documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991
  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. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @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
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * 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".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Normalize the current Vector3 with the given input length.
  2072. * Please note that this is an in place operation.
  2073. * @param len the length of the vector
  2074. * @returns the current updated Vector3
  2075. */
  2076. normalizeFromLength(len: number): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to a new vector
  2079. * @returns the new Vector3
  2080. */
  2081. normalizeToNew(): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to the reference
  2084. * @param reference define the Vector3 to update
  2085. * @returns the updated Vector3
  2086. */
  2087. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2088. /**
  2089. * Creates a new Vector3 copied from the current Vector3
  2090. * @returns the new Vector3
  2091. */
  2092. clone(): Vector3;
  2093. /**
  2094. * Copies the given vector coordinates to the current Vector3 ones
  2095. * @param source defines the source Vector3
  2096. * @returns the current updated Vector3
  2097. */
  2098. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2099. /**
  2100. * Copies the given floats to the current Vector3 coordinates
  2101. * @param x defines the x coordinate of the operand
  2102. * @param y defines the y coordinate of the operand
  2103. * @param z defines the z coordinate of the operand
  2104. * @returns the current updated Vector3
  2105. */
  2106. copyFromFloats(x: number, y: number, z: number): Vector3;
  2107. /**
  2108. * Copies the given floats to the current Vector3 coordinates
  2109. * @param x defines the x coordinate of the operand
  2110. * @param y defines the y coordinate of the operand
  2111. * @param z defines the z coordinate of the operand
  2112. * @returns the current updated Vector3
  2113. */
  2114. set(x: number, y: number, z: number): Vector3;
  2115. /**
  2116. * Copies the given float to the current Vector3 coordinates
  2117. * @param v defines the x, y and z coordinates of the operand
  2118. * @returns the current updated Vector3
  2119. */
  2120. setAll(v: number): Vector3;
  2121. /**
  2122. * Get the clip factor between two vectors
  2123. * @param vector0 defines the first operand
  2124. * @param vector1 defines the second operand
  2125. * @param axis defines the axis to use
  2126. * @param size defines the size along the axis
  2127. * @returns the clip factor
  2128. */
  2129. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2130. /**
  2131. * Get angle between two vectors
  2132. * @param vector0 angle between vector0 and vector1
  2133. * @param vector1 angle between vector0 and vector1
  2134. * @param normal direction of the normal
  2135. * @return the angle between vector0 and vector1
  2136. */
  2137. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2138. /**
  2139. * Returns a new Vector3 set from the index "offset" of the given array
  2140. * @param array defines the source array
  2141. * @param offset defines the offset in the source array
  2142. * @returns the new Vector3
  2143. */
  2144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2147. * This function is deprecated. Use FromArray instead
  2148. * @param array defines the source array
  2149. * @param offset defines the offset in the source array
  2150. * @returns the new Vector3
  2151. */
  2152. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2153. /**
  2154. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @param result defines the Vector3 where to store the result
  2158. */
  2159. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2162. * This function is deprecated. Use FromArrayToRef instead.
  2163. * @param array defines the source array
  2164. * @param offset defines the offset in the source array
  2165. * @param result defines the Vector3 where to store the result
  2166. */
  2167. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2168. /**
  2169. * Sets the given vector "result" with the given floats.
  2170. * @param x defines the x coordinate of the source
  2171. * @param y defines the y coordinate of the source
  2172. * @param z defines the z coordinate of the source
  2173. * @param result defines the Vector3 where to store the result
  2174. */
  2175. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2178. * @returns a new empty Vector3
  2179. */
  2180. static Zero(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2183. * @returns a new unit Vector3
  2184. */
  2185. static One(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2188. * @returns a new up Vector3
  2189. */
  2190. static Up(): Vector3;
  2191. /**
  2192. * Gets a up Vector3 that must not be updated
  2193. */
  2194. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2195. /**
  2196. * Gets a zero Vector3 that must not be updated
  2197. */
  2198. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2201. * @returns a new down Vector3
  2202. */
  2203. static Down(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Forward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Backward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2216. * @returns a new right Vector3
  2217. */
  2218. static Right(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2221. * @returns a new left Vector3
  2222. */
  2223. static Left(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2226. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2227. * @param vector defines the Vector3 to transform
  2228. * @param transformation defines the transformation matrix
  2229. * @returns the transformed Vector3
  2230. */
  2231. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2232. /**
  2233. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2234. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2235. * @param vector defines the Vector3 to transform
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2242. * This method computes tranformed coordinates only, not transformed direction vectors
  2243. * @param x define the x coordinate of the source vector
  2244. * @param y define the y coordinate of the source vector
  2245. * @param z define the z coordinate of the source vector
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2252. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2253. * @param vector defines the Vector3 to transform
  2254. * @param transformation defines the transformation matrix
  2255. * @returns the new Vector3
  2256. */
  2257. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2258. /**
  2259. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2260. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2261. * @param vector defines the Vector3 to transform
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2268. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2269. * @param x define the x coordinate of the source vector
  2270. * @param y define the y coordinate of the source vector
  2271. * @param z define the z coordinate of the source vector
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2278. * @param value1 defines the first control point
  2279. * @param value2 defines the second control point
  2280. * @param value3 defines the third control point
  2281. * @param value4 defines the fourth control point
  2282. * @param amount defines the amount on the spline to use
  2283. * @returns the new Vector3
  2284. */
  2285. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @returns the new Vector3
  2294. */
  2295. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @param result defines the Vector3 where to store the result
  2304. */
  2305. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2306. /**
  2307. * Checks if a given vector is inside a specific range
  2308. * @param v defines the vector to test
  2309. * @param min defines the minimum range
  2310. * @param max defines the maximum range
  2311. */
  2312. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2315. * @param value1 defines the first control point
  2316. * @param tangent1 defines the first tangent vector
  2317. * @param value2 defines the second control point
  2318. * @param tangent2 defines the second tangent vector
  2319. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2320. * @returns the new Vector3
  2321. */
  2322. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2325. * @param start defines the start value
  2326. * @param end defines the end value
  2327. * @param amount max defines amount between both (between 0 and 1)
  2328. * @returns the new Vector3
  2329. */
  2330. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2331. /**
  2332. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2333. * @param start defines the start value
  2334. * @param end defines the end value
  2335. * @param amount max defines amount between both (between 0 and 1)
  2336. * @param result defines the Vector3 where to store the result
  2337. */
  2338. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2339. /**
  2340. * Returns the dot product (float) between the vectors "left" and "right"
  2341. * @param left defines the left operand
  2342. * @param right defines the right operand
  2343. * @returns the dot product
  2344. */
  2345. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2346. /**
  2347. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2348. * The cross product is then orthogonal to both "left" and "right"
  2349. * @param left defines the left operand
  2350. * @param right defines the right operand
  2351. * @returns the cross product
  2352. */
  2353. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Sets the given vector "result" with the cross product of "left" and "right"
  2356. * The cross product is then orthogonal to both "left" and "right"
  2357. * @param left defines the left operand
  2358. * @param right defines the right operand
  2359. * @param result defines the Vector3 where to store the result
  2360. */
  2361. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2362. /**
  2363. * Returns a new Vector3 as the normalization of the given vector
  2364. * @param vector defines the Vector3 to normalize
  2365. * @returns the new Vector3
  2366. */
  2367. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2368. /**
  2369. * Sets the given vector "result" with the normalization of the given first vector
  2370. * @param vector defines the Vector3 to normalize
  2371. * @param result defines the Vector3 where to store the result
  2372. */
  2373. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2374. /**
  2375. * Project a Vector3 onto screen space
  2376. * @param vector defines the Vector3 to project
  2377. * @param world defines the world matrix to use
  2378. * @param transform defines the transform (view x projection) matrix to use
  2379. * @param viewport defines the screen viewport to use
  2380. * @returns the new Vector3
  2381. */
  2382. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2383. /** @hidden */
  2384. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2385. /**
  2386. * Unproject from screen space to object space
  2387. * @param source defines the screen space Vector3 to use
  2388. * @param viewportWidth defines the current width of the viewport
  2389. * @param viewportHeight defines the current height of the viewport
  2390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2391. * @param transform defines the transform (view x projection) matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @returns the new Vector3
  2404. */
  2405. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param source defines the screen space Vector3 to use
  2409. * @param viewportWidth defines the current width of the viewport
  2410. * @param viewportHeight defines the current height of the viewport
  2411. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2412. * @param view defines the view matrix to use
  2413. * @param projection defines the projection matrix to use
  2414. * @param result defines the Vector3 where to store the result
  2415. */
  2416. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2417. /**
  2418. * Unproject from screen space to object space
  2419. * @param sourceX defines the screen space x coordinate to use
  2420. * @param sourceY defines the screen space y coordinate to use
  2421. * @param sourceZ defines the screen space z coordinate to use
  2422. * @param viewportWidth defines the current width of the viewport
  2423. * @param viewportHeight defines the current height of the viewport
  2424. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2425. * @param view defines the view matrix to use
  2426. * @param projection defines the projection matrix to use
  2427. * @param result defines the Vector3 where to store the result
  2428. */
  2429. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2430. /**
  2431. * Gets the minimal coordinate values between two Vector3
  2432. * @param left defines the first operand
  2433. * @param right defines the second operand
  2434. * @returns the new Vector3
  2435. */
  2436. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2437. /**
  2438. * Gets the maximal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Returns the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines the first operand
  2447. * @param value2 defines the second operand
  2448. * @returns the distance
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the squared distance
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns a new Vector3 located at the center between "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the new Vector3
  2463. */
  2464. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2467. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2468. * to something in order to rotate it from its local system to the given target system
  2469. * Note: axis1, axis2 and axis3 are normalized during this operation
  2470. * @param axis1 defines the first axis
  2471. * @param axis2 defines the second axis
  2472. * @param axis3 defines the third axis
  2473. * @returns a new Vector3
  2474. */
  2475. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2478. * @param axis1 defines the first axis
  2479. * @param axis2 defines the second axis
  2480. * @param axis3 defines the third axis
  2481. * @param ref defines the Vector3 where to store the result
  2482. */
  2483. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2484. }
  2485. /**
  2486. * Vector4 class created for EulerAngle class conversion to Quaternion
  2487. */
  2488. export class Vector4 {
  2489. /** x value of the vector */
  2490. x: number;
  2491. /** y value of the vector */
  2492. y: number;
  2493. /** z value of the vector */
  2494. z: number;
  2495. /** w value of the vector */
  2496. w: number;
  2497. /**
  2498. * Creates a Vector4 object from the given floats.
  2499. * @param x x value of the vector
  2500. * @param y y value of the vector
  2501. * @param z z value of the vector
  2502. * @param w w value of the vector
  2503. */
  2504. constructor(
  2505. /** x value of the vector */
  2506. x: number,
  2507. /** y value of the vector */
  2508. y: number,
  2509. /** z value of the vector */
  2510. z: number,
  2511. /** w value of the vector */
  2512. w: number);
  2513. /**
  2514. * Returns the string with the Vector4 coordinates.
  2515. * @returns a string containing all the vector values
  2516. */
  2517. toString(): string;
  2518. /**
  2519. * Returns the string "Vector4".
  2520. * @returns "Vector4"
  2521. */
  2522. getClassName(): string;
  2523. /**
  2524. * Returns the Vector4 hash code.
  2525. * @returns a unique hash code
  2526. */
  2527. getHashCode(): number;
  2528. /**
  2529. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2530. * @returns the resulting array
  2531. */
  2532. asArray(): number[];
  2533. /**
  2534. * Populates the given array from the given index with the Vector4 coordinates.
  2535. * @param array array to populate
  2536. * @param index index of the array to start at (default: 0)
  2537. * @returns the Vector4.
  2538. */
  2539. toArray(array: FloatArray, index?: number): Vector4;
  2540. /**
  2541. * Adds the given vector to the current Vector4.
  2542. * @param otherVector the vector to add
  2543. * @returns the updated Vector4.
  2544. */
  2545. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @returns the resulting vector
  2550. */
  2551. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2552. /**
  2553. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2554. * @param otherVector the vector to add
  2555. * @param result the vector to store the result
  2556. * @returns the current Vector4.
  2557. */
  2558. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2559. /**
  2560. * Subtract in place the given vector from the current Vector4.
  2561. * @param otherVector the vector to subtract
  2562. * @returns the updated Vector4.
  2563. */
  2564. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to add
  2568. * @returns the new vector with the result
  2569. */
  2570. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2571. /**
  2572. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2573. * @param otherVector the vector to subtract
  2574. * @param result the vector to store the result
  2575. * @returns the current Vector4.
  2576. */
  2577. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2578. /**
  2579. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2580. */
  2581. /**
  2582. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2583. * @param x value to subtract
  2584. * @param y value to subtract
  2585. * @param z value to subtract
  2586. * @param w value to subtract
  2587. * @returns new vector containing the result
  2588. */
  2589. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2590. /**
  2591. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2592. * @param x value to subtract
  2593. * @param y value to subtract
  2594. * @param z value to subtract
  2595. * @param w value to subtract
  2596. * @param result the vector to store the result in
  2597. * @returns the current Vector4.
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2602. * @returns a new vector with the negated values
  2603. */
  2604. negate(): Vector4;
  2605. /**
  2606. * Multiplies the current Vector4 coordinates by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns the updated Vector4.
  2609. */
  2610. scaleInPlace(scale: number): Vector4;
  2611. /**
  2612. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @returns a new vector with the result
  2615. */
  2616. scale(scale: number): Vector4;
  2617. /**
  2618. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2619. * @param scale the number to scale with
  2620. * @param result a vector to store the result in
  2621. * @returns the current Vector4.
  2622. */
  2623. scaleToRef(scale: number, result: Vector4): Vector4;
  2624. /**
  2625. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2626. * @param scale defines the scale factor
  2627. * @param result defines the Vector4 object where to store the result
  2628. * @returns the unmodified current Vector4
  2629. */
  2630. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2633. * @param otherVector the vector to compare against
  2634. * @returns true if they are equal
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2637. /**
  2638. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2639. * @param otherVector vector to compare against
  2640. * @param epsilon (Default: very small number)
  2641. * @returns true if they are equal
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2644. /**
  2645. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2646. * @param x x value to compare against
  2647. * @param y y value to compare against
  2648. * @param z z value to compare against
  2649. * @param w w value to compare against
  2650. * @returns true if equal
  2651. */
  2652. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2653. /**
  2654. * Multiplies in place the current Vector4 by the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns the updated Vector4.
  2657. */
  2658. multiplyInPlace(otherVector: Vector4): Vector4;
  2659. /**
  2660. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @returns resulting new vector
  2663. */
  2664. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2665. /**
  2666. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2667. * @param otherVector vector to multiple with
  2668. * @param result vector to store the result
  2669. * @returns the current Vector4.
  2670. */
  2671. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2672. /**
  2673. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2674. * @param x x value multiply with
  2675. * @param y y value multiply with
  2676. * @param z z value multiply with
  2677. * @param w w value multiply with
  2678. * @returns resulting new vector
  2679. */
  2680. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2681. /**
  2682. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @returns resulting new vector
  2685. */
  2686. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2687. /**
  2688. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2689. * @param otherVector vector to devide with
  2690. * @param result vector to store the result
  2691. * @returns the current Vector4.
  2692. */
  2693. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2694. /**
  2695. * Divides the current Vector3 coordinates by the given ones.
  2696. * @param otherVector vector to devide with
  2697. * @returns the updated Vector3.
  2698. */
  2699. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2708. * @param other defines the second operand
  2709. * @returns the current updated Vector4
  2710. */
  2711. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector4 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. floor(): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector3 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. fract(): Vector4;
  2722. /**
  2723. * Returns the Vector4 length (float).
  2724. * @returns the length
  2725. */
  2726. length(): number;
  2727. /**
  2728. * Returns the Vector4 squared length (float).
  2729. * @returns the length squared
  2730. */
  2731. lengthSquared(): number;
  2732. /**
  2733. * Normalizes in place the Vector4.
  2734. * @returns the updated Vector4.
  2735. */
  2736. normalize(): Vector4;
  2737. /**
  2738. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2739. * @returns this converted to a new vector3
  2740. */
  2741. toVector3(): Vector3;
  2742. /**
  2743. * Returns a new Vector4 copied from the current one.
  2744. * @returns the new cloned vector
  2745. */
  2746. clone(): Vector4;
  2747. /**
  2748. * Updates the current Vector4 with the given one coordinates.
  2749. * @param source the source vector to copy from
  2750. * @returns the updated Vector4.
  2751. */
  2752. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2753. /**
  2754. * Updates the current Vector4 coordinates with the given floats.
  2755. * @param x float to copy from
  2756. * @param y float to copy from
  2757. * @param z float to copy from
  2758. * @param w float to copy from
  2759. * @returns the updated Vector4.
  2760. */
  2761. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2762. /**
  2763. * Updates the current Vector4 coordinates with the given floats.
  2764. * @param x float to set from
  2765. * @param y float to set from
  2766. * @param z float to set from
  2767. * @param w float to set from
  2768. * @returns the updated Vector4.
  2769. */
  2770. set(x: number, y: number, z: number, w: number): Vector4;
  2771. /**
  2772. * Copies the given float to the current Vector3 coordinates
  2773. * @param v defines the x, y, z and w coordinates of the operand
  2774. * @returns the current updated Vector3
  2775. */
  2776. setAll(v: number): Vector4;
  2777. /**
  2778. * Returns a new Vector4 set from the starting index of the given array.
  2779. * @param array the array to pull values from
  2780. * @param offset the offset into the array to start at
  2781. * @returns the new vector
  2782. */
  2783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2784. /**
  2785. * Updates the given vector "result" from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @param result the vector to store the result in
  2789. */
  2790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given Float32Array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" coordinates from the given floats.
  2800. * @param x float to set from
  2801. * @param y float to set from
  2802. * @param z float to set from
  2803. * @param w float to set from
  2804. * @param result the vector to the floats in
  2805. */
  2806. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2807. /**
  2808. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2809. * @returns the new vector
  2810. */
  2811. static Zero(): Vector4;
  2812. /**
  2813. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2814. * @returns the new vector
  2815. */
  2816. static One(): Vector4;
  2817. /**
  2818. * Returns a new normalized Vector4 from the given one.
  2819. * @param vector the vector to normalize
  2820. * @returns the vector
  2821. */
  2822. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2823. /**
  2824. * Updates the given vector "result" from the normalization of the given one.
  2825. * @param vector the vector to normalize
  2826. * @param result the vector to store the result in
  2827. */
  2828. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2829. /**
  2830. * Returns a vector with the minimum values from the left and right vectors
  2831. * @param left left vector to minimize
  2832. * @param right right vector to minimize
  2833. * @returns a new vector with the minimum of the left and right vector values
  2834. */
  2835. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2836. /**
  2837. * Returns a vector with the maximum values from the left and right vectors
  2838. * @param left left vector to maximize
  2839. * @param right right vector to maximize
  2840. * @returns a new vector with the maximum of the left and right vector values
  2841. */
  2842. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns the distance (float) between the vectors "value1" and "value2".
  2845. * @param value1 value to calulate the distance between
  2846. * @param value2 value to calulate the distance between
  2847. * @return the distance between the two vectors
  2848. */
  2849. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2850. /**
  2851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors squared
  2855. */
  2856. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the center between
  2860. * @param value2 value to calulate the center between
  2861. * @return the center between the two vectors
  2862. */
  2863. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2864. /**
  2865. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2866. * This methods computes transformed normalized direction vectors only.
  2867. * @param vector the vector to transform
  2868. * @param transformation the transformation matrix to apply
  2869. * @returns the new vector
  2870. */
  2871. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2872. /**
  2873. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2874. * This methods computes transformed normalized direction vectors only.
  2875. * @param vector the vector to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the result in
  2878. */
  2879. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2882. * This methods computes transformed normalized direction vectors only.
  2883. * @param x value to transform
  2884. * @param y value to transform
  2885. * @param z value to transform
  2886. * @param w value to transform
  2887. * @param transformation the transformation matrix to apply
  2888. * @param result the vector to store the results in
  2889. */
  2890. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2891. /**
  2892. * Creates a new Vector4 from a Vector3
  2893. * @param source defines the source data
  2894. * @param w defines the 4th component (default is 0)
  2895. * @returns a new Vector4
  2896. */
  2897. static FromVector3(source: Vector3, w?: number): Vector4;
  2898. }
  2899. /**
  2900. * Class used to store quaternion data
  2901. * @see https://en.wikipedia.org/wiki/Quaternion
  2902. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2903. */
  2904. export class Quaternion {
  2905. /** defines the first component (0 by default) */
  2906. x: number;
  2907. /** defines the second component (0 by default) */
  2908. y: number;
  2909. /** defines the third component (0 by default) */
  2910. z: number;
  2911. /** defines the fourth component (1.0 by default) */
  2912. w: number;
  2913. /**
  2914. * Creates a new Quaternion from the given floats
  2915. * @param x defines the first component (0 by default)
  2916. * @param y defines the second component (0 by default)
  2917. * @param z defines the third component (0 by default)
  2918. * @param w defines the fourth component (1.0 by default)
  2919. */
  2920. constructor(
  2921. /** defines the first component (0 by default) */
  2922. x?: number,
  2923. /** defines the second component (0 by default) */
  2924. y?: number,
  2925. /** defines the third component (0 by default) */
  2926. z?: number,
  2927. /** defines the fourth component (1.0 by default) */
  2928. w?: number);
  2929. /**
  2930. * Gets a string representation for the current quaternion
  2931. * @returns a string with the Quaternion coordinates
  2932. */
  2933. toString(): string;
  2934. /**
  2935. * Gets the class name of the quaternion
  2936. * @returns the string "Quaternion"
  2937. */
  2938. getClassName(): string;
  2939. /**
  2940. * Gets a hash code for this quaternion
  2941. * @returns the quaternion hash code
  2942. */
  2943. getHashCode(): number;
  2944. /**
  2945. * Copy the quaternion to an array
  2946. * @returns a new array populated with 4 elements from the quaternion coordinates
  2947. */
  2948. asArray(): number[];
  2949. /**
  2950. * Check if two quaternions are equals
  2951. * @param otherQuaternion defines the second operand
  2952. * @return true if the current quaternion and the given one coordinates are strictly equals
  2953. */
  2954. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2955. /**
  2956. * Clone the current quaternion
  2957. * @returns a new quaternion copied from the current one
  2958. */
  2959. clone(): Quaternion;
  2960. /**
  2961. * Copy a quaternion to the current one
  2962. * @param other defines the other quaternion
  2963. * @returns the updated current quaternion
  2964. */
  2965. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2966. /**
  2967. * Updates the current quaternion with the given float coordinates
  2968. * @param x defines the x coordinate
  2969. * @param y defines the y coordinate
  2970. * @param z defines the z coordinate
  2971. * @param w defines the w coordinate
  2972. * @returns the updated current quaternion
  2973. */
  2974. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2975. /**
  2976. * Updates the current quaternion from the given float coordinates
  2977. * @param x defines the x coordinate
  2978. * @param y defines the y coordinate
  2979. * @param z defines the z coordinate
  2980. * @param w defines the w coordinate
  2981. * @returns the updated current quaternion
  2982. */
  2983. set(x: number, y: number, z: number, w: number): Quaternion;
  2984. /**
  2985. * Adds two quaternions
  2986. * @param other defines the second operand
  2987. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2988. */
  2989. add(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Add a quaternion to the current one
  2992. * @param other defines the quaternion to add
  2993. * @returns the current quaternion
  2994. */
  2995. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2996. /**
  2997. * Subtract two quaternions
  2998. * @param other defines the second operand
  2999. * @returns a new quaternion as the subtraction result of the given one from the current one
  3000. */
  3001. subtract(other: Quaternion): Quaternion;
  3002. /**
  3003. * Multiplies the current quaternion by a scale factor
  3004. * @param value defines the scale factor
  3005. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3006. */
  3007. scale(value: number): Quaternion;
  3008. /**
  3009. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3010. * @param scale defines the scale factor
  3011. * @param result defines the Quaternion object where to store the result
  3012. * @returns the unmodified current quaternion
  3013. */
  3014. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3015. /**
  3016. * Multiplies in place the current quaternion by a scale factor
  3017. * @param value defines the scale factor
  3018. * @returns the current modified quaternion
  3019. */
  3020. scaleInPlace(value: number): Quaternion;
  3021. /**
  3022. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3023. * @param scale defines the scale factor
  3024. * @param result defines the Quaternion object where to store the result
  3025. * @returns the unmodified current quaternion
  3026. */
  3027. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3028. /**
  3029. * Multiplies two quaternions
  3030. * @param q1 defines the second operand
  3031. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3032. */
  3033. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3034. /**
  3035. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3036. * @param q1 defines the second operand
  3037. * @param result defines the target quaternion
  3038. * @returns the current quaternion
  3039. */
  3040. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3041. /**
  3042. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @returns the currentupdated quaternion
  3045. */
  3046. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3047. /**
  3048. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3049. * @param ref defines the target quaternion
  3050. * @returns the current quaternion
  3051. */
  3052. conjugateToRef(ref: Quaternion): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns the current updated quaternion
  3056. */
  3057. conjugateInPlace(): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns a new quaternion
  3061. */
  3062. conjugate(): Quaternion;
  3063. /**
  3064. * Gets length of current quaternion
  3065. * @returns the quaternion length (float)
  3066. */
  3067. length(): number;
  3068. /**
  3069. * Normalize in place the current quaternion
  3070. * @returns the current updated quaternion
  3071. */
  3072. normalize(): Quaternion;
  3073. /**
  3074. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3075. * @param order is a reserved parameter and is ignore for now
  3076. * @returns a new Vector3 containing the Euler angles
  3077. */
  3078. toEulerAngles(order?: string): Vector3;
  3079. /**
  3080. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3081. * @param result defines the vector which will be filled with the Euler angles
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toEulerAnglesToRef(result: Vector3): Quaternion;
  3086. /**
  3087. * Updates the given rotation matrix with the current quaternion values
  3088. * @param result defines the target matrix
  3089. * @returns the current unchanged quaternion
  3090. */
  3091. toRotationMatrix(result: Matrix): Quaternion;
  3092. /**
  3093. * Updates the current quaternion from the given rotation matrix values
  3094. * @param matrix defines the source matrix
  3095. * @returns the current updated quaternion
  3096. */
  3097. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Creates a new quaternion from a rotation matrix
  3100. * @param matrix defines the source matrix
  3101. * @returns a new quaternion created from the given rotation matrix values
  3102. */
  3103. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3104. /**
  3105. * Updates the given quaternion with the given rotation matrix values
  3106. * @param matrix defines the source matrix
  3107. * @param result defines the target quaternion
  3108. */
  3109. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3110. /**
  3111. * Returns the dot product (float) between the quaternions "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @returns the dot product
  3115. */
  3116. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3117. /**
  3118. * Checks if the two quaternions are close to each other
  3119. * @param quat0 defines the first quaternion to check
  3120. * @param quat1 defines the second quaternion to check
  3121. * @returns true if the two quaternions are close to each other
  3122. */
  3123. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3124. /**
  3125. * Creates an empty quaternion
  3126. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3127. */
  3128. static Zero(): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @returns a new quaternion as the inverted current quaternion
  3133. */
  3134. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3135. /**
  3136. * Inverse a given quaternion
  3137. * @param q defines the source quaternion
  3138. * @param result the quaternion the result will be stored in
  3139. * @returns the result quaternion
  3140. */
  3141. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3142. /**
  3143. * Creates an identity quaternion
  3144. * @returns the identity quaternion
  3145. */
  3146. static Identity(): Quaternion;
  3147. /**
  3148. * Gets a boolean indicating if the given quaternion is identity
  3149. * @param quaternion defines the quaternion to check
  3150. * @returns true if the quaternion is identity
  3151. */
  3152. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3153. /**
  3154. * Creates a quaternion from a rotation around an axis
  3155. * @param axis defines the axis to use
  3156. * @param angle defines the angle to use
  3157. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3158. */
  3159. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3160. /**
  3161. * Creates a rotation around an axis and stores it into the given quaternion
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @param result defines the target quaternion
  3165. * @returns the target quaternion
  3166. */
  3167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3168. /**
  3169. * Creates a new quaternion from data stored into an array
  3170. * @param array defines the data source
  3171. * @param offset defines the offset in the source array where the data starts
  3172. * @returns a new quaternion
  3173. */
  3174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3175. /**
  3176. * Create a quaternion from Euler rotation angles
  3177. * @param x Pitch
  3178. * @param y Yaw
  3179. * @param z Roll
  3180. * @returns the new Quaternion
  3181. */
  3182. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3183. /**
  3184. * Updates a quaternion from Euler rotation angles
  3185. * @param x Pitch
  3186. * @param y Yaw
  3187. * @param z Roll
  3188. * @param result the quaternion to store the result
  3189. * @returns the updated quaternion
  3190. */
  3191. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @returns the new Quaternion
  3196. */
  3197. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3198. /**
  3199. * Updates a quaternion from Euler rotation vector
  3200. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3201. * @param result the quaternion to store the result
  3202. * @returns the updated quaternion
  3203. */
  3204. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3205. /**
  3206. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3207. * @param yaw defines the rotation around Y axis
  3208. * @param pitch defines the rotation around X axis
  3209. * @param roll defines the rotation around Z axis
  3210. * @returns the new quaternion
  3211. */
  3212. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3213. /**
  3214. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3215. * @param yaw defines the rotation around Y axis
  3216. * @param pitch defines the rotation around X axis
  3217. * @param roll defines the rotation around Z axis
  3218. * @param result defines the target quaternion
  3219. */
  3220. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3221. /**
  3222. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3223. * @param alpha defines the rotation around first axis
  3224. * @param beta defines the rotation around second axis
  3225. * @param gamma defines the rotation around third axis
  3226. * @returns the new quaternion
  3227. */
  3228. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3229. /**
  3230. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3231. * @param alpha defines the rotation around first axis
  3232. * @param beta defines the rotation around second axis
  3233. * @param gamma defines the rotation around third axis
  3234. * @param result defines the target quaternion
  3235. */
  3236. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3237. /**
  3238. * 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)
  3239. * @param axis1 defines the first axis
  3240. * @param axis2 defines the second axis
  3241. * @param axis3 defines the third axis
  3242. * @returns the new quaternion
  3243. */
  3244. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3245. /**
  3246. * 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
  3247. * @param axis1 defines the first axis
  3248. * @param axis2 defines the second axis
  3249. * @param axis3 defines the third axis
  3250. * @param ref defines the target quaternion
  3251. */
  3252. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3253. /**
  3254. * Interpolates between two quaternions
  3255. * @param left defines first quaternion
  3256. * @param right defines second quaternion
  3257. * @param amount defines the gradient to use
  3258. * @returns the new interpolated quaternion
  3259. */
  3260. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3261. /**
  3262. * Interpolates between two quaternions and stores it into a target quaternion
  3263. * @param left defines first quaternion
  3264. * @param right defines second quaternion
  3265. * @param amount defines the gradient to use
  3266. * @param result defines the target quaternion
  3267. */
  3268. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3269. /**
  3270. * Interpolate between two quaternions using Hermite interpolation
  3271. * @param value1 defines first quaternion
  3272. * @param tangent1 defines the incoming tangent
  3273. * @param value2 defines second quaternion
  3274. * @param tangent2 defines the outgoing tangent
  3275. * @param amount defines the target quaternion
  3276. * @returns the new interpolated quaternion
  3277. */
  3278. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3279. }
  3280. /**
  3281. * Class used to store matrix data (4x4)
  3282. */
  3283. export class Matrix {
  3284. private static _updateFlagSeed;
  3285. private static _identityReadOnly;
  3286. private _isIdentity;
  3287. private _isIdentityDirty;
  3288. private _isIdentity3x2;
  3289. private _isIdentity3x2Dirty;
  3290. /**
  3291. * Gets the update flag of the matrix which is an unique number for the matrix.
  3292. * It will be incremented every time the matrix data change.
  3293. * You can use it to speed the comparison between two versions of the same matrix.
  3294. */
  3295. updateFlag: number;
  3296. private readonly _m;
  3297. /**
  3298. * Gets the internal data of the matrix
  3299. */
  3300. readonly m: DeepImmutable<Float32Array>;
  3301. /** @hidden */
  3302. _markAsUpdated(): void;
  3303. /** @hidden */
  3304. private _updateIdentityStatus;
  3305. /**
  3306. * Creates an empty matrix (filled with zeros)
  3307. */
  3308. constructor();
  3309. /**
  3310. * Check if the current matrix is identity
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentity(): boolean;
  3314. /**
  3315. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentityAs3x2(): boolean;
  3319. /**
  3320. * Gets the determinant of the matrix
  3321. * @returns the matrix determinant
  3322. */
  3323. determinant(): number;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array
  3327. */
  3328. toArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array.
  3332. */
  3333. asArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Inverts the current matrix in place
  3336. * @returns the current inverted matrix
  3337. */
  3338. invert(): Matrix;
  3339. /**
  3340. * Sets all the matrix elements to zero
  3341. * @returns the current matrix
  3342. */
  3343. reset(): Matrix;
  3344. /**
  3345. * Adds the current matrix with a second one
  3346. * @param other defines the matrix to add
  3347. * @returns a new matrix as the addition of the current matrix and the given one
  3348. */
  3349. add(other: DeepImmutable<Matrix>): Matrix;
  3350. /**
  3351. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3352. * @param other defines the matrix to add
  3353. * @param result defines the target matrix
  3354. * @returns the current matrix
  3355. */
  3356. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3357. /**
  3358. * Adds in place the given matrix to the current matrix
  3359. * @param other defines the second operand
  3360. * @returns the current updated matrix
  3361. */
  3362. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3363. /**
  3364. * Sets the given matrix to the current inverted Matrix
  3365. * @param other defines the target matrix
  3366. * @returns the unmodified current matrix
  3367. */
  3368. invertToRef(other: Matrix): Matrix;
  3369. /**
  3370. * add a value at the specified position in the current Matrix
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. addAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * mutiply the specified position in the current Matrix by a value
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. multiplyAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * Inserts the translation vector (using 3 floats) in the current matrix
  3385. * @param x defines the 1st component of the translation
  3386. * @param y defines the 2nd component of the translation
  3387. * @param z defines the 3rd component of the translation
  3388. * @returns the current updated matrix
  3389. */
  3390. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3391. /**
  3392. * Adds the translation vector (using 3 floats) in the current matrix
  3393. * @param x defines the 1st component of the translation
  3394. * @param y defines the 2nd component of the translation
  3395. * @param z defines the 3rd component of the translation
  3396. * @returns the current updated matrix
  3397. */
  3398. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3399. /**
  3400. * Inserts the translation vector in the current matrix
  3401. * @param vector3 defines the translation to insert
  3402. * @returns the current updated matrix
  3403. */
  3404. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3405. /**
  3406. * Gets the translation value of the current matrix
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * @param result defines the Vector3 where to store the translation
  3413. * @returns the current matrix
  3414. */
  3415. getTranslationToRef(result: Vector3): Matrix;
  3416. /**
  3417. * Remove rotation and scaling part from the matrix
  3418. * @returns the updated matrix
  3419. */
  3420. removeRotationAndScaling(): Matrix;
  3421. /**
  3422. * Multiply two matrices
  3423. * @param other defines the second operand
  3424. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3425. */
  3426. multiply(other: DeepImmutable<Matrix>): Matrix;
  3427. /**
  3428. * Copy the current matrix from the given one
  3429. * @param other defines the source matrix
  3430. * @returns the current updated matrix
  3431. */
  3432. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3433. /**
  3434. * Populates the given array from the starting index with the current matrix values
  3435. * @param array defines the target array
  3436. * @param offset defines the offset in the target array where to start storing values
  3437. * @returns the current matrix
  3438. */
  3439. copyToArray(array: Float32Array, offset?: number): Matrix;
  3440. /**
  3441. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the matrix where to store the multiplication
  3444. * @returns the current matrix
  3445. */
  3446. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3447. /**
  3448. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the array where to store the multiplication
  3451. * @param offset defines the offset in the target array where to start storing values
  3452. * @returns the current matrix
  3453. */
  3454. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3455. /**
  3456. * Check equality between this matrix and a second one
  3457. * @param value defines the second matrix to compare
  3458. * @returns true is the current matrix and the given one values are strictly equal
  3459. */
  3460. equals(value: DeepImmutable<Matrix>): boolean;
  3461. /**
  3462. * Clone the current matrix
  3463. * @returns a new matrix from the current matrix
  3464. */
  3465. clone(): Matrix;
  3466. /**
  3467. * Returns the name of the current matrix class
  3468. * @returns the string "Matrix"
  3469. */
  3470. getClassName(): string;
  3471. /**
  3472. * Gets the hash code of the current matrix
  3473. * @returns the hash code
  3474. */
  3475. getHashCode(): number;
  3476. /**
  3477. * Decomposes the current Matrix into a translation, rotation and scaling components
  3478. * @param scale defines the scale vector3 given as a reference to update
  3479. * @param rotation defines the rotation quaternion given as a reference to update
  3480. * @param translation defines the translation vector3 given as a reference to update
  3481. * @returns true if operation was successful
  3482. */
  3483. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3484. /**
  3485. * Gets specific row of the matrix
  3486. * @param index defines the number of the row to get
  3487. * @returns the index-th row of the current matrix as a new Vector4
  3488. */
  3489. getRow(index: number): Nullable<Vector4>;
  3490. /**
  3491. * Sets the index-th row of the current matrix to the vector4 values
  3492. * @param index defines the number of the row to set
  3493. * @param row defines the target vector4
  3494. * @returns the updated current matrix
  3495. */
  3496. setRow(index: number, row: Vector4): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix
  3499. * @returns the new transposed matrix
  3500. */
  3501. transpose(): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix and store it in a given matrix
  3504. * @param result defines the target matrix
  3505. * @returns the current matrix
  3506. */
  3507. transposeToRef(result: Matrix): Matrix;
  3508. /**
  3509. * Sets the index-th row of the current matrix with the given 4 x float values
  3510. * @param index defines the row index
  3511. * @param x defines the x component to set
  3512. * @param y defines the y component to set
  3513. * @param z defines the z component to set
  3514. * @param w defines the w component to set
  3515. * @returns the updated current matrix
  3516. */
  3517. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3518. /**
  3519. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3520. * @param scale defines the scale factor
  3521. * @returns a new matrix
  3522. */
  3523. scale(scale: number): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor to a given result matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor and add the result to a given matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3540. * @param ref matrix to store the result
  3541. */
  3542. toNormalMatrix(ref: Matrix): void;
  3543. /**
  3544. * Gets only rotation part of the current matrix
  3545. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3546. */
  3547. getRotationMatrix(): Matrix;
  3548. /**
  3549. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3550. * @param result defines the target matrix to store data to
  3551. * @returns the current matrix
  3552. */
  3553. getRotationMatrixToRef(result: Matrix): Matrix;
  3554. /**
  3555. * Toggles model matrix from being right handed to left handed in place and vice versa
  3556. */
  3557. toggleModelMatrixHandInPlace(): void;
  3558. /**
  3559. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3560. */
  3561. toggleProjectionMatrixHandInPlace(): void;
  3562. /**
  3563. * Creates a matrix from an array
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @returns a new Matrix set from the starting index of the given array
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3569. /**
  3570. * Copy the content of an array into a given matrix
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @param result defines the target matrix
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3576. /**
  3577. * Stores an array into a matrix after having multiplied each component by a given factor
  3578. * @param array defines the source array
  3579. * @param offset defines the offset in the source array
  3580. * @param scale defines the scaling factor
  3581. * @param result defines the target matrix
  3582. */
  3583. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3584. /**
  3585. * Gets an identity matrix that must not be updated
  3586. */
  3587. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3588. /**
  3589. * Stores a list of values (16) inside a given matrix
  3590. * @param initialM11 defines 1st value of 1st row
  3591. * @param initialM12 defines 2nd value of 1st row
  3592. * @param initialM13 defines 3rd value of 1st row
  3593. * @param initialM14 defines 4th value of 1st row
  3594. * @param initialM21 defines 1st value of 2nd row
  3595. * @param initialM22 defines 2nd value of 2nd row
  3596. * @param initialM23 defines 3rd value of 2nd row
  3597. * @param initialM24 defines 4th value of 2nd row
  3598. * @param initialM31 defines 1st value of 3rd row
  3599. * @param initialM32 defines 2nd value of 3rd row
  3600. * @param initialM33 defines 3rd value of 3rd row
  3601. * @param initialM34 defines 4th value of 3rd row
  3602. * @param initialM41 defines 1st value of 4th row
  3603. * @param initialM42 defines 2nd value of 4th row
  3604. * @param initialM43 defines 3rd value of 4th row
  3605. * @param initialM44 defines 4th value of 4th row
  3606. * @param result defines the target matrix
  3607. */
  3608. 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;
  3609. /**
  3610. * Creates new matrix from a list of values (16)
  3611. * @param initialM11 defines 1st value of 1st row
  3612. * @param initialM12 defines 2nd value of 1st row
  3613. * @param initialM13 defines 3rd value of 1st row
  3614. * @param initialM14 defines 4th value of 1st row
  3615. * @param initialM21 defines 1st value of 2nd row
  3616. * @param initialM22 defines 2nd value of 2nd row
  3617. * @param initialM23 defines 3rd value of 2nd row
  3618. * @param initialM24 defines 4th value of 2nd row
  3619. * @param initialM31 defines 1st value of 3rd row
  3620. * @param initialM32 defines 2nd value of 3rd row
  3621. * @param initialM33 defines 3rd value of 3rd row
  3622. * @param initialM34 defines 4th value of 3rd row
  3623. * @param initialM41 defines 1st value of 4th row
  3624. * @param initialM42 defines 2nd value of 4th row
  3625. * @param initialM43 defines 3rd value of 4th row
  3626. * @param initialM44 defines 4th value of 4th row
  3627. * @returns the new matrix
  3628. */
  3629. 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;
  3630. /**
  3631. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3632. * @param scale defines the scale vector3
  3633. * @param rotation defines the rotation quaternion
  3634. * @param translation defines the translation vector3
  3635. * @returns a new matrix
  3636. */
  3637. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3638. /**
  3639. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3640. * @param scale defines the scale vector3
  3641. * @param rotation defines the rotation quaternion
  3642. * @param translation defines the translation vector3
  3643. * @param result defines the target matrix
  3644. */
  3645. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3646. /**
  3647. * Creates a new identity matrix
  3648. * @returns a new identity matrix
  3649. */
  3650. static Identity(): Matrix;
  3651. /**
  3652. * Creates a new identity matrix and stores the result in a given matrix
  3653. * @param result defines the target matrix
  3654. */
  3655. static IdentityToRef(result: Matrix): void;
  3656. /**
  3657. * Creates a new zero matrix
  3658. * @returns a new zero matrix
  3659. */
  3660. static Zero(): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis
  3663. * @param angle defines the angle (in radians) to use
  3664. * @return the new matrix
  3665. */
  3666. static RotationX(angle: number): Matrix;
  3667. /**
  3668. * Creates a new matrix as the invert of a given matrix
  3669. * @param source defines the source matrix
  3670. * @returns the new matrix
  3671. */
  3672. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationXToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Y axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationY(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationYToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the Z axis
  3693. * @param angle defines the angle (in radians) to use
  3694. * @return the new matrix
  3695. */
  3696. static RotationZ(angle: number): Matrix;
  3697. /**
  3698. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3699. * @param angle defines the angle (in radians) to use
  3700. * @param result defines the target matrix
  3701. */
  3702. static RotationZToRef(angle: number, result: Matrix): void;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @return the new matrix
  3708. */
  3709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @param result defines the target matrix
  3715. */
  3716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3717. /**
  3718. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3719. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3720. * @param from defines the vector to align
  3721. * @param to defines the vector to align to
  3722. * @param result defines the target matrix
  3723. */
  3724. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3725. /**
  3726. * Creates a rotation matrix
  3727. * @param yaw defines the yaw angle in radians (Y axis)
  3728. * @param pitch defines the pitch angle in radians (X axis)
  3729. * @param roll defines the roll angle in radians (X axis)
  3730. * @returns the new rotation matrix
  3731. */
  3732. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3733. /**
  3734. * Creates a rotation matrix and stores it in a given matrix
  3735. * @param yaw defines the yaw angle in radians (Y axis)
  3736. * @param pitch defines the pitch angle in radians (X axis)
  3737. * @param roll defines the roll angle in radians (X axis)
  3738. * @param result defines the target matrix
  3739. */
  3740. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3741. /**
  3742. * Creates a scaling matrix
  3743. * @param x defines the scale factor on X axis
  3744. * @param y defines the scale factor on Y axis
  3745. * @param z defines the scale factor on Z axis
  3746. * @returns the new matrix
  3747. */
  3748. static Scaling(x: number, y: number, z: number): Matrix;
  3749. /**
  3750. * Creates a scaling matrix and stores it in a given matrix
  3751. * @param x defines the scale factor on X axis
  3752. * @param y defines the scale factor on Y axis
  3753. * @param z defines the scale factor on Z axis
  3754. * @param result defines the target matrix
  3755. */
  3756. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3757. /**
  3758. * Creates a translation matrix
  3759. * @param x defines the translation on X axis
  3760. * @param y defines the translation on Y axis
  3761. * @param z defines the translationon Z axis
  3762. * @returns the new matrix
  3763. */
  3764. static Translation(x: number, y: number, z: number): Matrix;
  3765. /**
  3766. * Creates a translation matrix and stores it in a given matrix
  3767. * @param x defines the translation on X axis
  3768. * @param y defines the translation on Y axis
  3769. * @param z defines the translationon Z axis
  3770. * @param result defines the target matrix
  3771. */
  3772. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3773. /**
  3774. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3775. * @param startValue defines the start value
  3776. * @param endValue defines the end value
  3777. * @param gradient defines the gradient factor
  3778. * @returns the new matrix
  3779. */
  3780. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3781. /**
  3782. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3783. * @param startValue defines the start value
  3784. * @param endValue defines the end value
  3785. * @param gradient defines the gradient factor
  3786. * @param result defines the Matrix object where to store data
  3787. */
  3788. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3789. /**
  3790. * Builds a new matrix whose values are computed by:
  3791. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3792. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3793. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3794. * @param startValue defines the first matrix
  3795. * @param endValue defines the second matrix
  3796. * @param gradient defines the gradient between the two matrices
  3797. * @returns the new matrix
  3798. */
  3799. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3800. /**
  3801. * Update a matrix to values which are computed by:
  3802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3805. * @param startValue defines the first matrix
  3806. * @param endValue defines the second matrix
  3807. * @param gradient defines the gradient between the two matrices
  3808. * @param result defines the target matrix
  3809. */
  3810. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3811. /**
  3812. * 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"
  3813. * This function works in left handed mode
  3814. * @param eye defines the final position of the entity
  3815. * @param target defines where the entity should look at
  3816. * @param up defines the up vector for the entity
  3817. * @returns the new matrix
  3818. */
  3819. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3820. /**
  3821. * 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".
  3822. * This function works in left handed mode
  3823. * @param eye defines the final position of the entity
  3824. * @param target defines where the entity should look at
  3825. * @param up defines the up vector for the entity
  3826. * @param result defines the target matrix
  3827. */
  3828. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3829. /**
  3830. * 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"
  3831. * This function works in right handed mode
  3832. * @param eye defines the final position of the entity
  3833. * @param target defines where the entity should look at
  3834. * @param up defines the up vector for the entity
  3835. * @returns the new matrix
  3836. */
  3837. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3838. /**
  3839. * 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".
  3840. * This function works in right handed mode
  3841. * @param eye defines the final position of the entity
  3842. * @param target defines where the entity should look at
  3843. * @param up defines the up vector for the entity
  3844. * @param result defines the target matrix
  3845. */
  3846. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3847. /**
  3848. * Create a left-handed orthographic projection matrix
  3849. * @param width defines the viewport width
  3850. * @param height defines the viewport height
  3851. * @param znear defines the near clip plane
  3852. * @param zfar defines the far clip plane
  3853. * @returns a new matrix as a left-handed orthographic projection matrix
  3854. */
  3855. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3856. /**
  3857. * Store a left-handed orthographic projection to a given matrix
  3858. * @param width defines the viewport width
  3859. * @param height defines the viewport height
  3860. * @param znear defines the near clip plane
  3861. * @param zfar defines the far clip plane
  3862. * @param result defines the target matrix
  3863. */
  3864. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3865. /**
  3866. * Create a left-handed orthographic projection matrix
  3867. * @param left defines the viewport left coordinate
  3868. * @param right defines the viewport right coordinate
  3869. * @param bottom defines the viewport bottom coordinate
  3870. * @param top defines the viewport top coordinate
  3871. * @param znear defines the near clip plane
  3872. * @param zfar defines the far clip plane
  3873. * @returns a new matrix as a left-handed orthographic projection matrix
  3874. */
  3875. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3876. /**
  3877. * Stores a left-handed orthographic projection into a given matrix
  3878. * @param left defines the viewport left coordinate
  3879. * @param right defines the viewport right coordinate
  3880. * @param bottom defines the viewport bottom coordinate
  3881. * @param top defines the viewport top coordinate
  3882. * @param znear defines the near clip plane
  3883. * @param zfar defines the far clip plane
  3884. * @param result defines the target matrix
  3885. */
  3886. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3887. /**
  3888. * Creates a right-handed orthographic projection matrix
  3889. * @param left defines the viewport left coordinate
  3890. * @param right defines the viewport right coordinate
  3891. * @param bottom defines the viewport bottom coordinate
  3892. * @param top defines the viewport top coordinate
  3893. * @param znear defines the near clip plane
  3894. * @param zfar defines the far clip plane
  3895. * @returns a new matrix as a right-handed orthographic projection matrix
  3896. */
  3897. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3898. /**
  3899. * Stores a right-handed orthographic projection into a given matrix
  3900. * @param left defines the viewport left coordinate
  3901. * @param right defines the viewport right coordinate
  3902. * @param bottom defines the viewport bottom coordinate
  3903. * @param top defines the viewport top coordinate
  3904. * @param znear defines the near clip plane
  3905. * @param zfar defines the far clip plane
  3906. * @param result defines the target matrix
  3907. */
  3908. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3909. /**
  3910. * Creates a left-handed perspective projection matrix
  3911. * @param width defines the viewport width
  3912. * @param height defines the viewport height
  3913. * @param znear defines the near clip plane
  3914. * @param zfar defines the far clip plane
  3915. * @returns a new matrix as a left-handed perspective projection matrix
  3916. */
  3917. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3918. /**
  3919. * Creates a left-handed perspective projection matrix
  3920. * @param fov defines the horizontal field of view
  3921. * @param aspect defines the aspect ratio
  3922. * @param znear defines the near clip plane
  3923. * @param zfar defines the far clip plane
  3924. * @returns a new matrix as a left-handed perspective projection matrix
  3925. */
  3926. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3927. /**
  3928. * Stores a left-handed perspective projection into a given matrix
  3929. * @param fov defines the horizontal field of view
  3930. * @param aspect defines the aspect ratio
  3931. * @param znear defines the near clip plane
  3932. * @param zfar defines the far clip plane
  3933. * @param result defines the target matrix
  3934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3935. */
  3936. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3937. /**
  3938. * Creates a right-handed perspective projection matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @returns a new matrix as a right-handed perspective projection matrix
  3944. */
  3945. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3946. /**
  3947. * Stores a right-handed perspective projection into a given matrix
  3948. * @param fov defines the horizontal field of view
  3949. * @param aspect defines the aspect ratio
  3950. * @param znear defines the near clip plane
  3951. * @param zfar defines the far clip plane
  3952. * @param result defines the target matrix
  3953. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3954. */
  3955. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3956. /**
  3957. * Stores a perspective projection for WebVR info a given matrix
  3958. * @param fov defines the field of view
  3959. * @param znear defines the near clip plane
  3960. * @param zfar defines the far clip plane
  3961. * @param result defines the target matrix
  3962. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3963. */
  3964. static PerspectiveFovWebVRToRef(fov: {
  3965. upDegrees: number;
  3966. downDegrees: number;
  3967. leftDegrees: number;
  3968. rightDegrees: number;
  3969. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3970. /**
  3971. * Computes a complete transformation matrix
  3972. * @param viewport defines the viewport to use
  3973. * @param world defines the world matrix
  3974. * @param view defines the view matrix
  3975. * @param projection defines the projection matrix
  3976. * @param zmin defines the near clip plane
  3977. * @param zmax defines the far clip plane
  3978. * @returns the transformation matrix
  3979. */
  3980. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3981. /**
  3982. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3983. * @param matrix defines the matrix to use
  3984. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3985. */
  3986. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3987. /**
  3988. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3989. * @param matrix defines the matrix to use
  3990. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3991. */
  3992. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3993. /**
  3994. * Compute the transpose of a given matrix
  3995. * @param matrix defines the matrix to transpose
  3996. * @returns the new matrix
  3997. */
  3998. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3999. /**
  4000. * Compute the transpose of a matrix and store it in a target matrix
  4001. * @param matrix defines the matrix to transpose
  4002. * @param result defines the target matrix
  4003. */
  4004. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4005. /**
  4006. * Computes a reflection matrix from a plane
  4007. * @param plane defines the reflection plane
  4008. * @returns a new matrix
  4009. */
  4010. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4011. /**
  4012. * Computes a reflection matrix from a plane
  4013. * @param plane defines the reflection plane
  4014. * @param result defines the target matrix
  4015. */
  4016. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4017. /**
  4018. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4019. * @param xaxis defines the value of the 1st axis
  4020. * @param yaxis defines the value of the 2nd axis
  4021. * @param zaxis defines the value of the 3rd axis
  4022. * @param result defines the target matrix
  4023. */
  4024. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4025. /**
  4026. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4027. * @param quat defines the quaternion to use
  4028. * @param result defines the target matrix
  4029. */
  4030. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4031. }
  4032. /**
  4033. * @hidden
  4034. */
  4035. export class TmpVectors {
  4036. static Vector2: Vector2[];
  4037. static Vector3: Vector3[];
  4038. static Vector4: Vector4[];
  4039. static Quaternion: Quaternion[];
  4040. static Matrix: Matrix[];
  4041. }
  4042. }
  4043. declare module BABYLON {
  4044. /** Defines the cross module used constants to avoid circular dependncies */
  4045. export class Constants {
  4046. /** Defines that alpha blending is disabled */
  4047. static readonly ALPHA_DISABLE: number;
  4048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4049. static readonly ALPHA_ADD: number;
  4050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4051. static readonly ALPHA_COMBINE: number;
  4052. /** Defines that alpha blending to DEST - SRC * DEST */
  4053. static readonly ALPHA_SUBTRACT: number;
  4054. /** Defines that alpha blending to SRC * DEST */
  4055. static readonly ALPHA_MULTIPLY: number;
  4056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4057. static readonly ALPHA_MAXIMIZED: number;
  4058. /** Defines that alpha blending to SRC + DEST */
  4059. static readonly ALPHA_ONEONE: number;
  4060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_PREMULTIPLIED: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4068. static readonly ALPHA_INTERPOLATE: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_SCREENMODE: number;
  4074. /** Defines that the ressource is not delayed*/
  4075. static readonly DELAYLOADSTATE_NONE: number;
  4076. /** Defines that the ressource was successfully delay loaded */
  4077. static readonly DELAYLOADSTATE_LOADED: number;
  4078. /** Defines that the ressource is currently delay loading */
  4079. static readonly DELAYLOADSTATE_LOADING: number;
  4080. /** Defines that the ressource is delayed and has not started loading */
  4081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4083. static readonly NEVER: number;
  4084. /** 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 */
  4085. static readonly ALWAYS: number;
  4086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4087. static readonly LESS: number;
  4088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4089. static readonly EQUAL: number;
  4090. /** 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 */
  4091. static readonly LEQUAL: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4093. static readonly GREATER: number;
  4094. /** 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 */
  4095. static readonly GEQUAL: number;
  4096. /** 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 */
  4097. static readonly NOTEQUAL: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be kept */
  4099. static readonly KEEP: number;
  4100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4101. static readonly REPLACE: number;
  4102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4103. static readonly INCR: number;
  4104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4105. static readonly DECR: number;
  4106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4107. static readonly INVERT: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4109. static readonly INCR_WRAP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4111. static readonly DECR_WRAP: number;
  4112. /** Texture is not repeating outside of 0..1 UVs */
  4113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4114. /** Texture is repeating outside of 0..1 UVs */
  4115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4116. /** Texture is repeating and mirrored */
  4117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4118. /** ALPHA */
  4119. static readonly TEXTUREFORMAT_ALPHA: number;
  4120. /** LUMINANCE */
  4121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4122. /** LUMINANCE_ALPHA */
  4123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4124. /** RGB */
  4125. static readonly TEXTUREFORMAT_RGB: number;
  4126. /** RGBA */
  4127. static readonly TEXTUREFORMAT_RGBA: number;
  4128. /** RED */
  4129. static readonly TEXTUREFORMAT_RED: number;
  4130. /** RED (2nd reference) */
  4131. static readonly TEXTUREFORMAT_R: number;
  4132. /** RG */
  4133. static readonly TEXTUREFORMAT_RG: number;
  4134. /** RED_INTEGER */
  4135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4136. /** RED_INTEGER (2nd reference) */
  4137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4138. /** RG_INTEGER */
  4139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4140. /** RGB_INTEGER */
  4141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4142. /** RGBA_INTEGER */
  4143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4144. /** UNSIGNED_BYTE */
  4145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4146. /** UNSIGNED_BYTE (2nd reference) */
  4147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4148. /** FLOAT */
  4149. static readonly TEXTURETYPE_FLOAT: number;
  4150. /** HALF_FLOAT */
  4151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4152. /** BYTE */
  4153. static readonly TEXTURETYPE_BYTE: number;
  4154. /** SHORT */
  4155. static readonly TEXTURETYPE_SHORT: number;
  4156. /** UNSIGNED_SHORT */
  4157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4158. /** INT */
  4159. static readonly TEXTURETYPE_INT: number;
  4160. /** UNSIGNED_INT */
  4161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4162. /** UNSIGNED_SHORT_4_4_4_4 */
  4163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4164. /** UNSIGNED_SHORT_5_5_5_1 */
  4165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4166. /** UNSIGNED_SHORT_5_6_5 */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4168. /** UNSIGNED_INT_2_10_10_10_REV */
  4169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4170. /** UNSIGNED_INT_24_8 */
  4171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4172. /** UNSIGNED_INT_10F_11F_11F_REV */
  4173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4174. /** UNSIGNED_INT_5_9_9_9_REV */
  4175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4178. /** nearest is mag = nearest and min = nearest and mip = linear */
  4179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4182. /** Trilinear is mag = linear and min = linear and mip = linear */
  4183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4184. /** nearest is mag = nearest and min = nearest and mip = linear */
  4185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4188. /** Trilinear is mag = linear and min = linear and mip = linear */
  4189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4190. /** mag = nearest and min = nearest and mip = nearest */
  4191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4192. /** mag = nearest and min = linear and mip = nearest */
  4193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4194. /** mag = nearest and min = linear and mip = linear */
  4195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4196. /** mag = nearest and min = linear and mip = none */
  4197. static readonly TEXTURE_NEAREST_LINEAR: number;
  4198. /** mag = nearest and min = nearest and mip = none */
  4199. static readonly TEXTURE_NEAREST_NEAREST: number;
  4200. /** mag = linear and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4202. /** mag = linear and min = nearest and mip = linear */
  4203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4204. /** mag = linear and min = linear and mip = none */
  4205. static readonly TEXTURE_LINEAR_LINEAR: number;
  4206. /** mag = linear and min = nearest and mip = none */
  4207. static readonly TEXTURE_LINEAR_NEAREST: number;
  4208. /** Explicit coordinates mode */
  4209. static readonly TEXTURE_EXPLICIT_MODE: number;
  4210. /** Spherical coordinates mode */
  4211. static readonly TEXTURE_SPHERICAL_MODE: number;
  4212. /** Planar coordinates mode */
  4213. static readonly TEXTURE_PLANAR_MODE: number;
  4214. /** Cubic coordinates mode */
  4215. static readonly TEXTURE_CUBIC_MODE: number;
  4216. /** Projection coordinates mode */
  4217. static readonly TEXTURE_PROJECTION_MODE: number;
  4218. /** Skybox coordinates mode */
  4219. static readonly TEXTURE_SKYBOX_MODE: number;
  4220. /** Inverse Cubic coordinates mode */
  4221. static readonly TEXTURE_INVCUBIC_MODE: number;
  4222. /** Equirectangular coordinates mode */
  4223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4224. /** Equirectangular Fixed coordinates mode */
  4225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4226. /** Equirectangular Fixed Mirrored coordinates mode */
  4227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4229. static readonly SCALEMODE_FLOOR: number;
  4230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4231. static readonly SCALEMODE_NEAREST: number;
  4232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4233. static readonly SCALEMODE_CEILING: number;
  4234. /**
  4235. * The dirty texture flag value
  4236. */
  4237. static readonly MATERIAL_TextureDirtyFlag: number;
  4238. /**
  4239. * The dirty light flag value
  4240. */
  4241. static readonly MATERIAL_LightDirtyFlag: number;
  4242. /**
  4243. * The dirty fresnel flag value
  4244. */
  4245. static readonly MATERIAL_FresnelDirtyFlag: number;
  4246. /**
  4247. * The dirty attribute flag value
  4248. */
  4249. static readonly MATERIAL_AttributesDirtyFlag: number;
  4250. /**
  4251. * The dirty misc flag value
  4252. */
  4253. static readonly MATERIAL_MiscDirtyFlag: number;
  4254. /**
  4255. * The all dirty flag value
  4256. */
  4257. static readonly MATERIAL_AllDirtyFlag: number;
  4258. /**
  4259. * Returns the triangle fill mode
  4260. */
  4261. static readonly MATERIAL_TriangleFillMode: number;
  4262. /**
  4263. * Returns the wireframe mode
  4264. */
  4265. static readonly MATERIAL_WireFrameFillMode: number;
  4266. /**
  4267. * Returns the point fill mode
  4268. */
  4269. static readonly MATERIAL_PointFillMode: number;
  4270. /**
  4271. * Returns the point list draw mode
  4272. */
  4273. static readonly MATERIAL_PointListDrawMode: number;
  4274. /**
  4275. * Returns the line list draw mode
  4276. */
  4277. static readonly MATERIAL_LineListDrawMode: number;
  4278. /**
  4279. * Returns the line loop draw mode
  4280. */
  4281. static readonly MATERIAL_LineLoopDrawMode: number;
  4282. /**
  4283. * Returns the line strip draw mode
  4284. */
  4285. static readonly MATERIAL_LineStripDrawMode: number;
  4286. /**
  4287. * Returns the triangle strip draw mode
  4288. */
  4289. static readonly MATERIAL_TriangleStripDrawMode: number;
  4290. /**
  4291. * Returns the triangle fan draw mode
  4292. */
  4293. static readonly MATERIAL_TriangleFanDrawMode: number;
  4294. /**
  4295. * Stores the clock-wise side orientation
  4296. */
  4297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4298. /**
  4299. * Stores the counter clock-wise side orientation
  4300. */
  4301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4302. /**
  4303. * Nothing
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_NothingTrigger: number;
  4307. /**
  4308. * On pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnPickTrigger: number;
  4312. /**
  4313. * On left pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnLeftPickTrigger: number;
  4317. /**
  4318. * On right pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnRightPickTrigger: number;
  4322. /**
  4323. * On center pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnCenterPickTrigger: number;
  4327. /**
  4328. * On pick down
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnPickDownTrigger: number;
  4332. /**
  4333. * On double pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnDoublePickTrigger: number;
  4337. /**
  4338. * On pick up
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickUpTrigger: number;
  4342. /**
  4343. * On pick out.
  4344. * This trigger will only be raised if you also declared a OnPickDown
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnPickOutTrigger: number;
  4348. /**
  4349. * On long press
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnLongPressTrigger: number;
  4353. /**
  4354. * On pointer over
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOverTrigger: number;
  4358. /**
  4359. * On pointer out
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOutTrigger: number;
  4363. /**
  4364. * On every frame
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnEveryFrameTrigger: number;
  4368. /**
  4369. * On intersection enter
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4373. /**
  4374. * On intersection exit
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionExitTrigger: number;
  4378. /**
  4379. * On key down
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyDownTrigger: number;
  4383. /**
  4384. * On key up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyUpTrigger: number;
  4388. /**
  4389. * Billboard mode will only apply to Y axis
  4390. */
  4391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4392. /**
  4393. * Billboard mode will apply to all axes
  4394. */
  4395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4396. /**
  4397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4398. */
  4399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4400. /**
  4401. * Gets or sets base Assets URL
  4402. */
  4403. static PARTICLES_BaseAssetsUrl: string;
  4404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4405. * Test order :
  4406. * Is the bounding sphere outside the frustum ?
  4407. * If not, are the bounding box vertices outside the frustum ?
  4408. * It not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4411. /** Culling strategy : Bounding Sphere Only.
  4412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4413. * It's also less accurate than the standard because some not visible objects can still be selected.
  4414. * Test : is the bounding sphere outside the frustum ?
  4415. * If not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4418. /** Culling strategy : Optimistic Inclusion.
  4419. * This in an inclusion test first, then the standard exclusion test.
  4420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4421. * 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.
  4422. * Anyway, it's as accurate as the standard strategy.
  4423. * Test :
  4424. * Is the cullable object bounding sphere center in the frustum ?
  4425. * If not, apply the default culling strategy.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4438. /**
  4439. * No logging while loading
  4440. */
  4441. static readonly SCENELOADER_NO_LOGGING: number;
  4442. /**
  4443. * Minimal logging while loading
  4444. */
  4445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4446. /**
  4447. * Summary logging while loading
  4448. */
  4449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4450. /**
  4451. * Detailled logging while loading
  4452. */
  4453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4454. }
  4455. }
  4456. declare module BABYLON {
  4457. /**
  4458. * Class used to store and describe the pipeline context associated with an effect
  4459. */
  4460. export interface IPipelineContext {
  4461. /**
  4462. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4463. */
  4464. isAsync: boolean;
  4465. /**
  4466. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4467. */
  4468. isReady: boolean;
  4469. /** @hidden */
  4470. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface IShaderProcessor {
  4476. attributeProcessor?: (attribute: string) => string;
  4477. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4478. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4479. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4480. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4481. lineProcessor?: (line: string, isFragment: boolean) => string;
  4482. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4483. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4484. }
  4485. }
  4486. declare module BABYLON {
  4487. /** @hidden */
  4488. export interface ProcessingOptions {
  4489. defines: string[];
  4490. indexParameters: any;
  4491. isFragment: boolean;
  4492. shouldUseHighPrecisionShader: boolean;
  4493. supportsUniformBuffers: boolean;
  4494. shadersRepository: string;
  4495. includesShadersStore: {
  4496. [key: string]: string;
  4497. };
  4498. processor?: IShaderProcessor;
  4499. version: string;
  4500. platformName: string;
  4501. lookForClosingBracketForUniformBuffer?: boolean;
  4502. }
  4503. }
  4504. declare module BABYLON {
  4505. /**
  4506. * Helper to manipulate strings
  4507. */
  4508. export class StringTools {
  4509. /**
  4510. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4511. * @param str Source string
  4512. * @param suffix Suffix to search for in the source string
  4513. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4514. */
  4515. static EndsWith(str: string, suffix: string): boolean;
  4516. /**
  4517. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4518. * @param str Source string
  4519. * @param suffix Suffix to search for in the source string
  4520. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4521. */
  4522. static StartsWith(str: string, suffix: string): boolean;
  4523. }
  4524. }
  4525. declare module BABYLON {
  4526. /** @hidden */
  4527. export class ShaderCodeNode {
  4528. line: string;
  4529. children: ShaderCodeNode[];
  4530. additionalDefineKey?: string;
  4531. additionalDefineValue?: string;
  4532. isValid(preprocessors: {
  4533. [key: string]: string;
  4534. }): boolean;
  4535. process(preprocessors: {
  4536. [key: string]: string;
  4537. }, options: ProcessingOptions): string;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. /** @hidden */
  4542. export class ShaderCodeCursor {
  4543. private _lines;
  4544. lineIndex: number;
  4545. readonly currentLine: string;
  4546. readonly canRead: boolean;
  4547. lines: string[];
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4553. process(preprocessors: {
  4554. [key: string]: string;
  4555. }, options: ProcessingOptions): string;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderDefineExpression {
  4561. isTrue(preprocessors: {
  4562. [key: string]: string;
  4563. }): boolean;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /** @hidden */
  4568. export class ShaderCodeTestNode extends ShaderCodeNode {
  4569. testExpression: ShaderDefineExpression;
  4570. isValid(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module BABYLON {
  4576. /** @hidden */
  4577. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4578. define: string;
  4579. not: boolean;
  4580. constructor(define: string, not?: boolean);
  4581. isTrue(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /** @hidden */
  4588. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4589. leftOperand: ShaderDefineExpression;
  4590. rightOperand: ShaderDefineExpression;
  4591. isTrue(preprocessors: {
  4592. [key: string]: string;
  4593. }): boolean;
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /** @hidden */
  4598. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4599. leftOperand: ShaderDefineExpression;
  4600. rightOperand: ShaderDefineExpression;
  4601. isTrue(preprocessors: {
  4602. [key: string]: string;
  4603. }): boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. /** @hidden */
  4608. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4609. define: string;
  4610. operand: string;
  4611. testValue: string;
  4612. constructor(define: string, operand: string, testValue: string);
  4613. isTrue(preprocessors: {
  4614. [key: string]: string;
  4615. }): boolean;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * @ignore
  4621. * Application error to support additional information when loading a file
  4622. */
  4623. export class LoadFileError extends Error {
  4624. /** defines the optional web request */
  4625. request?: WebRequest | undefined;
  4626. private static _setPrototypeOf;
  4627. /**
  4628. * Creates a new LoadFileError
  4629. * @param message defines the message of the error
  4630. * @param request defines the optional web request
  4631. */
  4632. constructor(message: string,
  4633. /** defines the optional web request */
  4634. request?: WebRequest | undefined);
  4635. }
  4636. }
  4637. declare module BABYLON {
  4638. /**
  4639. * Class used to enable access to offline support
  4640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4641. */
  4642. export interface IOfflineProvider {
  4643. /**
  4644. * Gets a boolean indicating if scene must be saved in the database
  4645. */
  4646. enableSceneOffline: boolean;
  4647. /**
  4648. * Gets a boolean indicating if textures must be saved in the database
  4649. */
  4650. enableTexturesOffline: boolean;
  4651. /**
  4652. * Open the offline support and make it available
  4653. * @param successCallback defines the callback to call on success
  4654. * @param errorCallback defines the callback to call on error
  4655. */
  4656. open(successCallback: () => void, errorCallback: () => void): void;
  4657. /**
  4658. * Loads an image from the offline support
  4659. * @param url defines the url to load from
  4660. * @param image defines the target DOM image
  4661. */
  4662. loadImage(url: string, image: HTMLImageElement): void;
  4663. /**
  4664. * Loads a file from offline support
  4665. * @param url defines the URL to load from
  4666. * @param sceneLoaded defines a callback to call on success
  4667. * @param progressCallBack defines a callback to call when progress changed
  4668. * @param errorCallback defines a callback to call on error
  4669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4670. */
  4671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4672. }
  4673. }
  4674. declare module BABYLON {
  4675. /**
  4676. * Class used to help managing file picking and drag'n'drop
  4677. * File Storage
  4678. */
  4679. export class FilesInputStore {
  4680. /**
  4681. * List of files ready to be loaded
  4682. */
  4683. static FilesToLoad: {
  4684. [key: string]: File;
  4685. };
  4686. }
  4687. }
  4688. declare module BABYLON {
  4689. /**
  4690. * Class used to define a retry strategy when error happens while loading assets
  4691. */
  4692. export class RetryStrategy {
  4693. /**
  4694. * Function used to defines an exponential back off strategy
  4695. * @param maxRetries defines the maximum number of retries (3 by default)
  4696. * @param baseInterval defines the interval between retries
  4697. * @returns the strategy function to use
  4698. */
  4699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4700. }
  4701. }
  4702. declare module BABYLON {
  4703. /**
  4704. * @hidden
  4705. */
  4706. export class FileTools {
  4707. /**
  4708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4709. */
  4710. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4711. /**
  4712. * Gets or sets the base URL to use to load assets
  4713. */
  4714. static BaseUrl: string;
  4715. /**
  4716. * Default behaviour for cors in the application.
  4717. * It can be a string if the expected behavior is identical in the entire app.
  4718. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4719. */
  4720. static CorsBehavior: string | ((url: string | string[]) => string);
  4721. /**
  4722. * Gets or sets a function used to pre-process url before using them to load assets
  4723. */
  4724. static PreprocessUrl: (url: string) => string;
  4725. /**
  4726. * Removes unwanted characters from an url
  4727. * @param url defines the url to clean
  4728. * @returns the cleaned url
  4729. */
  4730. private static _CleanUrl;
  4731. /**
  4732. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4733. * @param url define the url we are trying
  4734. * @param element define the dom element where to configure the cors policy
  4735. */
  4736. static SetCorsBehavior(url: string | string[], element: {
  4737. crossOrigin: string | null;
  4738. }): void;
  4739. /**
  4740. * Loads an image as an HTMLImageElement.
  4741. * @param input url string, ArrayBuffer, or Blob to load
  4742. * @param onLoad callback called when the image successfully loads
  4743. * @param onError callback called when the image fails to load
  4744. * @param offlineProvider offline provider for caching
  4745. * @returns the HTMLImageElement of the loaded image
  4746. */
  4747. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4748. /**
  4749. * Loads a file
  4750. * @param fileToLoad defines the file to load
  4751. * @param callback defines the callback to call when data is loaded
  4752. * @param progressCallBack defines the callback to call during loading process
  4753. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4754. * @returns a file request object
  4755. */
  4756. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4757. /**
  4758. * Loads a file
  4759. * @param url url string, ArrayBuffer, or Blob to load
  4760. * @param onSuccess callback called when the file successfully loads
  4761. * @param onProgress callback called while file is loading (if the server supports this mode)
  4762. * @param offlineProvider defines the offline provider for caching
  4763. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4764. * @param onError callback called when the file fails to load
  4765. * @returns a file request object
  4766. */
  4767. 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;
  4768. /**
  4769. * Checks if the loaded document was accessed via `file:`-Protocol.
  4770. * @returns boolean
  4771. */
  4772. static IsFileURL(): boolean;
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /** @hidden */
  4777. export class ShaderProcessor {
  4778. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4779. private static _ProcessPrecision;
  4780. private static _ExtractOperation;
  4781. private static _BuildSubExpression;
  4782. private static _BuildExpression;
  4783. private static _MoveCursorWithinIf;
  4784. private static _MoveCursor;
  4785. private static _EvaluatePreProcessors;
  4786. private static _PreparePreProcessors;
  4787. private static _ProcessShaderConversion;
  4788. private static _ProcessIncludes;
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Class used to hold a RBG color
  4794. */
  4795. export class Color3 {
  4796. /**
  4797. * Defines the red component (between 0 and 1, default is 0)
  4798. */
  4799. r: number;
  4800. /**
  4801. * Defines the green component (between 0 and 1, default is 0)
  4802. */
  4803. g: number;
  4804. /**
  4805. * Defines the blue component (between 0 and 1, default is 0)
  4806. */
  4807. b: number;
  4808. /**
  4809. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4810. * @param r defines the red component (between 0 and 1, default is 0)
  4811. * @param g defines the green component (between 0 and 1, default is 0)
  4812. * @param b defines the blue component (between 0 and 1, default is 0)
  4813. */
  4814. constructor(
  4815. /**
  4816. * Defines the red component (between 0 and 1, default is 0)
  4817. */
  4818. r?: number,
  4819. /**
  4820. * Defines the green component (between 0 and 1, default is 0)
  4821. */
  4822. g?: number,
  4823. /**
  4824. * Defines the blue component (between 0 and 1, default is 0)
  4825. */
  4826. b?: number);
  4827. /**
  4828. * Creates a string with the Color3 current values
  4829. * @returns the string representation of the Color3 object
  4830. */
  4831. toString(): string;
  4832. /**
  4833. * Returns the string "Color3"
  4834. * @returns "Color3"
  4835. */
  4836. getClassName(): string;
  4837. /**
  4838. * Compute the Color3 hash code
  4839. * @returns an unique number that can be used to hash Color3 objects
  4840. */
  4841. getHashCode(): number;
  4842. /**
  4843. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4844. * @param array defines the array where to store the r,g,b components
  4845. * @param index defines an optional index in the target array to define where to start storing values
  4846. * @returns the current Color3 object
  4847. */
  4848. toArray(array: FloatArray, index?: number): Color3;
  4849. /**
  4850. * Returns a new Color4 object from the current Color3 and the given alpha
  4851. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4852. * @returns a new Color4 object
  4853. */
  4854. toColor4(alpha?: number): Color4;
  4855. /**
  4856. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4857. * @returns the new array
  4858. */
  4859. asArray(): number[];
  4860. /**
  4861. * Returns the luminance value
  4862. * @returns a float value
  4863. */
  4864. toLuminance(): number;
  4865. /**
  4866. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4867. * @param otherColor defines the second operand
  4868. * @returns the new Color3 object
  4869. */
  4870. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4871. /**
  4872. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4873. * @param otherColor defines the second operand
  4874. * @param result defines the Color3 object where to store the result
  4875. * @returns the current Color3
  4876. */
  4877. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4878. /**
  4879. * Determines equality between Color3 objects
  4880. * @param otherColor defines the second operand
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equals(otherColor: DeepImmutable<Color3>): boolean;
  4884. /**
  4885. * Determines equality between the current Color3 object and a set of r,b,g values
  4886. * @param r defines the red component to check
  4887. * @param g defines the green component to check
  4888. * @param b defines the blue component to check
  4889. * @returns true if the rgb values are equal to the given ones
  4890. */
  4891. equalsFloats(r: number, g: number, b: number): boolean;
  4892. /**
  4893. * Multiplies in place each rgb value by scale
  4894. * @param scale defines the scaling factor
  4895. * @returns the updated Color3
  4896. */
  4897. scale(scale: number): Color3;
  4898. /**
  4899. * Multiplies the rgb values by scale and stores the result into "result"
  4900. * @param scale defines the scaling factor
  4901. * @param result defines the Color3 object where to store the result
  4902. * @returns the unmodified current Color3
  4903. */
  4904. scaleToRef(scale: number, result: Color3): Color3;
  4905. /**
  4906. * Scale the current Color3 values by a factor and add the result to a given Color3
  4907. * @param scale defines the scale factor
  4908. * @param result defines color to store the result into
  4909. * @returns the unmodified current Color3
  4910. */
  4911. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4912. /**
  4913. * Clamps the rgb values by the min and max values and stores the result into "result"
  4914. * @param min defines minimum clamping value (default is 0)
  4915. * @param max defines maximum clamping value (default is 1)
  4916. * @param result defines color to store the result into
  4917. * @returns the original Color3
  4918. */
  4919. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4920. /**
  4921. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. add(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4935. * @param otherColor defines the second operand
  4936. * @returns the new Color3
  4937. */
  4938. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4939. /**
  4940. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4941. * @param otherColor defines the second operand
  4942. * @param result defines Color3 object to store the result into
  4943. * @returns the unmodified current Color3
  4944. */
  4945. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4946. /**
  4947. * Copy the current object
  4948. * @returns a new Color3 copied the current one
  4949. */
  4950. clone(): Color3;
  4951. /**
  4952. * Copies the rgb values from the source in the current Color3
  4953. * @param source defines the source Color3 object
  4954. * @returns the updated Color3 object
  4955. */
  4956. copyFrom(source: DeepImmutable<Color3>): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. copyFromFloats(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Updates the Color3 rgb values from the given floats
  4967. * @param r defines the red component to read from
  4968. * @param g defines the green component to read from
  4969. * @param b defines the blue component to read from
  4970. * @returns the current Color3 object
  4971. */
  4972. set(r: number, g: number, b: number): Color3;
  4973. /**
  4974. * Compute the Color3 hexadecimal code as a string
  4975. * @returns a string containing the hexadecimal representation of the Color3 object
  4976. */
  4977. toHexString(): string;
  4978. /**
  4979. * Computes a new Color3 converted from the current one to linear space
  4980. * @returns a new Color3 object
  4981. */
  4982. toLinearSpace(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @returns a new color3 representing the HSV values
  4986. */
  4987. toHSV(): Color3;
  4988. /**
  4989. * Converts current color in rgb space to HSV values
  4990. * @param result defines the Color3 where to store the HSV values
  4991. */
  4992. toHSVToRef(result: Color3): void;
  4993. /**
  4994. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4995. * @param convertedColor defines the Color3 object where to store the linear space version
  4996. * @returns the unmodified Color3
  4997. */
  4998. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4999. /**
  5000. * Computes a new Color3 converted from the current one to gamma space
  5001. * @returns a new Color3 object
  5002. */
  5003. toGammaSpace(): Color3;
  5004. /**
  5005. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5006. * @param convertedColor defines the Color3 object where to store the gamma space version
  5007. * @returns the unmodified Color3
  5008. */
  5009. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5010. private static _BlackReadOnly;
  5011. /**
  5012. * Convert Hue, saturation and value to a Color3 (RGB)
  5013. * @param hue defines the hue
  5014. * @param saturation defines the saturation
  5015. * @param value defines the value
  5016. * @param result defines the Color3 where to store the RGB values
  5017. */
  5018. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5019. /**
  5020. * Creates a new Color3 from the string containing valid hexadecimal values
  5021. * @param hex defines a string containing valid hexadecimal values
  5022. * @returns a new Color3 object
  5023. */
  5024. static FromHexString(hex: string): Color3;
  5025. /**
  5026. * Creates a new Color3 from the starting index of the given array
  5027. * @param array defines the source array
  5028. * @param offset defines an offset in the source array
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5032. /**
  5033. * Creates a new Color3 from integer values (< 256)
  5034. * @param r defines the red component to read from (value between 0 and 255)
  5035. * @param g defines the green component to read from (value between 0 and 255)
  5036. * @param b defines the blue component to read from (value between 0 and 255)
  5037. * @returns a new Color3 object
  5038. */
  5039. static FromInts(r: number, g: number, b: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param start defines the start Color3 value
  5043. * @param end defines the end Color3 value
  5044. * @param amount defines the gradient value between start and end
  5045. * @returns a new Color3 object
  5046. */
  5047. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5048. /**
  5049. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5050. * @param left defines the start value
  5051. * @param right defines the end value
  5052. * @param amount defines the gradient factor
  5053. * @param result defines the Color3 object where to store the result
  5054. */
  5055. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5056. /**
  5057. * Returns a Color3 value containing a red color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Red(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a green color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Green(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a blue color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Blue(): Color3;
  5071. /**
  5072. * Returns a Color3 value containing a black color
  5073. * @returns a new Color3 object
  5074. */
  5075. static Black(): Color3;
  5076. /**
  5077. * Gets a Color3 value containing a black color that must not be updated
  5078. */
  5079. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5080. /**
  5081. * Returns a Color3 value containing a white color
  5082. * @returns a new Color3 object
  5083. */
  5084. static White(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a purple color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Purple(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a magenta color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Magenta(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a yellow color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Yellow(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a gray color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Gray(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a teal color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Teal(): Color3;
  5110. /**
  5111. * Returns a Color3 value containing a random color
  5112. * @returns a new Color3 object
  5113. */
  5114. static Random(): Color3;
  5115. }
  5116. /**
  5117. * Class used to hold a RBGA color
  5118. */
  5119. export class Color4 {
  5120. /**
  5121. * Defines the red component (between 0 and 1, default is 0)
  5122. */
  5123. r: number;
  5124. /**
  5125. * Defines the green component (between 0 and 1, default is 0)
  5126. */
  5127. g: number;
  5128. /**
  5129. * Defines the blue component (between 0 and 1, default is 0)
  5130. */
  5131. b: number;
  5132. /**
  5133. * Defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. a: number;
  5136. /**
  5137. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5138. * @param r defines the red component (between 0 and 1, default is 0)
  5139. * @param g defines the green component (between 0 and 1, default is 0)
  5140. * @param b defines the blue component (between 0 and 1, default is 0)
  5141. * @param a defines the alpha component (between 0 and 1, default is 1)
  5142. */
  5143. constructor(
  5144. /**
  5145. * Defines the red component (between 0 and 1, default is 0)
  5146. */
  5147. r?: number,
  5148. /**
  5149. * Defines the green component (between 0 and 1, default is 0)
  5150. */
  5151. g?: number,
  5152. /**
  5153. * Defines the blue component (between 0 and 1, default is 0)
  5154. */
  5155. b?: number,
  5156. /**
  5157. * Defines the alpha component (between 0 and 1, default is 1)
  5158. */
  5159. a?: number);
  5160. /**
  5161. * Adds in place the given Color4 values to the current Color4 object
  5162. * @param right defines the second operand
  5163. * @returns the current updated Color4 object
  5164. */
  5165. addInPlace(right: DeepImmutable<Color4>): Color4;
  5166. /**
  5167. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Stores from the starting index in the given array the Color4 successive values
  5173. * @param array defines the array where to store the r,g,b components
  5174. * @param index defines an optional index in the target array to define where to start storing values
  5175. * @returns the current Color4 object
  5176. */
  5177. toArray(array: number[], index?: number): Color4;
  5178. /**
  5179. * Determines equality between Color4 objects
  5180. * @param otherColor defines the second operand
  5181. * @returns true if the rgba values are equal to the given ones
  5182. */
  5183. equals(otherColor: DeepImmutable<Color4>): boolean;
  5184. /**
  5185. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5186. * @param right defines the second operand
  5187. * @returns a new Color4 object
  5188. */
  5189. add(right: DeepImmutable<Color4>): Color4;
  5190. /**
  5191. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5192. * @param right defines the second operand
  5193. * @returns a new Color4 object
  5194. */
  5195. subtract(right: DeepImmutable<Color4>): Color4;
  5196. /**
  5197. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5198. * @param right defines the second operand
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current Color4 object
  5201. */
  5202. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5203. /**
  5204. * Creates a new Color4 with the current Color4 values multiplied by scale
  5205. * @param scale defines the scaling factor to apply
  5206. * @returns a new Color4 object
  5207. */
  5208. scale(scale: number): Color4;
  5209. /**
  5210. * Multiplies the current Color4 values by scale and stores the result in "result"
  5211. * @param scale defines the scaling factor to apply
  5212. * @param result defines the Color4 object where to store the result
  5213. * @returns the current unmodified Color4
  5214. */
  5215. scaleToRef(scale: number, result: Color4): Color4;
  5216. /**
  5217. * Scale the current Color4 values by a factor and add the result to a given Color4
  5218. * @param scale defines the scale factor
  5219. * @param result defines the Color4 object where to store the result
  5220. * @returns the unmodified current Color4
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into.
  5228. * @returns the cuurent Color4
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5231. /**
  5232. * Multipy an Color4 value by another and return a new Color4 object
  5233. * @param color defines the Color4 value to multiply by
  5234. * @returns a new Color4 object
  5235. */
  5236. multiply(color: Color4): Color4;
  5237. /**
  5238. * Multipy a Color4 value by another and push the result in a reference value
  5239. * @param color defines the Color4 value to multiply by
  5240. * @param result defines the Color4 to fill the result in
  5241. * @returns the result Color4
  5242. */
  5243. multiplyToRef(color: Color4, result: Color4): Color4;
  5244. /**
  5245. * Creates a string with the Color4 current values
  5246. * @returns the string representation of the Color4 object
  5247. */
  5248. toString(): string;
  5249. /**
  5250. * Returns the string "Color4"
  5251. * @returns "Color4"
  5252. */
  5253. getClassName(): string;
  5254. /**
  5255. * Compute the Color4 hash code
  5256. * @returns an unique number that can be used to hash Color4 objects
  5257. */
  5258. getHashCode(): number;
  5259. /**
  5260. * Creates a new Color4 copied from the current one
  5261. * @returns a new Color4 object
  5262. */
  5263. clone(): Color4;
  5264. /**
  5265. * Copies the given Color4 values into the current one
  5266. * @param source defines the source Color4 object
  5267. * @returns the current updated Color4 object
  5268. */
  5269. copyFrom(source: Color4): Color4;
  5270. /**
  5271. * Copies the given float values into the current one
  5272. * @param r defines the red component to read from
  5273. * @param g defines the green component to read from
  5274. * @param b defines the blue component to read from
  5275. * @param a defines the alpha component to read from
  5276. * @returns the current updated Color4 object
  5277. */
  5278. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5279. /**
  5280. * Copies the given float values into the current one
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @param a defines the alpha component to read from
  5285. * @returns the current updated Color4 object
  5286. */
  5287. set(r: number, g: number, b: number, a: number): Color4;
  5288. /**
  5289. * Compute the Color4 hexadecimal code as a string
  5290. * @returns a string containing the hexadecimal representation of the Color4 object
  5291. */
  5292. toHexString(): string;
  5293. /**
  5294. * Computes a new Color4 converted from the current one to linear space
  5295. * @returns a new Color4 object
  5296. */
  5297. toLinearSpace(): Color4;
  5298. /**
  5299. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5300. * @param convertedColor defines the Color4 object where to store the linear space version
  5301. * @returns the unmodified Color4
  5302. */
  5303. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5304. /**
  5305. * Computes a new Color4 converted from the current one to gamma space
  5306. * @returns a new Color4 object
  5307. */
  5308. toGammaSpace(): Color4;
  5309. /**
  5310. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5311. * @param convertedColor defines the Color4 object where to store the gamma space version
  5312. * @returns the unmodified Color4
  5313. */
  5314. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5315. /**
  5316. * Creates a new Color4 from the string containing valid hexadecimal values
  5317. * @param hex defines a string containing valid hexadecimal values
  5318. * @returns a new Color4 object
  5319. */
  5320. static FromHexString(hex: string): Color4;
  5321. /**
  5322. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @returns a new Color4 object
  5327. */
  5328. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5329. /**
  5330. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5331. * @param left defines the start value
  5332. * @param right defines the end value
  5333. * @param amount defines the gradient factor
  5334. * @param result defines the Color4 object where to store data
  5335. */
  5336. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5337. /**
  5338. * Creates a new Color4 from a Color3 and an alpha value
  5339. * @param color3 defines the source Color3 to read from
  5340. * @param alpha defines the alpha component (1.0 by default)
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5344. /**
  5345. * Creates a new Color4 from the starting index element of the given array
  5346. * @param array defines the source array to read from
  5347. * @param offset defines the offset in the source array
  5348. * @returns a new Color4 object
  5349. */
  5350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5351. /**
  5352. * Creates a new Color3 from integer values (< 256)
  5353. * @param r defines the red component to read from (value between 0 and 255)
  5354. * @param g defines the green component to read from (value between 0 and 255)
  5355. * @param b defines the blue component to read from (value between 0 and 255)
  5356. * @param a defines the alpha component to read from (value between 0 and 255)
  5357. * @returns a new Color3 object
  5358. */
  5359. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5360. /**
  5361. * Check the content of a given array and convert it to an array containing RGBA data
  5362. * If the original array was already containing count * 4 values then it is returned directly
  5363. * @param colors defines the array to check
  5364. * @param count defines the number of RGBA data to expect
  5365. * @returns an array containing count * 4 values (RGBA)
  5366. */
  5367. static CheckColors4(colors: number[], count: number): number[];
  5368. }
  5369. /**
  5370. * @hidden
  5371. */
  5372. export class TmpColors {
  5373. static Color3: Color3[];
  5374. static Color4: Color4[];
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. /**
  5379. * Class representing spherical harmonics coefficients to the 3rd degree
  5380. */
  5381. export class SphericalHarmonics {
  5382. /**
  5383. * Defines whether or not the harmonics have been prescaled for rendering.
  5384. */
  5385. preScaled: boolean;
  5386. /**
  5387. * The l0,0 coefficients of the spherical harmonics
  5388. */
  5389. l00: Vector3;
  5390. /**
  5391. * The l1,-1 coefficients of the spherical harmonics
  5392. */
  5393. l1_1: Vector3;
  5394. /**
  5395. * The l1,0 coefficients of the spherical harmonics
  5396. */
  5397. l10: Vector3;
  5398. /**
  5399. * The l1,1 coefficients of the spherical harmonics
  5400. */
  5401. l11: Vector3;
  5402. /**
  5403. * The l2,-2 coefficients of the spherical harmonics
  5404. */
  5405. l2_2: Vector3;
  5406. /**
  5407. * The l2,-1 coefficients of the spherical harmonics
  5408. */
  5409. l2_1: Vector3;
  5410. /**
  5411. * The l2,0 coefficients of the spherical harmonics
  5412. */
  5413. l20: Vector3;
  5414. /**
  5415. * The l2,1 coefficients of the spherical harmonics
  5416. */
  5417. l21: Vector3;
  5418. /**
  5419. * The l2,2 coefficients of the spherical harmonics
  5420. */
  5421. l22: Vector3;
  5422. /**
  5423. * Adds a light to the spherical harmonics
  5424. * @param direction the direction of the light
  5425. * @param color the color of the light
  5426. * @param deltaSolidAngle the delta solid angle of the light
  5427. */
  5428. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5429. /**
  5430. * Scales the spherical harmonics by the given amount
  5431. * @param scale the amount to scale
  5432. */
  5433. scaleInPlace(scale: number): void;
  5434. /**
  5435. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5436. *
  5437. * ```
  5438. * E_lm = A_l * L_lm
  5439. * ```
  5440. *
  5441. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5442. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5443. * the scaling factors are given in equation 9.
  5444. */
  5445. convertIncidentRadianceToIrradiance(): void;
  5446. /**
  5447. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5448. *
  5449. * ```
  5450. * L = (1/pi) * E * rho
  5451. * ```
  5452. *
  5453. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5454. */
  5455. convertIrradianceToLambertianRadiance(): void;
  5456. /**
  5457. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5458. * required operations at run time.
  5459. *
  5460. * This is simply done by scaling back the SH with Ylm constants parameter.
  5461. * The trigonometric part being applied by the shader at run time.
  5462. */
  5463. preScaleForRendering(): void;
  5464. /**
  5465. * Constructs a spherical harmonics from an array.
  5466. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5467. * @returns the spherical harmonics
  5468. */
  5469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5470. /**
  5471. * Gets the spherical harmonics from polynomial
  5472. * @param polynomial the spherical polynomial
  5473. * @returns the spherical harmonics
  5474. */
  5475. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5476. }
  5477. /**
  5478. * Class representing spherical polynomial coefficients to the 3rd degree
  5479. */
  5480. export class SphericalPolynomial {
  5481. private _harmonics;
  5482. /**
  5483. * The spherical harmonics used to create the polynomials.
  5484. */
  5485. readonly preScaledHarmonics: SphericalHarmonics;
  5486. /**
  5487. * The x coefficients of the spherical polynomial
  5488. */
  5489. x: Vector3;
  5490. /**
  5491. * The y coefficients of the spherical polynomial
  5492. */
  5493. y: Vector3;
  5494. /**
  5495. * The z coefficients of the spherical polynomial
  5496. */
  5497. z: Vector3;
  5498. /**
  5499. * The xx coefficients of the spherical polynomial
  5500. */
  5501. xx: Vector3;
  5502. /**
  5503. * The yy coefficients of the spherical polynomial
  5504. */
  5505. yy: Vector3;
  5506. /**
  5507. * The zz coefficients of the spherical polynomial
  5508. */
  5509. zz: Vector3;
  5510. /**
  5511. * The xy coefficients of the spherical polynomial
  5512. */
  5513. xy: Vector3;
  5514. /**
  5515. * The yz coefficients of the spherical polynomial
  5516. */
  5517. yz: Vector3;
  5518. /**
  5519. * The zx coefficients of the spherical polynomial
  5520. */
  5521. zx: Vector3;
  5522. /**
  5523. * Adds an ambient color to the spherical polynomial
  5524. * @param color the color to add
  5525. */
  5526. addAmbient(color: Color3): void;
  5527. /**
  5528. * Scales the spherical polynomial by the given amount
  5529. * @param scale the amount to scale
  5530. */
  5531. scaleInPlace(scale: number): void;
  5532. /**
  5533. * Gets the spherical polynomial from harmonics
  5534. * @param harmonics the spherical harmonics
  5535. * @returns the spherical polynomial
  5536. */
  5537. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5538. /**
  5539. * Constructs a spherical polynomial from an array.
  5540. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5541. * @returns the spherical polynomial
  5542. */
  5543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5544. }
  5545. }
  5546. declare module BABYLON {
  5547. /**
  5548. * Define options used to create a render target texture
  5549. */
  5550. export class RenderTargetCreationOptions {
  5551. /**
  5552. * Specifies is mipmaps must be generated
  5553. */
  5554. generateMipMaps?: boolean;
  5555. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5556. generateDepthBuffer?: boolean;
  5557. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5558. generateStencilBuffer?: boolean;
  5559. /** Defines texture type (int by default) */
  5560. type?: number;
  5561. /** Defines sampling mode (trilinear by default) */
  5562. samplingMode?: number;
  5563. /** Defines format (RGBA by default) */
  5564. format?: number;
  5565. }
  5566. }
  5567. declare module BABYLON {
  5568. /**
  5569. * @hidden
  5570. **/
  5571. export class _AlphaState {
  5572. private _isAlphaBlendDirty;
  5573. private _isBlendFunctionParametersDirty;
  5574. private _isBlendEquationParametersDirty;
  5575. private _isBlendConstantsDirty;
  5576. private _alphaBlend;
  5577. private _blendFunctionParameters;
  5578. private _blendEquationParameters;
  5579. private _blendConstants;
  5580. /**
  5581. * Initializes the state.
  5582. */
  5583. constructor();
  5584. readonly isDirty: boolean;
  5585. alphaBlend: boolean;
  5586. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5587. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5588. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5589. reset(): void;
  5590. apply(gl: WebGLRenderingContext): void;
  5591. }
  5592. }
  5593. declare module BABYLON {
  5594. /**
  5595. * @hidden
  5596. **/
  5597. export class _DepthCullingState {
  5598. private _isDepthTestDirty;
  5599. private _isDepthMaskDirty;
  5600. private _isDepthFuncDirty;
  5601. private _isCullFaceDirty;
  5602. private _isCullDirty;
  5603. private _isZOffsetDirty;
  5604. private _isFrontFaceDirty;
  5605. private _depthTest;
  5606. private _depthMask;
  5607. private _depthFunc;
  5608. private _cull;
  5609. private _cullFace;
  5610. private _zOffset;
  5611. private _frontFace;
  5612. /**
  5613. * Initializes the state.
  5614. */
  5615. constructor();
  5616. readonly isDirty: boolean;
  5617. zOffset: number;
  5618. cullFace: Nullable<number>;
  5619. cull: Nullable<boolean>;
  5620. depthFunc: Nullable<number>;
  5621. depthMask: boolean;
  5622. depthTest: boolean;
  5623. frontFace: Nullable<number>;
  5624. reset(): void;
  5625. apply(gl: WebGLRenderingContext): void;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * @hidden
  5631. **/
  5632. export class _StencilState {
  5633. /** 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 */
  5634. static readonly ALWAYS: number;
  5635. /** Passed to stencilOperation to specify that stencil value must be kept */
  5636. static readonly KEEP: number;
  5637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5638. static readonly REPLACE: number;
  5639. private _isStencilTestDirty;
  5640. private _isStencilMaskDirty;
  5641. private _isStencilFuncDirty;
  5642. private _isStencilOpDirty;
  5643. private _stencilTest;
  5644. private _stencilMask;
  5645. private _stencilFunc;
  5646. private _stencilFuncRef;
  5647. private _stencilFuncMask;
  5648. private _stencilOpStencilFail;
  5649. private _stencilOpDepthFail;
  5650. private _stencilOpStencilDepthPass;
  5651. readonly isDirty: boolean;
  5652. stencilFunc: number;
  5653. stencilFuncRef: number;
  5654. stencilFuncMask: number;
  5655. stencilOpStencilFail: number;
  5656. stencilOpDepthFail: number;
  5657. stencilOpStencilDepthPass: number;
  5658. stencilMask: number;
  5659. stencilTest: boolean;
  5660. constructor();
  5661. reset(): void;
  5662. apply(gl: WebGLRenderingContext): void;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * @hidden
  5668. **/
  5669. export class _TimeToken {
  5670. _startTimeQuery: Nullable<WebGLQuery>;
  5671. _endTimeQuery: Nullable<WebGLQuery>;
  5672. _timeElapsedQuery: Nullable<WebGLQuery>;
  5673. _timeElapsedQueryEnded: boolean;
  5674. }
  5675. }
  5676. declare module BABYLON {
  5677. /**
  5678. * Class used to evalaute queries containing `and` and `or` operators
  5679. */
  5680. export class AndOrNotEvaluator {
  5681. /**
  5682. * Evaluate a query
  5683. * @param query defines the query to evaluate
  5684. * @param evaluateCallback defines the callback used to filter result
  5685. * @returns true if the query matches
  5686. */
  5687. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5688. private static _HandleParenthesisContent;
  5689. private static _SimplifyNegation;
  5690. }
  5691. }
  5692. declare module BABYLON {
  5693. /**
  5694. * Class used to store custom tags
  5695. */
  5696. export class Tags {
  5697. /**
  5698. * Adds support for tags on the given object
  5699. * @param obj defines the object to use
  5700. */
  5701. static EnableFor(obj: any): void;
  5702. /**
  5703. * Removes tags support
  5704. * @param obj defines the object to use
  5705. */
  5706. static DisableFor(obj: any): void;
  5707. /**
  5708. * Gets a boolean indicating if the given object has tags
  5709. * @param obj defines the object to use
  5710. * @returns a boolean
  5711. */
  5712. static HasTags(obj: any): boolean;
  5713. /**
  5714. * Gets the tags available on a given object
  5715. * @param obj defines the object to use
  5716. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5717. * @returns the tags
  5718. */
  5719. static GetTags(obj: any, asString?: boolean): any;
  5720. /**
  5721. * Adds tags to an object
  5722. * @param obj defines the object to use
  5723. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5724. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5725. */
  5726. static AddTagsTo(obj: any, tagsString: string): void;
  5727. /**
  5728. * @hidden
  5729. */
  5730. static _AddTagTo(obj: any, tag: string): void;
  5731. /**
  5732. * Removes specific tags from a specific object
  5733. * @param obj defines the object to use
  5734. * @param tagsString defines the tags to remove
  5735. */
  5736. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5737. /**
  5738. * @hidden
  5739. */
  5740. static _RemoveTagFrom(obj: any, tag: string): void;
  5741. /**
  5742. * Defines if tags hosted on an object match a given query
  5743. * @param obj defines the object to use
  5744. * @param tagsQuery defines the tag query
  5745. * @returns a boolean
  5746. */
  5747. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5748. }
  5749. }
  5750. declare module BABYLON {
  5751. /**
  5752. * Defines potential orientation for back face culling
  5753. */
  5754. export enum Orientation {
  5755. /**
  5756. * Clockwise
  5757. */
  5758. CW = 0,
  5759. /** Counter clockwise */
  5760. CCW = 1
  5761. }
  5762. /** Class used to represent a Bezier curve */
  5763. export class BezierCurve {
  5764. /**
  5765. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5766. * @param t defines the time
  5767. * @param x1 defines the left coordinate on X axis
  5768. * @param y1 defines the left coordinate on Y axis
  5769. * @param x2 defines the right coordinate on X axis
  5770. * @param y2 defines the right coordinate on Y axis
  5771. * @returns the interpolated value
  5772. */
  5773. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5774. }
  5775. /**
  5776. * Defines angle representation
  5777. */
  5778. export class Angle {
  5779. private _radians;
  5780. /**
  5781. * Creates an Angle object of "radians" radians (float).
  5782. * @param radians the angle in radians
  5783. */
  5784. constructor(radians: number);
  5785. /**
  5786. * Get value in degrees
  5787. * @returns the Angle value in degrees (float)
  5788. */
  5789. degrees(): number;
  5790. /**
  5791. * Get value in radians
  5792. * @returns the Angle value in radians (float)
  5793. */
  5794. radians(): number;
  5795. /**
  5796. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5797. * @param a defines first vector
  5798. * @param b defines second vector
  5799. * @returns a new Angle
  5800. */
  5801. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5802. /**
  5803. * Gets a new Angle object from the given float in radians
  5804. * @param radians defines the angle value in radians
  5805. * @returns a new Angle
  5806. */
  5807. static FromRadians(radians: number): Angle;
  5808. /**
  5809. * Gets a new Angle object from the given float in degrees
  5810. * @param degrees defines the angle value in degrees
  5811. * @returns a new Angle
  5812. */
  5813. static FromDegrees(degrees: number): Angle;
  5814. }
  5815. /**
  5816. * This represents an arc in a 2d space.
  5817. */
  5818. export class Arc2 {
  5819. /** Defines the start point of the arc */
  5820. startPoint: Vector2;
  5821. /** Defines the mid point of the arc */
  5822. midPoint: Vector2;
  5823. /** Defines the end point of the arc */
  5824. endPoint: Vector2;
  5825. /**
  5826. * Defines the center point of the arc.
  5827. */
  5828. centerPoint: Vector2;
  5829. /**
  5830. * Defines the radius of the arc.
  5831. */
  5832. radius: number;
  5833. /**
  5834. * Defines the angle of the arc (from mid point to end point).
  5835. */
  5836. angle: Angle;
  5837. /**
  5838. * Defines the start angle of the arc (from start point to middle point).
  5839. */
  5840. startAngle: Angle;
  5841. /**
  5842. * Defines the orientation of the arc (clock wise/counter clock wise).
  5843. */
  5844. orientation: Orientation;
  5845. /**
  5846. * Creates an Arc object from the three given points : start, middle and end.
  5847. * @param startPoint Defines the start point of the arc
  5848. * @param midPoint Defines the midlle point of the arc
  5849. * @param endPoint Defines the end point of the arc
  5850. */
  5851. constructor(
  5852. /** Defines the start point of the arc */
  5853. startPoint: Vector2,
  5854. /** Defines the mid point of the arc */
  5855. midPoint: Vector2,
  5856. /** Defines the end point of the arc */
  5857. endPoint: Vector2);
  5858. }
  5859. /**
  5860. * Represents a 2D path made up of multiple 2D points
  5861. */
  5862. export class Path2 {
  5863. private _points;
  5864. private _length;
  5865. /**
  5866. * If the path start and end point are the same
  5867. */
  5868. closed: boolean;
  5869. /**
  5870. * Creates a Path2 object from the starting 2D coordinates x and y.
  5871. * @param x the starting points x value
  5872. * @param y the starting points y value
  5873. */
  5874. constructor(x: number, y: number);
  5875. /**
  5876. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5877. * @param x the added points x value
  5878. * @param y the added points y value
  5879. * @returns the updated Path2.
  5880. */
  5881. addLineTo(x: number, y: number): Path2;
  5882. /**
  5883. * 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.
  5884. * @param midX middle point x value
  5885. * @param midY middle point y value
  5886. * @param endX end point x value
  5887. * @param endY end point y value
  5888. * @param numberOfSegments (default: 36)
  5889. * @returns the updated Path2.
  5890. */
  5891. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5892. /**
  5893. * Closes the Path2.
  5894. * @returns the Path2.
  5895. */
  5896. close(): Path2;
  5897. /**
  5898. * Gets the sum of the distance between each sequential point in the path
  5899. * @returns the Path2 total length (float).
  5900. */
  5901. length(): number;
  5902. /**
  5903. * Gets the points which construct the path
  5904. * @returns the Path2 internal array of points.
  5905. */
  5906. getPoints(): Vector2[];
  5907. /**
  5908. * Retreives the point at the distance aways from the starting point
  5909. * @param normalizedLengthPosition the length along the path to retreive the point from
  5910. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5911. */
  5912. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5913. /**
  5914. * Creates a new path starting from an x and y position
  5915. * @param x starting x value
  5916. * @param y starting y value
  5917. * @returns a new Path2 starting at the coordinates (x, y).
  5918. */
  5919. static StartingAt(x: number, y: number): Path2;
  5920. }
  5921. /**
  5922. * Represents a 3D path made up of multiple 3D points
  5923. */
  5924. export class Path3D {
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[];
  5929. private _curve;
  5930. private _distances;
  5931. private _tangents;
  5932. private _normals;
  5933. private _binormals;
  5934. private _raw;
  5935. /**
  5936. * new Path3D(path, normal, raw)
  5937. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5938. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5939. * @param path an array of Vector3, the curve axis of the Path3D
  5940. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5941. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5942. */
  5943. constructor(
  5944. /**
  5945. * an array of Vector3, the curve axis of the Path3D
  5946. */
  5947. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5948. /**
  5949. * Returns the Path3D array of successive Vector3 designing its curve.
  5950. * @returns the Path3D array of successive Vector3 designing its curve.
  5951. */
  5952. getCurve(): Vector3[];
  5953. /**
  5954. * Returns an array populated with tangent vectors on each Path3D curve point.
  5955. * @returns an array populated with tangent vectors on each Path3D curve point.
  5956. */
  5957. getTangents(): Vector3[];
  5958. /**
  5959. * Returns an array populated with normal vectors on each Path3D curve point.
  5960. * @returns an array populated with normal vectors on each Path3D curve point.
  5961. */
  5962. getNormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with binormal vectors on each Path3D curve point.
  5965. * @returns an array populated with binormal vectors on each Path3D curve point.
  5966. */
  5967. getBinormals(): Vector3[];
  5968. /**
  5969. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5970. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5971. */
  5972. getDistances(): number[];
  5973. /**
  5974. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5975. * @param path path which all values are copied into the curves points
  5976. * @param firstNormal which should be projected onto the curve
  5977. * @returns the same object updated.
  5978. */
  5979. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5980. private _compute;
  5981. private _getFirstNonNullVector;
  5982. private _getLastNonNullVector;
  5983. private _normalVector;
  5984. }
  5985. /**
  5986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5987. * A Curve3 is designed from a series of successive Vector3.
  5988. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5989. */
  5990. export class Curve3 {
  5991. private _points;
  5992. private _length;
  5993. /**
  5994. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5995. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5996. * @param v1 (Vector3) the control point
  5997. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5998. * @param nbPoints (integer) the wanted number of points in the curve
  5999. * @returns the created Curve3
  6000. */
  6001. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6002. /**
  6003. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6004. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6005. * @param v1 (Vector3) the first control point
  6006. * @param v2 (Vector3) the second control point
  6007. * @param v3 (Vector3) the end point of the Cubic Bezier
  6008. * @param nbPoints (integer) the wanted number of points in the curve
  6009. * @returns the created Curve3
  6010. */
  6011. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6012. /**
  6013. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6014. * @param p1 (Vector3) the origin point of the Hermite Spline
  6015. * @param t1 (Vector3) the tangent vector at the origin point
  6016. * @param p2 (Vector3) the end point of the Hermite Spline
  6017. * @param t2 (Vector3) the tangent vector at the end point
  6018. * @param nbPoints (integer) the wanted number of points in the curve
  6019. * @returns the created Curve3
  6020. */
  6021. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6022. /**
  6023. * Returns a Curve3 object along a CatmullRom Spline curve :
  6024. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6025. * @param nbPoints (integer) the wanted number of points between each curve control points
  6026. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6027. * @returns the created Curve3
  6028. */
  6029. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6030. /**
  6031. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6032. * A Curve3 is designed from a series of successive Vector3.
  6033. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6034. * @param points points which make up the curve
  6035. */
  6036. constructor(points: Vector3[]);
  6037. /**
  6038. * @returns the Curve3 stored array of successive Vector3
  6039. */
  6040. getPoints(): Vector3[];
  6041. /**
  6042. * @returns the computed length (float) of the curve.
  6043. */
  6044. length(): number;
  6045. /**
  6046. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6047. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6048. * curveA and curveB keep unchanged.
  6049. * @param curve the curve to continue from this curve
  6050. * @returns the newly constructed curve
  6051. */
  6052. continue(curve: DeepImmutable<Curve3>): Curve3;
  6053. private _computeLength;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * This represents the main contract an easing function should follow.
  6059. * Easing functions are used throughout the animation system.
  6060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6061. */
  6062. export interface IEasingFunction {
  6063. /**
  6064. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6065. * of the easing function.
  6066. * The link below provides some of the most common examples of easing functions.
  6067. * @see https://easings.net/
  6068. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6069. * @returns the corresponding value on the curve defined by the easing function
  6070. */
  6071. ease(gradient: number): number;
  6072. }
  6073. /**
  6074. * Base class used for every default easing function.
  6075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6076. */
  6077. export class EasingFunction implements IEasingFunction {
  6078. /**
  6079. * Interpolation follows the mathematical formula associated with the easing function.
  6080. */
  6081. static readonly EASINGMODE_EASEIN: number;
  6082. /**
  6083. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6084. */
  6085. static readonly EASINGMODE_EASEOUT: number;
  6086. /**
  6087. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6088. */
  6089. static readonly EASINGMODE_EASEINOUT: number;
  6090. private _easingMode;
  6091. /**
  6092. * Sets the easing mode of the current function.
  6093. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6094. */
  6095. setEasingMode(easingMode: number): void;
  6096. /**
  6097. * Gets the current easing mode.
  6098. * @returns the easing mode
  6099. */
  6100. getEasingMode(): number;
  6101. /**
  6102. * @hidden
  6103. */
  6104. easeInCore(gradient: number): number;
  6105. /**
  6106. * Given an input gradient between 0 and 1, this returns the corresponding value
  6107. * of the easing function.
  6108. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6109. * @returns the corresponding value on the curve defined by the easing function
  6110. */
  6111. ease(gradient: number): number;
  6112. }
  6113. /**
  6114. * Easing function with a circle shape (see link below).
  6115. * @see https://easings.net/#easeInCirc
  6116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6117. */
  6118. export class CircleEase extends EasingFunction implements IEasingFunction {
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a ease back shape (see link below).
  6124. * @see https://easings.net/#easeInBack
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BackEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the amplitude of the function */
  6129. amplitude: number;
  6130. /**
  6131. * Instantiates a back ease easing
  6132. * @see https://easings.net/#easeInBack
  6133. * @param amplitude Defines the amplitude of the function
  6134. */
  6135. constructor(
  6136. /** Defines the amplitude of the function */
  6137. amplitude?: number);
  6138. /** @hidden */
  6139. easeInCore(gradient: number): number;
  6140. }
  6141. /**
  6142. * Easing function with a bouncing shape (see link below).
  6143. * @see https://easings.net/#easeInBounce
  6144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6145. */
  6146. export class BounceEase extends EasingFunction implements IEasingFunction {
  6147. /** Defines the number of bounces */
  6148. bounces: number;
  6149. /** Defines the amplitude of the bounce */
  6150. bounciness: number;
  6151. /**
  6152. * Instantiates a bounce easing
  6153. * @see https://easings.net/#easeInBounce
  6154. * @param bounces Defines the number of bounces
  6155. * @param bounciness Defines the amplitude of the bounce
  6156. */
  6157. constructor(
  6158. /** Defines the number of bounces */
  6159. bounces?: number,
  6160. /** Defines the amplitude of the bounce */
  6161. bounciness?: number);
  6162. /** @hidden */
  6163. easeInCore(gradient: number): number;
  6164. }
  6165. /**
  6166. * Easing function with a power of 3 shape (see link below).
  6167. * @see https://easings.net/#easeInCubic
  6168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6169. */
  6170. export class CubicEase extends EasingFunction implements IEasingFunction {
  6171. /** @hidden */
  6172. easeInCore(gradient: number): number;
  6173. }
  6174. /**
  6175. * Easing function with an elastic shape (see link below).
  6176. * @see https://easings.net/#easeInElastic
  6177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6178. */
  6179. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6180. /** Defines the number of oscillations*/
  6181. oscillations: number;
  6182. /** Defines the amplitude of the oscillations*/
  6183. springiness: number;
  6184. /**
  6185. * Instantiates an elastic easing function
  6186. * @see https://easings.net/#easeInElastic
  6187. * @param oscillations Defines the number of oscillations
  6188. * @param springiness Defines the amplitude of the oscillations
  6189. */
  6190. constructor(
  6191. /** Defines the number of oscillations*/
  6192. oscillations?: number,
  6193. /** Defines the amplitude of the oscillations*/
  6194. springiness?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with an exponential shape (see link below).
  6200. * @see https://easings.net/#easeInExpo
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the exponent of the function */
  6205. exponent: number;
  6206. /**
  6207. * Instantiates an exponential easing function
  6208. * @see https://easings.net/#easeInExpo
  6209. * @param exponent Defines the exponent of the function
  6210. */
  6211. constructor(
  6212. /** Defines the exponent of the function */
  6213. exponent?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class PowerEase extends EasingFunction implements IEasingFunction {
  6223. /** Defines the power of the function */
  6224. power: number;
  6225. /**
  6226. * Instantiates an power base easing function
  6227. * @see https://easings.net/#easeInQuad
  6228. * @param power Defines the power of the function
  6229. */
  6230. constructor(
  6231. /** Defines the power of the function */
  6232. power?: number);
  6233. /** @hidden */
  6234. easeInCore(gradient: number): number;
  6235. }
  6236. /**
  6237. * Easing function with a power of 2 shape (see link below).
  6238. * @see https://easings.net/#easeInQuad
  6239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6240. */
  6241. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6242. /** @hidden */
  6243. easeInCore(gradient: number): number;
  6244. }
  6245. /**
  6246. * Easing function with a power of 4 shape (see link below).
  6247. * @see https://easings.net/#easeInQuart
  6248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6249. */
  6250. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6251. /** @hidden */
  6252. easeInCore(gradient: number): number;
  6253. }
  6254. /**
  6255. * Easing function with a power of 5 shape (see link below).
  6256. * @see https://easings.net/#easeInQuint
  6257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6258. */
  6259. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a sin shape (see link below).
  6265. * @see https://easings.net/#easeInSine
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class SineEase extends EasingFunction implements IEasingFunction {
  6269. /** @hidden */
  6270. easeInCore(gradient: number): number;
  6271. }
  6272. /**
  6273. * Easing function with a bezier shape (see link below).
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6276. */
  6277. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6278. /** Defines the x component of the start tangent in the bezier curve */
  6279. x1: number;
  6280. /** Defines the y component of the start tangent in the bezier curve */
  6281. y1: number;
  6282. /** Defines the x component of the end tangent in the bezier curve */
  6283. x2: number;
  6284. /** Defines the y component of the end tangent in the bezier curve */
  6285. y2: number;
  6286. /**
  6287. * Instantiates a bezier function
  6288. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6289. * @param x1 Defines the x component of the start tangent in the bezier curve
  6290. * @param y1 Defines the y component of the start tangent in the bezier curve
  6291. * @param x2 Defines the x component of the end tangent in the bezier curve
  6292. * @param y2 Defines the y component of the end tangent in the bezier curve
  6293. */
  6294. constructor(
  6295. /** Defines the x component of the start tangent in the bezier curve */
  6296. x1?: number,
  6297. /** Defines the y component of the start tangent in the bezier curve */
  6298. y1?: number,
  6299. /** Defines the x component of the end tangent in the bezier curve */
  6300. x2?: number,
  6301. /** Defines the y component of the end tangent in the bezier curve */
  6302. y2?: number);
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. }
  6307. declare module BABYLON {
  6308. /**
  6309. * Defines an interface which represents an animation key frame
  6310. */
  6311. export interface IAnimationKey {
  6312. /**
  6313. * Frame of the key frame
  6314. */
  6315. frame: number;
  6316. /**
  6317. * Value at the specifies key frame
  6318. */
  6319. value: any;
  6320. /**
  6321. * The input tangent for the cubic hermite spline
  6322. */
  6323. inTangent?: any;
  6324. /**
  6325. * The output tangent for the cubic hermite spline
  6326. */
  6327. outTangent?: any;
  6328. /**
  6329. * The animation interpolation type
  6330. */
  6331. interpolation?: AnimationKeyInterpolation;
  6332. }
  6333. /**
  6334. * Enum for the animation key frame interpolation type
  6335. */
  6336. export enum AnimationKeyInterpolation {
  6337. /**
  6338. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6339. */
  6340. STEP = 1
  6341. }
  6342. }
  6343. declare module BABYLON {
  6344. /**
  6345. * Represents the range of an animation
  6346. */
  6347. export class AnimationRange {
  6348. /**The name of the animation range**/
  6349. name: string;
  6350. /**The starting frame of the animation */
  6351. from: number;
  6352. /**The ending frame of the animation*/
  6353. to: number;
  6354. /**
  6355. * Initializes the range of an animation
  6356. * @param name The name of the animation range
  6357. * @param from The starting frame of the animation
  6358. * @param to The ending frame of the animation
  6359. */
  6360. constructor(
  6361. /**The name of the animation range**/
  6362. name: string,
  6363. /**The starting frame of the animation */
  6364. from: number,
  6365. /**The ending frame of the animation*/
  6366. to: number);
  6367. /**
  6368. * Makes a copy of the animation range
  6369. * @returns A copy of the animation range
  6370. */
  6371. clone(): AnimationRange;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * Composed of a frame, and an action function
  6377. */
  6378. export class AnimationEvent {
  6379. /** The frame for which the event is triggered **/
  6380. frame: number;
  6381. /** The event to perform when triggered **/
  6382. action: (currentFrame: number) => void;
  6383. /** Specifies if the event should be triggered only once**/
  6384. onlyOnce?: boolean | undefined;
  6385. /**
  6386. * Specifies if the animation event is done
  6387. */
  6388. isDone: boolean;
  6389. /**
  6390. * Initializes the animation event
  6391. * @param frame The frame for which the event is triggered
  6392. * @param action The event to perform when triggered
  6393. * @param onlyOnce Specifies if the event should be triggered only once
  6394. */
  6395. constructor(
  6396. /** The frame for which the event is triggered **/
  6397. frame: number,
  6398. /** The event to perform when triggered **/
  6399. action: (currentFrame: number) => void,
  6400. /** Specifies if the event should be triggered only once**/
  6401. onlyOnce?: boolean | undefined);
  6402. /** @hidden */
  6403. _clone(): AnimationEvent;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Interface used to define a behavior
  6409. */
  6410. export interface Behavior<T> {
  6411. /** gets or sets behavior's name */
  6412. name: string;
  6413. /**
  6414. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6415. */
  6416. init(): void;
  6417. /**
  6418. * Called when the behavior is attached to a target
  6419. * @param target defines the target where the behavior is attached to
  6420. */
  6421. attach(target: T): void;
  6422. /**
  6423. * Called when the behavior is detached from its target
  6424. */
  6425. detach(): void;
  6426. }
  6427. /**
  6428. * Interface implemented by classes supporting behaviors
  6429. */
  6430. export interface IBehaviorAware<T> {
  6431. /**
  6432. * Attach a behavior
  6433. * @param behavior defines the behavior to attach
  6434. * @returns the current host
  6435. */
  6436. addBehavior(behavior: Behavior<T>): T;
  6437. /**
  6438. * Remove a behavior from the current object
  6439. * @param behavior defines the behavior to detach
  6440. * @returns the current host
  6441. */
  6442. removeBehavior(behavior: Behavior<T>): T;
  6443. /**
  6444. * Gets a behavior using its name to search
  6445. * @param name defines the name to search
  6446. * @returns the behavior or null if not found
  6447. */
  6448. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Defines an array and its length.
  6454. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6455. */
  6456. export interface ISmartArrayLike<T> {
  6457. /**
  6458. * The data of the array.
  6459. */
  6460. data: Array<T>;
  6461. /**
  6462. * The active length of the array.
  6463. */
  6464. length: number;
  6465. }
  6466. /**
  6467. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6468. */
  6469. export class SmartArray<T> implements ISmartArrayLike<T> {
  6470. /**
  6471. * The full set of data from the array.
  6472. */
  6473. data: Array<T>;
  6474. /**
  6475. * The active length of the array.
  6476. */
  6477. length: number;
  6478. protected _id: number;
  6479. /**
  6480. * Instantiates a Smart Array.
  6481. * @param capacity defines the default capacity of the array.
  6482. */
  6483. constructor(capacity: number);
  6484. /**
  6485. * Pushes a value at the end of the active data.
  6486. * @param value defines the object to push in the array.
  6487. */
  6488. push(value: T): void;
  6489. /**
  6490. * Iterates over the active data and apply the lambda to them.
  6491. * @param func defines the action to apply on each value.
  6492. */
  6493. forEach(func: (content: T) => void): void;
  6494. /**
  6495. * Sorts the full sets of data.
  6496. * @param compareFn defines the comparison function to apply.
  6497. */
  6498. sort(compareFn: (a: T, b: T) => number): void;
  6499. /**
  6500. * Resets the active data to an empty array.
  6501. */
  6502. reset(): void;
  6503. /**
  6504. * Releases all the data from the array as well as the array.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Concats the active data with a given array.
  6509. * @param array defines the data to concatenate with.
  6510. */
  6511. concat(array: any): void;
  6512. /**
  6513. * Returns the position of a value in the active data.
  6514. * @param value defines the value to find the index for
  6515. * @returns the index if found in the active data otherwise -1
  6516. */
  6517. indexOf(value: T): number;
  6518. /**
  6519. * Returns whether an element is part of the active data.
  6520. * @param value defines the value to look for
  6521. * @returns true if found in the active data otherwise false
  6522. */
  6523. contains(value: T): boolean;
  6524. private static _GlobalId;
  6525. }
  6526. /**
  6527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6528. * The data in this array can only be present once
  6529. */
  6530. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6531. private _duplicateId;
  6532. /**
  6533. * Pushes a value at the end of the active data.
  6534. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6535. * @param value defines the object to push in the array.
  6536. */
  6537. push(value: T): void;
  6538. /**
  6539. * Pushes a value at the end of the active data.
  6540. * If the data is already present, it won t be added again
  6541. * @param value defines the object to push in the array.
  6542. * @returns true if added false if it was already present
  6543. */
  6544. pushNoDuplicate(value: T): boolean;
  6545. /**
  6546. * Resets the active data to an empty array.
  6547. */
  6548. reset(): void;
  6549. /**
  6550. * Concats the active data with a given array.
  6551. * This ensures no dupplicate will be present in the result.
  6552. * @param array defines the data to concatenate with.
  6553. */
  6554. concatWithNoDuplicate(array: any): void;
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * @ignore
  6560. * This is a list of all the different input types that are available in the application.
  6561. * Fo instance: ArcRotateCameraGamepadInput...
  6562. */
  6563. export var CameraInputTypes: {};
  6564. /**
  6565. * This is the contract to implement in order to create a new input class.
  6566. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6567. */
  6568. export interface ICameraInput<TCamera extends Camera> {
  6569. /**
  6570. * Defines the camera the input is attached to.
  6571. */
  6572. camera: Nullable<TCamera>;
  6573. /**
  6574. * Gets the class name of the current intput.
  6575. * @returns the class name
  6576. */
  6577. getClassName(): string;
  6578. /**
  6579. * Get the friendly name associated with the input class.
  6580. * @returns the input friendly name
  6581. */
  6582. getSimpleName(): string;
  6583. /**
  6584. * Attach the input controls to a specific dom element to get the input from.
  6585. * @param element Defines the element the controls should be listened from
  6586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6587. */
  6588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6589. /**
  6590. * Detach the current controls from the specified dom element.
  6591. * @param element Defines the element to stop listening the inputs from
  6592. */
  6593. detachControl(element: Nullable<HTMLElement>): void;
  6594. /**
  6595. * Update the current camera state depending on the inputs that have been used this frame.
  6596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6597. */
  6598. checkInputs?: () => void;
  6599. }
  6600. /**
  6601. * Represents a map of input types to input instance or input index to input instance.
  6602. */
  6603. export interface CameraInputsMap<TCamera extends Camera> {
  6604. /**
  6605. * Accessor to the input by input type.
  6606. */
  6607. [name: string]: ICameraInput<TCamera>;
  6608. /**
  6609. * Accessor to the input by input index.
  6610. */
  6611. [idx: number]: ICameraInput<TCamera>;
  6612. }
  6613. /**
  6614. * This represents the input manager used within a camera.
  6615. * It helps dealing with all the different kind of input attached to a camera.
  6616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6617. */
  6618. export class CameraInputsManager<TCamera extends Camera> {
  6619. /**
  6620. * Defines the list of inputs attahed to the camera.
  6621. */
  6622. attached: CameraInputsMap<TCamera>;
  6623. /**
  6624. * Defines the dom element the camera is collecting inputs from.
  6625. * This is null if the controls have not been attached.
  6626. */
  6627. attachedElement: Nullable<HTMLElement>;
  6628. /**
  6629. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6630. */
  6631. noPreventDefault: boolean;
  6632. /**
  6633. * Defined the camera the input manager belongs to.
  6634. */
  6635. camera: TCamera;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs: () => void;
  6641. /**
  6642. * Instantiate a new Camera Input Manager.
  6643. * @param camera Defines the camera the input manager blongs to
  6644. */
  6645. constructor(camera: TCamera);
  6646. /**
  6647. * Add an input method to a camera
  6648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6649. * @param input camera input method
  6650. */
  6651. add(input: ICameraInput<TCamera>): void;
  6652. /**
  6653. * Remove a specific input method from a camera
  6654. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6655. * @param inputToRemove camera input method
  6656. */
  6657. remove(inputToRemove: ICameraInput<TCamera>): void;
  6658. /**
  6659. * Remove a specific input type from a camera
  6660. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6661. * @param inputType the type of the input to remove
  6662. */
  6663. removeByType(inputType: string): void;
  6664. private _addCheckInputs;
  6665. /**
  6666. * Attach the input controls to the currently attached dom element to listen the events from.
  6667. * @param input Defines the input to attach
  6668. */
  6669. attachInput(input: ICameraInput<TCamera>): void;
  6670. /**
  6671. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6672. * @param element Defines the dom element to collect the events from
  6673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6674. */
  6675. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6676. /**
  6677. * Detach the current manager inputs controls from a specific dom element.
  6678. * @param element Defines the dom element to collect the events from
  6679. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6680. */
  6681. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6682. /**
  6683. * Rebuild the dynamic inputCheck function from the current list of
  6684. * defined inputs in the manager.
  6685. */
  6686. rebuildInputCheck(): void;
  6687. /**
  6688. * Remove all attached input methods from a camera
  6689. */
  6690. clear(): void;
  6691. /**
  6692. * Serialize the current input manager attached to a camera.
  6693. * This ensures than once parsed,
  6694. * the input associated to the camera will be identical to the current ones
  6695. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6696. */
  6697. serialize(serializedCamera: any): void;
  6698. /**
  6699. * Parses an input manager serialized JSON to restore the previous list of inputs
  6700. * and states associated to a camera.
  6701. * @param parsedCamera Defines the JSON to parse
  6702. */
  6703. parse(parsedCamera: any): void;
  6704. }
  6705. }
  6706. declare module BABYLON {
  6707. /**
  6708. * @hidden
  6709. */
  6710. export class IntersectionInfo {
  6711. bu: Nullable<number>;
  6712. bv: Nullable<number>;
  6713. distance: number;
  6714. faceId: number;
  6715. subMeshId: number;
  6716. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6717. }
  6718. }
  6719. declare module BABYLON {
  6720. /**
  6721. * Represens a plane by the equation ax + by + cz + d = 0
  6722. */
  6723. export class Plane {
  6724. private static _TmpMatrix;
  6725. /**
  6726. * Normal of the plane (a,b,c)
  6727. */
  6728. normal: Vector3;
  6729. /**
  6730. * d component of the plane
  6731. */
  6732. d: number;
  6733. /**
  6734. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6735. * @param a a component of the plane
  6736. * @param b b component of the plane
  6737. * @param c c component of the plane
  6738. * @param d d component of the plane
  6739. */
  6740. constructor(a: number, b: number, c: number, d: number);
  6741. /**
  6742. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6743. */
  6744. asArray(): number[];
  6745. /**
  6746. * @returns a new plane copied from the current Plane.
  6747. */
  6748. clone(): Plane;
  6749. /**
  6750. * @returns the string "Plane".
  6751. */
  6752. getClassName(): string;
  6753. /**
  6754. * @returns the Plane hash code.
  6755. */
  6756. getHashCode(): number;
  6757. /**
  6758. * Normalize the current Plane in place.
  6759. * @returns the updated Plane.
  6760. */
  6761. normalize(): Plane;
  6762. /**
  6763. * Applies a transformation the plane and returns the result
  6764. * @param transformation the transformation matrix to be applied to the plane
  6765. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6766. */
  6767. transform(transformation: DeepImmutable<Matrix>): Plane;
  6768. /**
  6769. * Calcualtte the dot product between the point and the plane normal
  6770. * @param point point to calculate the dot product with
  6771. * @returns the dot product (float) of the point coordinates and the plane normal.
  6772. */
  6773. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6774. /**
  6775. * Updates the current Plane from the plane defined by the three given points.
  6776. * @param point1 one of the points used to contruct the plane
  6777. * @param point2 one of the points used to contruct the plane
  6778. * @param point3 one of the points used to contruct the plane
  6779. * @returns the updated Plane.
  6780. */
  6781. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6782. /**
  6783. * Checks if the plane is facing a given direction
  6784. * @param direction the direction to check if the plane is facing
  6785. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6786. * @returns True is the vector "direction" is the same side than the plane normal.
  6787. */
  6788. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6789. /**
  6790. * Calculates the distance to a point
  6791. * @param point point to calculate distance to
  6792. * @returns the signed distance (float) from the given point to the Plane.
  6793. */
  6794. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6795. /**
  6796. * Creates a plane from an array
  6797. * @param array the array to create a plane from
  6798. * @returns a new Plane from the given array.
  6799. */
  6800. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6801. /**
  6802. * Creates a plane from three points
  6803. * @param point1 point used to create the plane
  6804. * @param point2 point used to create the plane
  6805. * @param point3 point used to create the plane
  6806. * @returns a new Plane defined by the three given points.
  6807. */
  6808. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6809. /**
  6810. * Creates a plane from an origin point and a normal
  6811. * @param origin origin of the plane to be constructed
  6812. * @param normal normal of the plane to be constructed
  6813. * @returns a new Plane the normal vector to this plane at the given origin point.
  6814. * Note : the vector "normal" is updated because normalized.
  6815. */
  6816. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6817. /**
  6818. * Calculates the distance from a plane and a point
  6819. * @param origin origin of the plane to be constructed
  6820. * @param normal normal of the plane to be constructed
  6821. * @param point point to calculate distance to
  6822. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6823. */
  6824. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6825. }
  6826. }
  6827. declare module BABYLON {
  6828. /**
  6829. * Class used to store bounding sphere information
  6830. */
  6831. export class BoundingSphere {
  6832. /**
  6833. * Gets the center of the bounding sphere in local space
  6834. */
  6835. readonly center: Vector3;
  6836. /**
  6837. * Radius of the bounding sphere in local space
  6838. */
  6839. radius: number;
  6840. /**
  6841. * Gets the center of the bounding sphere in world space
  6842. */
  6843. readonly centerWorld: Vector3;
  6844. /**
  6845. * Radius of the bounding sphere in world space
  6846. */
  6847. radiusWorld: number;
  6848. /**
  6849. * Gets the minimum vector in local space
  6850. */
  6851. readonly minimum: Vector3;
  6852. /**
  6853. * Gets the maximum vector in local space
  6854. */
  6855. readonly maximum: Vector3;
  6856. private _worldMatrix;
  6857. private static readonly TmpVector3;
  6858. /**
  6859. * Creates a new bounding sphere
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding sphere by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingSphere;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding sphere is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding sphere center is in between the frustum planes.
  6893. * Used for optimistic fast inclusion.
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if the sphere center is in between the frustum planes
  6896. */
  6897. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding sphere
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding sphere
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Checks if two sphere intersct
  6906. * @param sphere0 sphere 0
  6907. * @param sphere1 sphere 1
  6908. * @returns true if the speres intersect
  6909. */
  6910. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6911. }
  6912. }
  6913. declare module BABYLON {
  6914. /**
  6915. * Class used to store bounding box information
  6916. */
  6917. export class BoundingBox implements ICullable {
  6918. /**
  6919. * Gets the 8 vectors representing the bounding box in local space
  6920. */
  6921. readonly vectors: Vector3[];
  6922. /**
  6923. * Gets the center of the bounding box in local space
  6924. */
  6925. readonly center: Vector3;
  6926. /**
  6927. * Gets the center of the bounding box in world space
  6928. */
  6929. readonly centerWorld: Vector3;
  6930. /**
  6931. * Gets the extend size in local space
  6932. */
  6933. readonly extendSize: Vector3;
  6934. /**
  6935. * Gets the extend size in world space
  6936. */
  6937. readonly extendSizeWorld: Vector3;
  6938. /**
  6939. * Gets the OBB (object bounding box) directions
  6940. */
  6941. readonly directions: Vector3[];
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in world space
  6944. */
  6945. readonly vectorsWorld: Vector3[];
  6946. /**
  6947. * Gets the minimum vector in world space
  6948. */
  6949. readonly minimumWorld: Vector3;
  6950. /**
  6951. * Gets the maximum vector in world space
  6952. */
  6953. readonly maximumWorld: Vector3;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * @hidden
  6966. */
  6967. _tag: number;
  6968. /**
  6969. * Creates a new bounding box
  6970. * @param min defines the minimum vector (in local space)
  6971. * @param max defines the maximum vector (in local space)
  6972. * @param worldMatrix defines the new world matrix
  6973. */
  6974. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6975. /**
  6976. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6977. * @param min defines the new minimum vector (in local space)
  6978. * @param max defines the new maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Scale the current bounding box by applying a scale factor
  6984. * @param factor defines the scale factor to apply
  6985. * @returns the current bounding box
  6986. */
  6987. scale(factor: number): BoundingBox;
  6988. /**
  6989. * Gets the world matrix of the bounding box
  6990. * @returns a matrix
  6991. */
  6992. getWorldMatrix(): DeepImmutable<Matrix>;
  6993. /** @hidden */
  6994. _update(world: DeepImmutable<Matrix>): void;
  6995. /**
  6996. * Tests if the bounding box is intersecting the frustum planes
  6997. * @param frustumPlanes defines the frustum planes to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7001. /**
  7002. * Tests if the bounding box is entirely inside the frustum planes
  7003. * @param frustumPlanes defines the frustum planes to test
  7004. * @returns true if there is an inclusion
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7007. /**
  7008. * Tests if a point is inside the bounding box
  7009. * @param point defines the point to test
  7010. * @returns true if the point is inside the bounding box
  7011. */
  7012. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if the bounding box intersects with a bounding sphere
  7015. * @param sphere defines the sphere to test
  7016. * @returns true if there is an intersection
  7017. */
  7018. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7019. /**
  7020. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7021. * @param min defines the min vector to use
  7022. * @param max defines the max vector to use
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if two bounding boxes are intersections
  7028. * @param box0 defines the first box to test
  7029. * @param box1 defines the second box to test
  7030. * @returns true if there is an intersection
  7031. */
  7032. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7033. /**
  7034. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7035. * @param minPoint defines the minimum vector of the bounding box
  7036. * @param maxPoint defines the maximum vector of the bounding box
  7037. * @param sphereCenter defines the sphere center
  7038. * @param sphereRadius defines the sphere radius
  7039. * @returns true if there is an intersection
  7040. */
  7041. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7042. /**
  7043. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7044. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @return true if there is an inclusion
  7047. */
  7048. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an intersection
  7054. */
  7055. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. }
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class Collider {
  7061. /** Define if a collision was found */
  7062. collisionFound: boolean;
  7063. /**
  7064. * Define last intersection point in local space
  7065. */
  7066. intersectionPoint: Vector3;
  7067. /**
  7068. * Define last collided mesh
  7069. */
  7070. collidedMesh: Nullable<AbstractMesh>;
  7071. private _collisionPoint;
  7072. private _planeIntersectionPoint;
  7073. private _tempVector;
  7074. private _tempVector2;
  7075. private _tempVector3;
  7076. private _tempVector4;
  7077. private _edge;
  7078. private _baseToVertex;
  7079. private _destinationPoint;
  7080. private _slidePlaneNormal;
  7081. private _displacementVector;
  7082. /** @hidden */
  7083. _radius: Vector3;
  7084. /** @hidden */
  7085. _retry: number;
  7086. private _velocity;
  7087. private _basePoint;
  7088. private _epsilon;
  7089. /** @hidden */
  7090. _velocityWorldLength: number;
  7091. /** @hidden */
  7092. _basePointWorld: Vector3;
  7093. private _velocityWorld;
  7094. private _normalizedVelocity;
  7095. /** @hidden */
  7096. _initialVelocity: Vector3;
  7097. /** @hidden */
  7098. _initialPosition: Vector3;
  7099. private _nearestDistance;
  7100. private _collisionMask;
  7101. collisionMask: number;
  7102. /**
  7103. * Gets the plane normal used to compute the sliding response (in local space)
  7104. */
  7105. readonly slidePlaneNormal: Vector3;
  7106. /** @hidden */
  7107. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7108. /** @hidden */
  7109. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7110. /** @hidden */
  7111. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7112. /** @hidden */
  7113. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7114. /** @hidden */
  7115. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7116. /** @hidden */
  7117. _getResponse(pos: Vector3, vel: Vector3): void;
  7118. }
  7119. }
  7120. declare module BABYLON {
  7121. /**
  7122. * Interface for cullable objects
  7123. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7124. */
  7125. export interface ICullable {
  7126. /**
  7127. * Checks if the object or part of the object is in the frustum
  7128. * @param frustumPlanes Camera near/planes
  7129. * @returns true if the object is in frustum otherwise false
  7130. */
  7131. isInFrustum(frustumPlanes: Plane[]): boolean;
  7132. /**
  7133. * Checks if a cullable object (mesh...) is in the camera frustum
  7134. * Unlike isInFrustum this cheks the full bounding box
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7139. }
  7140. /**
  7141. * Info for a bounding data of a mesh
  7142. */
  7143. export class BoundingInfo implements ICullable {
  7144. /**
  7145. * Bounding box for the mesh
  7146. */
  7147. readonly boundingBox: BoundingBox;
  7148. /**
  7149. * Bounding sphere for the mesh
  7150. */
  7151. readonly boundingSphere: BoundingSphere;
  7152. private _isLocked;
  7153. private static readonly TmpVector3;
  7154. /**
  7155. * Constructs bounding info
  7156. * @param minimum min vector of the bounding box/sphere
  7157. * @param maximum max vector of the bounding box/sphere
  7158. * @param worldMatrix defines the new world matrix
  7159. */
  7160. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7161. /**
  7162. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7163. * @param min defines the new minimum vector (in local space)
  7164. * @param max defines the new maximum vector (in local space)
  7165. * @param worldMatrix defines the new world matrix
  7166. */
  7167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * min vector of the bounding box/sphere
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * max vector of the bounding box/sphere
  7174. */
  7175. readonly maximum: Vector3;
  7176. /**
  7177. * If the info is locked and won't be updated to avoid perf overhead
  7178. */
  7179. isLocked: boolean;
  7180. /**
  7181. * Updates the bounding sphere and box
  7182. * @param world world matrix to be used to update
  7183. */
  7184. update(world: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7187. * @param center New center of the bounding info
  7188. * @param extend New extend of the bounding info
  7189. * @returns the current bounding info
  7190. */
  7191. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7192. /**
  7193. * Scale the current bounding info by applying a scale factor
  7194. * @param factor defines the scale factor to apply
  7195. * @returns the current bounding info
  7196. */
  7197. scale(factor: number): BoundingInfo;
  7198. /**
  7199. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7200. * @param frustumPlanes defines the frustum to test
  7201. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7202. * @returns true if the bounding info is in the frustum planes
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7205. /**
  7206. * Gets the world distance between the min and max points of the bounding box
  7207. */
  7208. readonly diagonalLength: number;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7216. /** @hidden */
  7217. _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Extracts minimum and maximum values from a list of indexed positions
  7238. * @param positions defines the positions to use
  7239. * @param indices defines the indices to the positions
  7240. * @param indexStart defines the start index
  7241. * @param indexCount defines the end index
  7242. * @param bias defines bias value to add to the result
  7243. * @return minimum and maximum values
  7244. */
  7245. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7246. minimum: Vector3;
  7247. maximum: Vector3;
  7248. };
  7249. /**
  7250. * Extracts minimum and maximum values from a list of positions
  7251. * @param positions defines the positions to use
  7252. * @param start defines the start index in the positions array
  7253. * @param count defines the number of positions to handle
  7254. * @param bias defines bias value to add to the result
  7255. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7256. * @return minimum and maximum values
  7257. */
  7258. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7259. minimum: Vector3;
  7260. maximum: Vector3;
  7261. };
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Enum that determines the text-wrapping mode to use.
  7266. */
  7267. export enum InspectableType {
  7268. /**
  7269. * Checkbox for booleans
  7270. */
  7271. Checkbox = 0,
  7272. /**
  7273. * Sliders for numbers
  7274. */
  7275. Slider = 1,
  7276. /**
  7277. * Vector3
  7278. */
  7279. Vector3 = 2,
  7280. /**
  7281. * Quaternions
  7282. */
  7283. Quaternion = 3,
  7284. /**
  7285. * Color3
  7286. */
  7287. Color3 = 4,
  7288. /**
  7289. * String
  7290. */
  7291. String = 5
  7292. }
  7293. /**
  7294. * Interface used to define custom inspectable properties.
  7295. * This interface is used by the inspector to display custom property grids
  7296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7297. */
  7298. export interface IInspectable {
  7299. /**
  7300. * Gets the label to display
  7301. */
  7302. label: string;
  7303. /**
  7304. * Gets the name of the property to edit
  7305. */
  7306. propertyName: string;
  7307. /**
  7308. * Gets the type of the editor to use
  7309. */
  7310. type: InspectableType;
  7311. /**
  7312. * Gets the minimum value of the property when using in "slider" mode
  7313. */
  7314. min?: number;
  7315. /**
  7316. * Gets the maximum value of the property when using in "slider" mode
  7317. */
  7318. max?: number;
  7319. /**
  7320. * Gets the setp to use when using in "slider" mode
  7321. */
  7322. step?: number;
  7323. }
  7324. }
  7325. declare module BABYLON {
  7326. /**
  7327. * Class used to provide helper for timing
  7328. */
  7329. export class TimingTools {
  7330. /**
  7331. * Polyfill for setImmediate
  7332. * @param action defines the action to execute after the current execution block
  7333. */
  7334. static SetImmediate(action: () => void): void;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * Class used to enable instatition of objects by class name
  7340. */
  7341. export class InstantiationTools {
  7342. /**
  7343. * Use this object to register external classes like custom textures or material
  7344. * to allow the laoders to instantiate them
  7345. */
  7346. static RegisteredExternalClasses: {
  7347. [key: string]: Object;
  7348. };
  7349. /**
  7350. * Tries to instantiate a new object from a given class name
  7351. * @param className defines the class name to instantiate
  7352. * @returns the new object or null if the system was not able to do the instantiation
  7353. */
  7354. static Instantiate(className: string): any;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * This represents the required contract to create a new type of texture loader.
  7360. */
  7361. export interface IInternalTextureLoader {
  7362. /**
  7363. * Defines wether the loader supports cascade loading the different faces.
  7364. */
  7365. supportCascades: boolean;
  7366. /**
  7367. * This returns if the loader support the current file information.
  7368. * @param extension defines the file extension of the file being loaded
  7369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7370. * @param fallback defines the fallback internal texture if any
  7371. * @param isBase64 defines whether the texture is encoded as a base64
  7372. * @param isBuffer defines whether the texture data are stored as a buffer
  7373. * @returns true if the loader can load the specified file
  7374. */
  7375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7376. /**
  7377. * Transform the url before loading if required.
  7378. * @param rootUrl the url of the texture
  7379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7380. * @returns the transformed texture
  7381. */
  7382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7383. /**
  7384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7385. * @param rootUrl the url of the texture
  7386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7387. * @returns the fallback texture
  7388. */
  7389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7390. /**
  7391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7392. * @param data contains the texture data
  7393. * @param texture defines the BabylonJS internal texture
  7394. * @param createPolynomials will be true if polynomials have been requested
  7395. * @param onLoad defines the callback to trigger once the texture is ready
  7396. * @param onError defines the callback to trigger in case of error
  7397. */
  7398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7399. /**
  7400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7401. * @param data contains the texture data
  7402. * @param texture defines the BabylonJS internal texture
  7403. * @param callback defines the method to call once ready to upload
  7404. */
  7405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7406. }
  7407. }
  7408. declare module BABYLON {
  7409. interface Engine {
  7410. /**
  7411. * Creates a depth stencil cube texture.
  7412. * This is only available in WebGL 2.
  7413. * @param size The size of face edge in the cube texture.
  7414. * @param options The options defining the cube texture.
  7415. * @returns The cube texture
  7416. */
  7417. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7418. /**
  7419. * Creates a cube texture
  7420. * @param rootUrl defines the url where the files to load is located
  7421. * @param scene defines the current scene
  7422. * @param files defines the list of files to load (1 per face)
  7423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7424. * @param onLoad defines an optional callback raised when the texture is loaded
  7425. * @param onError defines an optional callback raised if there is an issue to load the texture
  7426. * @param format defines the format of the data
  7427. * @param forcedExtension defines the extension to use to pick the right loader
  7428. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7431. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7432. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7433. * @returns the cube texture as an InternalTexture
  7434. */
  7435. 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;
  7436. /**
  7437. * Creates a cube texture
  7438. * @param rootUrl defines the url where the files to load is located
  7439. * @param scene defines the current scene
  7440. * @param files defines the list of files to load (1 per face)
  7441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7442. * @param onLoad defines an optional callback raised when the texture is loaded
  7443. * @param onError defines an optional callback raised if there is an issue to load the texture
  7444. * @param format defines the format of the data
  7445. * @param forcedExtension defines the extension to use to pick the right loader
  7446. * @returns the cube texture as an InternalTexture
  7447. */
  7448. 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;
  7449. /**
  7450. * Creates a cube texture
  7451. * @param rootUrl defines the url where the files to load is located
  7452. * @param scene defines the current scene
  7453. * @param files defines the list of files to load (1 per face)
  7454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7455. * @param onLoad defines an optional callback raised when the texture is loaded
  7456. * @param onError defines an optional callback raised if there is an issue to load the texture
  7457. * @param format defines the format of the data
  7458. * @param forcedExtension defines the extension to use to pick the right loader
  7459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7462. * @returns the cube texture as an InternalTexture
  7463. */
  7464. 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;
  7465. /** @hidden */
  7466. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7467. /** @hidden */
  7468. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7469. /** @hidden */
  7470. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7471. /** @hidden */
  7472. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class for creating a cube texture
  7478. */
  7479. export class CubeTexture extends BaseTexture {
  7480. private _delayedOnLoad;
  7481. /**
  7482. * The url of the texture
  7483. */
  7484. url: string;
  7485. /**
  7486. * Gets or sets the center of the bounding box associated with the cube texture.
  7487. * It must define where the camera used to render the texture was set
  7488. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7489. */
  7490. boundingBoxPosition: Vector3;
  7491. private _boundingBoxSize;
  7492. /**
  7493. * Gets or sets the size of the bounding box associated with the cube texture
  7494. * When defined, the cubemap will switch to local mode
  7495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7496. * @example https://www.babylonjs-playground.com/#RNASML
  7497. */
  7498. /**
  7499. * Returns the bounding box size
  7500. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7501. */
  7502. boundingBoxSize: Vector3;
  7503. protected _rotationY: number;
  7504. /**
  7505. * Sets texture matrix rotation angle around Y axis in radians.
  7506. */
  7507. /**
  7508. * Gets texture matrix rotation angle around Y axis radians.
  7509. */
  7510. rotationY: number;
  7511. /**
  7512. * Are mip maps generated for this texture or not.
  7513. */
  7514. readonly noMipmap: boolean;
  7515. private _noMipmap;
  7516. private _files;
  7517. private _extensions;
  7518. private _textureMatrix;
  7519. private _format;
  7520. private _createPolynomials;
  7521. /** @hidden */
  7522. _prefiltered: boolean;
  7523. /**
  7524. * Creates a cube texture from an array of image urls
  7525. * @param files defines an array of image urls
  7526. * @param scene defines the hosting scene
  7527. * @param noMipmap specifies if mip maps are not used
  7528. * @returns a cube texture
  7529. */
  7530. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7531. /**
  7532. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7533. * @param url defines the url of the prefiltered texture
  7534. * @param scene defines the scene the texture is attached to
  7535. * @param forcedExtension defines the extension of the file if different from the url
  7536. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7537. * @return the prefiltered texture
  7538. */
  7539. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7540. /**
  7541. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7542. * as prefiltered data.
  7543. * @param rootUrl defines the url of the texture or the root name of the six images
  7544. * @param scene defines the scene the texture is attached to
  7545. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7546. * @param noMipmap defines if mipmaps should be created or not
  7547. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7548. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7549. * @param onError defines a callback triggered in case of error during load
  7550. * @param format defines the internal format to use for the texture once loaded
  7551. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7552. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7553. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7556. * @return the cube texture
  7557. */
  7558. 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);
  7559. /**
  7560. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7561. */
  7562. readonly isPrefiltered: boolean;
  7563. /**
  7564. * Get the current class name of the texture useful for serialization or dynamic coding.
  7565. * @returns "CubeTexture"
  7566. */
  7567. getClassName(): string;
  7568. /**
  7569. * Update the url (and optional buffer) of this texture if url was null during construction.
  7570. * @param url the url of the texture
  7571. * @param forcedExtension defines the extension to use
  7572. * @param onLoad callback called when the texture is loaded (defaults to null)
  7573. */
  7574. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7575. /**
  7576. * Delays loading of the cube texture
  7577. * @param forcedExtension defines the extension to use
  7578. */
  7579. delayLoad(forcedExtension?: string): void;
  7580. /**
  7581. * Returns the reflection texture matrix
  7582. * @returns the reflection texture matrix
  7583. */
  7584. getReflectionTextureMatrix(): Matrix;
  7585. /**
  7586. * Sets the reflection texture matrix
  7587. * @param value Reflection texture matrix
  7588. */
  7589. setReflectionTextureMatrix(value: Matrix): void;
  7590. /**
  7591. * Parses text to create a cube texture
  7592. * @param parsedTexture define the serialized text to read from
  7593. * @param scene defines the hosting scene
  7594. * @param rootUrl defines the root url of the cube texture
  7595. * @returns a cube texture
  7596. */
  7597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7598. /**
  7599. * Makes a clone, or deep copy, of the cube texture
  7600. * @returns a new cube texture
  7601. */
  7602. clone(): CubeTexture;
  7603. }
  7604. }
  7605. declare module BABYLON {
  7606. /**
  7607. * Manages the defines for the Material
  7608. */
  7609. export class MaterialDefines {
  7610. /** @hidden */
  7611. protected _keys: string[];
  7612. private _isDirty;
  7613. /** @hidden */
  7614. _renderId: number;
  7615. /** @hidden */
  7616. _areLightsDirty: boolean;
  7617. /** @hidden */
  7618. _areLightsDisposed: boolean;
  7619. /** @hidden */
  7620. _areAttributesDirty: boolean;
  7621. /** @hidden */
  7622. _areTexturesDirty: boolean;
  7623. /** @hidden */
  7624. _areFresnelDirty: boolean;
  7625. /** @hidden */
  7626. _areMiscDirty: boolean;
  7627. /** @hidden */
  7628. _areImageProcessingDirty: boolean;
  7629. /** @hidden */
  7630. _normals: boolean;
  7631. /** @hidden */
  7632. _uvs: boolean;
  7633. /** @hidden */
  7634. _needNormals: boolean;
  7635. /** @hidden */
  7636. _needUVs: boolean;
  7637. [id: string]: any;
  7638. /**
  7639. * Specifies if the material needs to be re-calculated
  7640. */
  7641. readonly isDirty: boolean;
  7642. /**
  7643. * Marks the material to indicate that it has been re-calculated
  7644. */
  7645. markAsProcessed(): void;
  7646. /**
  7647. * Marks the material to indicate that it needs to be re-calculated
  7648. */
  7649. markAsUnprocessed(): void;
  7650. /**
  7651. * Marks the material to indicate all of its defines need to be re-calculated
  7652. */
  7653. markAllAsDirty(): void;
  7654. /**
  7655. * Marks the material to indicate that image processing needs to be re-calculated
  7656. */
  7657. markAsImageProcessingDirty(): void;
  7658. /**
  7659. * Marks the material to indicate the lights need to be re-calculated
  7660. * @param disposed Defines whether the light is dirty due to dispose or not
  7661. */
  7662. markAsLightDirty(disposed?: boolean): void;
  7663. /**
  7664. * Marks the attribute state as changed
  7665. */
  7666. markAsAttributesDirty(): void;
  7667. /**
  7668. * Marks the texture state as changed
  7669. */
  7670. markAsTexturesDirty(): void;
  7671. /**
  7672. * Marks the fresnel state as changed
  7673. */
  7674. markAsFresnelDirty(): void;
  7675. /**
  7676. * Marks the misc state as changed
  7677. */
  7678. markAsMiscDirty(): void;
  7679. /**
  7680. * Rebuilds the material defines
  7681. */
  7682. rebuild(): void;
  7683. /**
  7684. * Specifies if two material defines are equal
  7685. * @param other - A material define instance to compare to
  7686. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7687. */
  7688. isEqual(other: MaterialDefines): boolean;
  7689. /**
  7690. * Clones this instance's defines to another instance
  7691. * @param other - material defines to clone values to
  7692. */
  7693. cloneTo(other: MaterialDefines): void;
  7694. /**
  7695. * Resets the material define values
  7696. */
  7697. reset(): void;
  7698. /**
  7699. * Converts the material define values to a string
  7700. * @returns - String of material define information
  7701. */
  7702. toString(): string;
  7703. }
  7704. }
  7705. declare module BABYLON {
  7706. /**
  7707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7709. * 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;
  7710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7711. */
  7712. export class ColorCurves {
  7713. private _dirty;
  7714. private _tempColor;
  7715. private _globalCurve;
  7716. private _highlightsCurve;
  7717. private _midtonesCurve;
  7718. private _shadowsCurve;
  7719. private _positiveCurve;
  7720. private _negativeCurve;
  7721. private _globalHue;
  7722. private _globalDensity;
  7723. private _globalSaturation;
  7724. private _globalExposure;
  7725. /**
  7726. * Gets the global Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the global Hue value.
  7731. * 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).
  7732. */
  7733. globalHue: number;
  7734. /**
  7735. * Gets the global Density value.
  7736. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the global Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. globalDensity: number;
  7745. /**
  7746. * Gets the global Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the global Saturation value.
  7751. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7752. */
  7753. globalSaturation: number;
  7754. /**
  7755. * Gets the global Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the global Exposure value.
  7760. * 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.
  7761. */
  7762. globalExposure: number;
  7763. private _highlightsHue;
  7764. private _highlightsDensity;
  7765. private _highlightsSaturation;
  7766. private _highlightsExposure;
  7767. /**
  7768. * Gets the highlights Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the highlights Hue value.
  7773. * 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).
  7774. */
  7775. highlightsHue: number;
  7776. /**
  7777. * Gets the highlights Density value.
  7778. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the highlights Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. highlightsDensity: number;
  7787. /**
  7788. * Gets the highlights Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the highlights Saturation value.
  7793. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7794. */
  7795. highlightsSaturation: number;
  7796. /**
  7797. * Gets the highlights Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the highlights Exposure value.
  7802. * 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.
  7803. */
  7804. highlightsExposure: number;
  7805. private _midtonesHue;
  7806. private _midtonesDensity;
  7807. private _midtonesSaturation;
  7808. private _midtonesExposure;
  7809. /**
  7810. * Gets the midtones Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the midtones Hue value.
  7815. * 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).
  7816. */
  7817. midtonesHue: number;
  7818. /**
  7819. * Gets the midtones Density value.
  7820. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the midtones Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. midtonesDensity: number;
  7829. /**
  7830. * Gets the midtones Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the midtones Saturation value.
  7835. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7836. */
  7837. midtonesSaturation: number;
  7838. /**
  7839. * Gets the midtones Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the midtones Exposure value.
  7844. * 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.
  7845. */
  7846. midtonesExposure: number;
  7847. private _shadowsHue;
  7848. private _shadowsDensity;
  7849. private _shadowsSaturation;
  7850. private _shadowsExposure;
  7851. /**
  7852. * Gets the shadows Hue value.
  7853. * 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).
  7854. */
  7855. /**
  7856. * Sets the shadows Hue value.
  7857. * 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).
  7858. */
  7859. shadowsHue: number;
  7860. /**
  7861. * Gets the shadows Density value.
  7862. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. /**
  7866. * Sets the shadows Density value.
  7867. * 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.
  7868. * Values less than zero provide a filter of opposite hue.
  7869. */
  7870. shadowsDensity: number;
  7871. /**
  7872. * Gets the shadows Saturation value.
  7873. * 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.
  7874. */
  7875. /**
  7876. * Sets the shadows Saturation value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7878. */
  7879. shadowsSaturation: number;
  7880. /**
  7881. * Gets the shadows Exposure value.
  7882. * 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.
  7883. */
  7884. /**
  7885. * Sets the shadows Exposure value.
  7886. * 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.
  7887. */
  7888. shadowsExposure: number;
  7889. /**
  7890. * Returns the class name
  7891. * @returns The class name
  7892. */
  7893. getClassName(): string;
  7894. /**
  7895. * Binds the color curves to the shader.
  7896. * @param colorCurves The color curve to bind
  7897. * @param effect The effect to bind to
  7898. * @param positiveUniform The positive uniform shader parameter
  7899. * @param neutralUniform The neutral uniform shader parameter
  7900. * @param negativeUniform The negative uniform shader parameter
  7901. */
  7902. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7903. /**
  7904. * Prepare the list of uniforms associated with the ColorCurves effects.
  7905. * @param uniformsList The list of uniforms used in the effect
  7906. */
  7907. static PrepareUniforms(uniformsList: string[]): void;
  7908. /**
  7909. * Returns color grading data based on a hue, density, saturation and exposure value.
  7910. * @param filterHue The hue of the color filter.
  7911. * @param filterDensity The density of the color filter.
  7912. * @param saturation The saturation.
  7913. * @param exposure The exposure.
  7914. * @param result The result data container.
  7915. */
  7916. private getColorGradingDataToRef;
  7917. /**
  7918. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7919. * @param value The input slider value in range [-100,100].
  7920. * @returns Adjusted value.
  7921. */
  7922. private static applyColorGradingSliderNonlinear;
  7923. /**
  7924. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7925. * @param hue The hue (H) input.
  7926. * @param saturation The saturation (S) input.
  7927. * @param brightness The brightness (B) input.
  7928. * @result An RGBA color represented as Vector4.
  7929. */
  7930. private static fromHSBToRef;
  7931. /**
  7932. * Returns a value clamped between min and max
  7933. * @param value The value to clamp
  7934. * @param min The minimum of value
  7935. * @param max The maximum of value
  7936. * @returns The clamped value.
  7937. */
  7938. private static clamp;
  7939. /**
  7940. * Clones the current color curve instance.
  7941. * @return The cloned curves
  7942. */
  7943. clone(): ColorCurves;
  7944. /**
  7945. * Serializes the current color curve instance to a json representation.
  7946. * @return a JSON representation
  7947. */
  7948. serialize(): any;
  7949. /**
  7950. * Parses the color curve from a json representation.
  7951. * @param source the JSON source to parse
  7952. * @return The parsed curves
  7953. */
  7954. static Parse(source: any): ColorCurves;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Interface to follow in your material defines to integrate easily the
  7960. * Image proccessing functions.
  7961. * @hidden
  7962. */
  7963. export interface IImageProcessingConfigurationDefines {
  7964. IMAGEPROCESSING: boolean;
  7965. VIGNETTE: boolean;
  7966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7967. VIGNETTEBLENDMODEOPAQUE: boolean;
  7968. TONEMAPPING: boolean;
  7969. TONEMAPPING_ACES: boolean;
  7970. CONTRAST: boolean;
  7971. EXPOSURE: boolean;
  7972. COLORCURVES: boolean;
  7973. COLORGRADING: boolean;
  7974. COLORGRADING3D: boolean;
  7975. SAMPLER3DGREENDEPTH: boolean;
  7976. SAMPLER3DBGRMAP: boolean;
  7977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7978. }
  7979. /**
  7980. * @hidden
  7981. */
  7982. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7983. IMAGEPROCESSING: boolean;
  7984. VIGNETTE: boolean;
  7985. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7986. VIGNETTEBLENDMODEOPAQUE: boolean;
  7987. TONEMAPPING: boolean;
  7988. TONEMAPPING_ACES: boolean;
  7989. CONTRAST: boolean;
  7990. COLORCURVES: boolean;
  7991. COLORGRADING: boolean;
  7992. COLORGRADING3D: boolean;
  7993. SAMPLER3DGREENDEPTH: boolean;
  7994. SAMPLER3DBGRMAP: boolean;
  7995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7996. EXPOSURE: boolean;
  7997. constructor();
  7998. }
  7999. /**
  8000. * This groups together the common properties used for image processing either in direct forward pass
  8001. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8002. * or not.
  8003. */
  8004. export class ImageProcessingConfiguration {
  8005. /**
  8006. * Default tone mapping applied in BabylonJS.
  8007. */
  8008. static readonly TONEMAPPING_STANDARD: number;
  8009. /**
  8010. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8011. * to other engines rendering to increase portability.
  8012. */
  8013. static readonly TONEMAPPING_ACES: number;
  8014. /**
  8015. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8016. */
  8017. colorCurves: Nullable<ColorCurves>;
  8018. private _colorCurvesEnabled;
  8019. /**
  8020. * Gets wether the color curves effect is enabled.
  8021. */
  8022. /**
  8023. * Sets wether the color curves effect is enabled.
  8024. */
  8025. colorCurvesEnabled: boolean;
  8026. private _colorGradingTexture;
  8027. /**
  8028. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8029. */
  8030. /**
  8031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8032. */
  8033. colorGradingTexture: Nullable<BaseTexture>;
  8034. private _colorGradingEnabled;
  8035. /**
  8036. * Gets wether the color grading effect is enabled.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is enabled.
  8040. */
  8041. colorGradingEnabled: boolean;
  8042. private _colorGradingWithGreenDepth;
  8043. /**
  8044. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8045. */
  8046. /**
  8047. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8048. */
  8049. colorGradingWithGreenDepth: boolean;
  8050. private _colorGradingBGR;
  8051. /**
  8052. * Gets wether the color grading texture contains BGR values.
  8053. */
  8054. /**
  8055. * Sets wether the color grading texture contains BGR values.
  8056. */
  8057. colorGradingBGR: boolean;
  8058. /** @hidden */
  8059. _exposure: number;
  8060. /**
  8061. * Gets the Exposure used in the effect.
  8062. */
  8063. /**
  8064. * Sets the Exposure used in the effect.
  8065. */
  8066. exposure: number;
  8067. private _toneMappingEnabled;
  8068. /**
  8069. * Gets wether the tone mapping effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the tone mapping effect is enabled.
  8073. */
  8074. toneMappingEnabled: boolean;
  8075. private _toneMappingType;
  8076. /**
  8077. * Gets the type of tone mapping effect.
  8078. */
  8079. /**
  8080. * Sets the type of tone mapping effect used in BabylonJS.
  8081. */
  8082. toneMappingType: number;
  8083. protected _contrast: number;
  8084. /**
  8085. * Gets the contrast used in the effect.
  8086. */
  8087. /**
  8088. * Sets the contrast used in the effect.
  8089. */
  8090. contrast: number;
  8091. /**
  8092. * Vignette stretch size.
  8093. */
  8094. vignetteStretch: number;
  8095. /**
  8096. * Vignette centre X Offset.
  8097. */
  8098. vignetteCentreX: number;
  8099. /**
  8100. * Vignette centre Y Offset.
  8101. */
  8102. vignetteCentreY: number;
  8103. /**
  8104. * Vignette weight or intensity of the vignette effect.
  8105. */
  8106. vignetteWeight: number;
  8107. /**
  8108. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8109. * if vignetteEnabled is set to true.
  8110. */
  8111. vignetteColor: Color4;
  8112. /**
  8113. * Camera field of view used by the Vignette effect.
  8114. */
  8115. vignetteCameraFov: number;
  8116. private _vignetteBlendMode;
  8117. /**
  8118. * Gets the vignette blend mode allowing different kind of effect.
  8119. */
  8120. /**
  8121. * Sets the vignette blend mode allowing different kind of effect.
  8122. */
  8123. vignetteBlendMode: number;
  8124. private _vignetteEnabled;
  8125. /**
  8126. * Gets wether the vignette effect is enabled.
  8127. */
  8128. /**
  8129. * Sets wether the vignette effect is enabled.
  8130. */
  8131. vignetteEnabled: boolean;
  8132. private _applyByPostProcess;
  8133. /**
  8134. * Gets wether the image processing is applied through a post process or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is applied through a post process or not.
  8138. */
  8139. applyByPostProcess: boolean;
  8140. private _isEnabled;
  8141. /**
  8142. * Gets wether the image processing is enabled or not.
  8143. */
  8144. /**
  8145. * Sets wether the image processing is enabled or not.
  8146. */
  8147. isEnabled: boolean;
  8148. /**
  8149. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8150. */
  8151. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8152. /**
  8153. * Method called each time the image processing information changes requires to recompile the effect.
  8154. */
  8155. protected _updateParameters(): void;
  8156. /**
  8157. * Gets the current class name.
  8158. * @return "ImageProcessingConfiguration"
  8159. */
  8160. getClassName(): string;
  8161. /**
  8162. * Prepare the list of uniforms associated with the Image Processing effects.
  8163. * @param uniforms The list of uniforms used in the effect
  8164. * @param defines the list of defines currently in use
  8165. */
  8166. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8167. /**
  8168. * Prepare the list of samplers associated with the Image Processing effects.
  8169. * @param samplersList The list of uniforms used in the effect
  8170. * @param defines the list of defines currently in use
  8171. */
  8172. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8173. /**
  8174. * Prepare the list of defines associated to the shader.
  8175. * @param defines the list of defines to complete
  8176. * @param forPostProcess Define if we are currently in post process mode or not
  8177. */
  8178. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8179. /**
  8180. * Returns true if all the image processing information are ready.
  8181. * @returns True if ready, otherwise, false
  8182. */
  8183. isReady(): boolean;
  8184. /**
  8185. * Binds the image processing to the shader.
  8186. * @param effect The effect to bind to
  8187. * @param aspectRatio Define the current aspect ratio of the effect
  8188. */
  8189. bind(effect: Effect, aspectRatio?: number): void;
  8190. /**
  8191. * Clones the current image processing instance.
  8192. * @return The cloned image processing
  8193. */
  8194. clone(): ImageProcessingConfiguration;
  8195. /**
  8196. * Serializes the current image processing instance to a json representation.
  8197. * @return a JSON representation
  8198. */
  8199. serialize(): any;
  8200. /**
  8201. * Parses the image processing from a json representation.
  8202. * @param source the JSON source to parse
  8203. * @return The parsed image processing
  8204. */
  8205. static Parse(source: any): ImageProcessingConfiguration;
  8206. private static _VIGNETTEMODE_MULTIPLY;
  8207. private static _VIGNETTEMODE_OPAQUE;
  8208. /**
  8209. * Used to apply the vignette as a mix with the pixel color.
  8210. */
  8211. static readonly VIGNETTEMODE_MULTIPLY: number;
  8212. /**
  8213. * Used to apply the vignette as a replacement of the pixel color.
  8214. */
  8215. static readonly VIGNETTEMODE_OPAQUE: number;
  8216. }
  8217. }
  8218. declare module BABYLON {
  8219. /** @hidden */
  8220. export var postprocessVertexShader: {
  8221. name: string;
  8222. shader: string;
  8223. };
  8224. }
  8225. declare module BABYLON {
  8226. /** Defines supported spaces */
  8227. export enum Space {
  8228. /** Local (object) space */
  8229. LOCAL = 0,
  8230. /** World space */
  8231. WORLD = 1,
  8232. /** Bone space */
  8233. BONE = 2
  8234. }
  8235. /** Defines the 3 main axes */
  8236. export class Axis {
  8237. /** X axis */
  8238. static X: Vector3;
  8239. /** Y axis */
  8240. static Y: Vector3;
  8241. /** Z axis */
  8242. static Z: Vector3;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8248. * This is the base of the follow, arc rotate cameras and Free camera
  8249. * @see http://doc.babylonjs.com/features/cameras
  8250. */
  8251. export class TargetCamera extends Camera {
  8252. private static _RigCamTransformMatrix;
  8253. private static _TargetTransformMatrix;
  8254. private static _TargetFocalPoint;
  8255. /**
  8256. * Define the current direction the camera is moving to
  8257. */
  8258. cameraDirection: Vector3;
  8259. /**
  8260. * Define the current rotation the camera is rotating to
  8261. */
  8262. cameraRotation: Vector2;
  8263. /**
  8264. * When set, the up vector of the camera will be updated by the rotation of the camera
  8265. */
  8266. updateUpVectorFromRotation: boolean;
  8267. private _tmpQuaternion;
  8268. /**
  8269. * Define the current rotation of the camera
  8270. */
  8271. rotation: Vector3;
  8272. /**
  8273. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8274. */
  8275. rotationQuaternion: Quaternion;
  8276. /**
  8277. * Define the current speed of the camera
  8278. */
  8279. speed: number;
  8280. /**
  8281. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8282. * around all axis.
  8283. */
  8284. noRotationConstraint: boolean;
  8285. /**
  8286. * Define the current target of the camera as an object or a position.
  8287. */
  8288. lockedTarget: any;
  8289. /** @hidden */
  8290. _currentTarget: Vector3;
  8291. /** @hidden */
  8292. _initialFocalDistance: number;
  8293. /** @hidden */
  8294. _viewMatrix: Matrix;
  8295. /** @hidden */
  8296. _camMatrix: Matrix;
  8297. /** @hidden */
  8298. _cameraTransformMatrix: Matrix;
  8299. /** @hidden */
  8300. _cameraRotationMatrix: Matrix;
  8301. /** @hidden */
  8302. _referencePoint: Vector3;
  8303. /** @hidden */
  8304. _transformedReferencePoint: Vector3;
  8305. protected _globalCurrentTarget: Vector3;
  8306. protected _globalCurrentUpVector: Vector3;
  8307. /** @hidden */
  8308. _reset: () => void;
  8309. private _defaultUp;
  8310. /**
  8311. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8312. * This is the base of the follow, arc rotate cameras and Free camera
  8313. * @see http://doc.babylonjs.com/features/cameras
  8314. * @param name Defines the name of the camera in the scene
  8315. * @param position Defines the start position of the camera in the scene
  8316. * @param scene Defines the scene the camera belongs to
  8317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8318. */
  8319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8320. /**
  8321. * Gets the position in front of the camera at a given distance.
  8322. * @param distance The distance from the camera we want the position to be
  8323. * @returns the position
  8324. */
  8325. getFrontPosition(distance: number): Vector3;
  8326. /** @hidden */
  8327. _getLockedTargetPosition(): Nullable<Vector3>;
  8328. private _storedPosition;
  8329. private _storedRotation;
  8330. private _storedRotationQuaternion;
  8331. /**
  8332. * Store current camera state of the camera (fov, position, rotation, etc..)
  8333. * @returns the camera
  8334. */
  8335. storeState(): Camera;
  8336. /**
  8337. * Restored camera state. You must call storeState() first
  8338. * @returns whether it was successful or not
  8339. * @hidden
  8340. */
  8341. _restoreStateValues(): boolean;
  8342. /** @hidden */
  8343. _initCache(): void;
  8344. /** @hidden */
  8345. _updateCache(ignoreParentClass?: boolean): void;
  8346. /** @hidden */
  8347. _isSynchronizedViewMatrix(): boolean;
  8348. /** @hidden */
  8349. _computeLocalCameraSpeed(): number;
  8350. /**
  8351. * Defines the target the camera should look at.
  8352. * @param target Defines the new target as a Vector or a mesh
  8353. */
  8354. setTarget(target: Vector3): void;
  8355. /**
  8356. * Return the current target position of the camera. This value is expressed in local space.
  8357. * @returns the target position
  8358. */
  8359. getTarget(): Vector3;
  8360. /** @hidden */
  8361. _decideIfNeedsToMove(): boolean;
  8362. /** @hidden */
  8363. _updatePosition(): void;
  8364. /** @hidden */
  8365. _checkInputs(): void;
  8366. protected _updateCameraRotationMatrix(): void;
  8367. /**
  8368. * 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)
  8369. * @returns the current camera
  8370. */
  8371. private _rotateUpVectorWithCameraRotationMatrix;
  8372. private _cachedRotationZ;
  8373. private _cachedQuaternionRotationZ;
  8374. /** @hidden */
  8375. _getViewMatrix(): Matrix;
  8376. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8377. /**
  8378. * @hidden
  8379. */
  8380. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8381. /**
  8382. * @hidden
  8383. */
  8384. _updateRigCameras(): void;
  8385. private _getRigCamPositionAndTarget;
  8386. /**
  8387. * Gets the current object class name.
  8388. * @return the class name
  8389. */
  8390. getClassName(): string;
  8391. }
  8392. }
  8393. declare module BABYLON {
  8394. /**
  8395. * Gather the list of keyboard event types as constants.
  8396. */
  8397. export class KeyboardEventTypes {
  8398. /**
  8399. * The keydown event is fired when a key becomes active (pressed).
  8400. */
  8401. static readonly KEYDOWN: number;
  8402. /**
  8403. * The keyup event is fired when a key has been released.
  8404. */
  8405. static readonly KEYUP: number;
  8406. }
  8407. /**
  8408. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8409. */
  8410. export class KeyboardInfo {
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number;
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent;
  8419. /**
  8420. * Instantiates a new keyboard info.
  8421. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. /**
  8436. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8437. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8438. */
  8439. export class KeyboardInfoPre extends KeyboardInfo {
  8440. /**
  8441. * Defines the type of event (KeyboardEventTypes)
  8442. */
  8443. type: number;
  8444. /**
  8445. * Defines the related dom event
  8446. */
  8447. event: KeyboardEvent;
  8448. /**
  8449. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8450. */
  8451. skipOnPointerObservable: boolean;
  8452. /**
  8453. * Instantiates a new keyboard pre info.
  8454. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8455. * @param type Defines the type of event (KeyboardEventTypes)
  8456. * @param event Defines the related dom event
  8457. */
  8458. constructor(
  8459. /**
  8460. * Defines the type of event (KeyboardEventTypes)
  8461. */
  8462. type: number,
  8463. /**
  8464. * Defines the related dom event
  8465. */
  8466. event: KeyboardEvent);
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /**
  8471. * Manage the keyboard inputs to control the movement of a free camera.
  8472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8473. */
  8474. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8475. /**
  8476. * Defines the camera the input is attached to.
  8477. */
  8478. camera: FreeCamera;
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8481. */
  8482. keysUp: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8485. */
  8486. keysDown: number[];
  8487. /**
  8488. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8489. */
  8490. keysLeft: number[];
  8491. /**
  8492. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8493. */
  8494. keysRight: number[];
  8495. private _keys;
  8496. private _onCanvasBlurObserver;
  8497. private _onKeyboardObserver;
  8498. private _engine;
  8499. private _scene;
  8500. /**
  8501. * Attach the input controls to a specific dom element to get the input from.
  8502. * @param element Defines the element the controls should be listened from
  8503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8504. */
  8505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8506. /**
  8507. * Detach the current controls from the specified dom element.
  8508. * @param element Defines the element to stop listening the inputs from
  8509. */
  8510. detachControl(element: Nullable<HTMLElement>): void;
  8511. /**
  8512. * Update the current camera state depending on the inputs that have been used this frame.
  8513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8514. */
  8515. checkInputs(): void;
  8516. /**
  8517. * Gets the class name of the current intput.
  8518. * @returns the class name
  8519. */
  8520. getClassName(): string;
  8521. /** @hidden */
  8522. _onLostFocus(): void;
  8523. /**
  8524. * Get the friendly name associated with the input class.
  8525. * @returns the input friendly name
  8526. */
  8527. getSimpleName(): string;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * Interface describing all the common properties and methods a shadow light needs to implement.
  8533. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8534. * as well as binding the different shadow properties to the effects.
  8535. */
  8536. export interface IShadowLight extends Light {
  8537. /**
  8538. * The light id in the scene (used in scene.findLighById for instance)
  8539. */
  8540. id: string;
  8541. /**
  8542. * The position the shdow will be casted from.
  8543. */
  8544. position: Vector3;
  8545. /**
  8546. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8547. */
  8548. direction: Vector3;
  8549. /**
  8550. * The transformed position. Position of the light in world space taking parenting in account.
  8551. */
  8552. transformedPosition: Vector3;
  8553. /**
  8554. * The transformed direction. Direction of the light in world space taking parenting in account.
  8555. */
  8556. transformedDirection: Vector3;
  8557. /**
  8558. * The friendly name of the light in the scene.
  8559. */
  8560. name: string;
  8561. /**
  8562. * Defines the shadow projection clipping minimum z value.
  8563. */
  8564. shadowMinZ: number;
  8565. /**
  8566. * Defines the shadow projection clipping maximum z value.
  8567. */
  8568. shadowMaxZ: number;
  8569. /**
  8570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8572. */
  8573. computeTransformedInformation(): boolean;
  8574. /**
  8575. * Gets the scene the light belongs to.
  8576. * @returns The scene
  8577. */
  8578. getScene(): Scene;
  8579. /**
  8580. * Callback defining a custom Projection Matrix Builder.
  8581. * This can be used to override the default projection matrix computation.
  8582. */
  8583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8584. /**
  8585. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8586. * @param matrix The materix to updated with the projection information
  8587. * @param viewMatrix The transform matrix of the light
  8588. * @param renderList The list of mesh to render in the map
  8589. * @returns The current light
  8590. */
  8591. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8592. /**
  8593. * Gets the current depth scale used in ESM.
  8594. * @returns The scale
  8595. */
  8596. getDepthScale(): number;
  8597. /**
  8598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8599. * @returns true if a cube texture needs to be use
  8600. */
  8601. needCube(): boolean;
  8602. /**
  8603. * Detects if the projection matrix requires to be recomputed this frame.
  8604. * @returns true if it requires to be recomputed otherwise, false.
  8605. */
  8606. needProjectionMatrixCompute(): boolean;
  8607. /**
  8608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8609. */
  8610. forceProjectionMatrixCompute(): void;
  8611. /**
  8612. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8615. */
  8616. getShadowDirection(faceIndex?: number): Vector3;
  8617. /**
  8618. * Gets the minZ used for shadow according to both the scene and the light.
  8619. * @param activeCamera The camera we are returning the min for
  8620. * @returns the depth min z
  8621. */
  8622. getDepthMinZ(activeCamera: Camera): number;
  8623. /**
  8624. * Gets the maxZ used for shadow according to both the scene and the light.
  8625. * @param activeCamera The camera we are returning the max for
  8626. * @returns the depth max z
  8627. */
  8628. getDepthMaxZ(activeCamera: Camera): number;
  8629. }
  8630. /**
  8631. * Base implementation IShadowLight
  8632. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8633. */
  8634. export abstract class ShadowLight extends Light implements IShadowLight {
  8635. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8636. protected _position: Vector3;
  8637. protected _setPosition(value: Vector3): void;
  8638. /**
  8639. * Sets the position the shadow will be casted from. Also use as the light position for both
  8640. * point and spot lights.
  8641. */
  8642. /**
  8643. * Sets the position the shadow will be casted from. Also use as the light position for both
  8644. * point and spot lights.
  8645. */
  8646. position: Vector3;
  8647. protected _direction: Vector3;
  8648. protected _setDirection(value: Vector3): void;
  8649. /**
  8650. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8651. * Also use as the light direction on spot and directional lights.
  8652. */
  8653. /**
  8654. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8655. * Also use as the light direction on spot and directional lights.
  8656. */
  8657. direction: Vector3;
  8658. private _shadowMinZ;
  8659. /**
  8660. * Gets the shadow projection clipping minimum z value.
  8661. */
  8662. /**
  8663. * Sets the shadow projection clipping minimum z value.
  8664. */
  8665. shadowMinZ: number;
  8666. private _shadowMaxZ;
  8667. /**
  8668. * Sets the shadow projection clipping maximum z value.
  8669. */
  8670. /**
  8671. * Gets the shadow projection clipping maximum z value.
  8672. */
  8673. shadowMaxZ: number;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. private _needProjectionMatrixCompute;
  8688. /**
  8689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8691. */
  8692. computeTransformedInformation(): boolean;
  8693. /**
  8694. * Return the depth scale used for the shadow map.
  8695. * @returns the depth scale.
  8696. */
  8697. getDepthScale(): number;
  8698. /**
  8699. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8702. */
  8703. getShadowDirection(faceIndex?: number): Vector3;
  8704. /**
  8705. * Returns the ShadowLight absolute position in the World.
  8706. * @returns the position vector in world space
  8707. */
  8708. getAbsolutePosition(): Vector3;
  8709. /**
  8710. * Sets the ShadowLight direction toward the passed target.
  8711. * @param target The point to target in local space
  8712. * @returns the updated ShadowLight direction
  8713. */
  8714. setDirectionToTarget(target: Vector3): Vector3;
  8715. /**
  8716. * Returns the light rotation in euler definition.
  8717. * @returns the x y z rotation in local space.
  8718. */
  8719. getRotation(): Vector3;
  8720. /**
  8721. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8722. * @returns true if a cube texture needs to be use
  8723. */
  8724. needCube(): boolean;
  8725. /**
  8726. * Detects if the projection matrix requires to be recomputed this frame.
  8727. * @returns true if it requires to be recomputed otherwise, false.
  8728. */
  8729. needProjectionMatrixCompute(): boolean;
  8730. /**
  8731. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8732. */
  8733. forceProjectionMatrixCompute(): void;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _isSynchronized(): boolean;
  8738. /**
  8739. * Computes the world matrix of the node
  8740. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8741. * @returns the world matrix
  8742. */
  8743. computeWorldMatrix(force?: boolean): Matrix;
  8744. /**
  8745. * Gets the minZ used for shadow according to both the scene and the light.
  8746. * @param activeCamera The camera we are returning the min for
  8747. * @returns the depth min z
  8748. */
  8749. getDepthMinZ(activeCamera: Camera): number;
  8750. /**
  8751. * Gets the maxZ used for shadow according to both the scene and the light.
  8752. * @param activeCamera The camera we are returning the max for
  8753. * @returns the depth max z
  8754. */
  8755. getDepthMaxZ(activeCamera: Camera): number;
  8756. /**
  8757. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8758. * @param matrix The materix to updated with the projection information
  8759. * @param viewMatrix The transform matrix of the light
  8760. * @param renderList The list of mesh to render in the map
  8761. * @returns The current light
  8762. */
  8763. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * "Static Class" containing the most commonly used helper while dealing with material for
  8769. * rendering purpose.
  8770. *
  8771. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8772. *
  8773. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8774. */
  8775. export class MaterialHelper {
  8776. /**
  8777. * Bind the current view position to an effect.
  8778. * @param effect The effect to be bound
  8779. * @param scene The scene the eyes position is used from
  8780. */
  8781. static BindEyePosition(effect: Effect, scene: Scene): void;
  8782. /**
  8783. * Helps preparing the defines values about the UVs in used in the effect.
  8784. * UVs are shared as much as we can accross channels in the shaders.
  8785. * @param texture The texture we are preparing the UVs for
  8786. * @param defines The defines to update
  8787. * @param key The channel key "diffuse", "specular"... used in the shader
  8788. */
  8789. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8790. /**
  8791. * Binds a texture matrix value to its corrsponding uniform
  8792. * @param texture The texture to bind the matrix for
  8793. * @param uniformBuffer The uniform buffer receivin the data
  8794. * @param key The channel key "diffuse", "specular"... used in the shader
  8795. */
  8796. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8797. /**
  8798. * Gets the current status of the fog (should it be enabled?)
  8799. * @param mesh defines the mesh to evaluate for fog support
  8800. * @param scene defines the hosting scene
  8801. * @returns true if fog must be enabled
  8802. */
  8803. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8804. /**
  8805. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8806. * @param mesh defines the current mesh
  8807. * @param scene defines the current scene
  8808. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8809. * @param pointsCloud defines if point cloud rendering has to be turned on
  8810. * @param fogEnabled defines if fog has to be turned on
  8811. * @param alphaTest defines if alpha testing has to be turned on
  8812. * @param defines defines the current list of defines
  8813. */
  8814. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8815. /**
  8816. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8817. * @param scene defines the current scene
  8818. * @param engine defines the current engine
  8819. * @param defines specifies the list of active defines
  8820. * @param useInstances defines if instances have to be turned on
  8821. * @param useClipPlane defines if clip plane have to be turned on
  8822. */
  8823. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8824. /**
  8825. * Prepares the defines for bones
  8826. * @param mesh The mesh containing the geometry data we will draw
  8827. * @param defines The defines to update
  8828. */
  8829. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8830. /**
  8831. * Prepares the defines for morph targets
  8832. * @param mesh The mesh containing the geometry data we will draw
  8833. * @param defines The defines to update
  8834. */
  8835. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8836. /**
  8837. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8838. * @param mesh The mesh containing the geometry data we will draw
  8839. * @param defines The defines to update
  8840. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8841. * @param useBones Precise whether bones should be used or not (override mesh info)
  8842. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8843. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8844. * @returns false if defines are considered not dirty and have not been checked
  8845. */
  8846. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8847. /**
  8848. * Prepares the defines related to multiview
  8849. * @param scene The scene we are intending to draw
  8850. * @param defines The defines to update
  8851. */
  8852. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8853. /**
  8854. * Prepares the defines related to the light information passed in parameter
  8855. * @param scene The scene we are intending to draw
  8856. * @param mesh The mesh the effect is compiling for
  8857. * @param light The light the effect is compiling for
  8858. * @param lightIndex The index of the light
  8859. * @param defines The defines to update
  8860. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8861. * @param state Defines the current state regarding what is needed (normals, etc...)
  8862. */
  8863. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8864. needNormals: boolean;
  8865. needRebuild: boolean;
  8866. shadowEnabled: boolean;
  8867. specularEnabled: boolean;
  8868. lightmapMode: boolean;
  8869. }): void;
  8870. /**
  8871. * Prepares the defines related to the light information passed in parameter
  8872. * @param scene The scene we are intending to draw
  8873. * @param mesh The mesh the effect is compiling for
  8874. * @param defines The defines to update
  8875. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8876. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8877. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8878. * @returns true if normals will be required for the rest of the effect
  8879. */
  8880. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8881. /**
  8882. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8883. * @param lightIndex defines the light index
  8884. * @param uniformsList The uniform list
  8885. * @param samplersList The sampler list
  8886. * @param projectedLightTexture defines if projected texture must be used
  8887. * @param uniformBuffersList defines an optional list of uniform buffers
  8888. */
  8889. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8890. /**
  8891. * Prepares the uniforms and samplers list to be used in the effect
  8892. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8893. * @param samplersList The sampler list
  8894. * @param defines The defines helping in the list generation
  8895. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8896. */
  8897. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8898. /**
  8899. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8900. * @param defines The defines to update while falling back
  8901. * @param fallbacks The authorized effect fallbacks
  8902. * @param maxSimultaneousLights The maximum number of lights allowed
  8903. * @param rank the current rank of the Effect
  8904. * @returns The newly affected rank
  8905. */
  8906. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8907. private static _TmpMorphInfluencers;
  8908. /**
  8909. * Prepares the list of attributes required for morph targets according to the effect defines.
  8910. * @param attribs The current list of supported attribs
  8911. * @param mesh The mesh to prepare the morph targets attributes for
  8912. * @param influencers The number of influencers
  8913. */
  8914. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8915. /**
  8916. * Prepares the list of attributes required for morph targets according to the effect defines.
  8917. * @param attribs The current list of supported attribs
  8918. * @param mesh The mesh to prepare the morph targets attributes for
  8919. * @param defines The current Defines of the effect
  8920. */
  8921. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8922. /**
  8923. * Prepares the list of attributes required for bones according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param mesh The mesh to prepare the bones attributes for
  8926. * @param defines The current Defines of the effect
  8927. * @param fallbacks The current efffect fallback strategy
  8928. */
  8929. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8930. /**
  8931. * Check and prepare the list of attributes required for instances according to the effect defines.
  8932. * @param attribs The current list of supported attribs
  8933. * @param defines The current MaterialDefines of the effect
  8934. */
  8935. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8936. /**
  8937. * Add the list of attributes required for instances to the attribs array.
  8938. * @param attribs The current list of supported attribs
  8939. */
  8940. static PushAttributesForInstances(attribs: string[]): void;
  8941. /**
  8942. * Binds the light shadow information to the effect for the given mesh.
  8943. * @param light The light containing the generator
  8944. * @param scene The scene the lights belongs to
  8945. * @param mesh The mesh we are binding the information to render
  8946. * @param lightIndex The light index in the effect used to render the mesh
  8947. * @param effect The effect we are binding the data to
  8948. */
  8949. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8950. /**
  8951. * Binds the light information to the effect.
  8952. * @param light The light containing the generator
  8953. * @param effect The effect we are binding the data to
  8954. * @param lightIndex The light index in the effect used to render
  8955. */
  8956. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8957. /**
  8958. * Binds the lights information from the scene to the effect for the given mesh.
  8959. * @param light Light to bind
  8960. * @param lightIndex Light index
  8961. * @param scene The scene where the light belongs to
  8962. * @param mesh The mesh we are binding the information to render
  8963. * @param effect The effect we are binding the data to
  8964. * @param useSpecular Defines if specular is supported
  8965. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8966. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8967. */
  8968. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param scene The scene the lights belongs to
  8972. * @param mesh The mesh we are binding the information to render
  8973. * @param effect The effect we are binding the data to
  8974. * @param defines The generated defines for the effect
  8975. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. private static _tempFogColor;
  8981. /**
  8982. * Binds the fog information from the scene to the effect for the given mesh.
  8983. * @param scene The scene the lights belongs to
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. * @param linearSpace Defines if the fog effect is applied in linear space
  8987. */
  8988. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8989. /**
  8990. * Binds the bones information from the mesh to the effect.
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param effect The effect we are binding the data to
  8993. */
  8994. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8995. /**
  8996. * Binds the morph targets information from the mesh to the effect.
  8997. * @param abstractMesh The mesh we are binding the information to render
  8998. * @param effect The effect we are binding the data to
  8999. */
  9000. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9001. /**
  9002. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9003. * @param defines The generated defines used in the effect
  9004. * @param effect The effect we are binding the data to
  9005. * @param scene The scene we are willing to render with logarithmic scale for
  9006. */
  9007. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9008. /**
  9009. * Binds the clip plane information from the scene to the effect.
  9010. * @param scene The scene the clip plane information are extracted from
  9011. * @param effect The effect we are binding the data to
  9012. */
  9013. static BindClipPlane(effect: Effect, scene: Scene): void;
  9014. }
  9015. }
  9016. declare module BABYLON {
  9017. /** @hidden */
  9018. export var packingFunctions: {
  9019. name: string;
  9020. shader: string;
  9021. };
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var shadowMapPixelShader: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var bonesDeclaration: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var morphTargetsVertexGlobalDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var morphTargetsVertexDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var instancesDeclaration: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var helperFunctions: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var morphTargetsVertex: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var instancesVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var bonesVertex: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var shadowMapVertexShader: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /** @hidden */
  9095. export var depthBoxBlurPixelShader: {
  9096. name: string;
  9097. shader: string;
  9098. };
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9103. */
  9104. export interface ICustomShaderOptions {
  9105. /**
  9106. * Gets or sets the custom shader name to use
  9107. */
  9108. shaderName: string;
  9109. /**
  9110. * The list of attribute names used in the shader
  9111. */
  9112. attributes?: string[];
  9113. /**
  9114. * The list of unifrom names used in the shader
  9115. */
  9116. uniforms?: string[];
  9117. /**
  9118. * The list of sampler names used in the shader
  9119. */
  9120. samplers?: string[];
  9121. /**
  9122. * The list of defines used in the shader
  9123. */
  9124. defines?: string[];
  9125. }
  9126. /**
  9127. * Interface to implement to create a shadow generator compatible with BJS.
  9128. */
  9129. export interface IShadowGenerator {
  9130. /**
  9131. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9132. * @returns The render target texture if present otherwise, null
  9133. */
  9134. getShadowMap(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9137. * @returns The render target texture if the shadow map is present otherwise, null
  9138. */
  9139. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9140. /**
  9141. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9142. * @param subMesh The submesh we want to render in the shadow map
  9143. * @param useInstances Defines wether will draw in the map using instances
  9144. * @returns true if ready otherwise, false
  9145. */
  9146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9147. /**
  9148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9149. * @param defines Defines of the material we want to update
  9150. * @param lightIndex Index of the light in the enabled light list of the material
  9151. */
  9152. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9153. /**
  9154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9155. * defined in the generator but impacting the effect).
  9156. * It implies the unifroms available on the materials are the standard BJS ones.
  9157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9158. * @param effect The effect we are binfing the information for
  9159. */
  9160. bindShadowLight(lightIndex: string, effect: Effect): void;
  9161. /**
  9162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9163. * (eq to shadow prjection matrix * light transform matrix)
  9164. * @returns The transform matrix used to create the shadow map
  9165. */
  9166. getTransformMatrix(): Matrix;
  9167. /**
  9168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9169. * Cube and 2D textures for instance.
  9170. */
  9171. recreateShadowMap(): void;
  9172. /**
  9173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9174. * @param onCompiled Callback triggered at the and of the effects compilation
  9175. * @param options Sets of optional options forcing the compilation with different modes
  9176. */
  9177. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9178. useInstances: boolean;
  9179. }>): void;
  9180. /**
  9181. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9182. * @param options Sets of optional options forcing the compilation with different modes
  9183. * @returns A promise that resolves when the compilation completes
  9184. */
  9185. forceCompilationAsync(options?: Partial<{
  9186. useInstances: boolean;
  9187. }>): Promise<void>;
  9188. /**
  9189. * Serializes the shadow generator setup to a json object.
  9190. * @returns The serialized JSON object
  9191. */
  9192. serialize(): any;
  9193. /**
  9194. * Disposes the Shadow map and related Textures and effects.
  9195. */
  9196. dispose(): void;
  9197. }
  9198. /**
  9199. * Default implementation IShadowGenerator.
  9200. * This is the main object responsible of generating shadows in the framework.
  9201. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9202. */
  9203. export class ShadowGenerator implements IShadowGenerator {
  9204. /**
  9205. * Shadow generator mode None: no filtering applied.
  9206. */
  9207. static readonly FILTER_NONE: number;
  9208. /**
  9209. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9215. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9216. */
  9217. static readonly FILTER_POISSONSAMPLING: number;
  9218. /**
  9219. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9220. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9221. */
  9222. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9223. /**
  9224. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9225. * edge artifacts on steep falloff.
  9226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9227. */
  9228. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9231. * edge artifacts on steep falloff.
  9232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9233. */
  9234. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9235. /**
  9236. * Shadow generator mode PCF: Percentage Closer Filtering
  9237. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9238. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9239. */
  9240. static readonly FILTER_PCF: number;
  9241. /**
  9242. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9244. * Contact Hardening
  9245. */
  9246. static readonly FILTER_PCSS: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Highest Quality.
  9250. *
  9251. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9252. *
  9253. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9254. */
  9255. static readonly QUALITY_HIGH: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * Good tradeoff for quality/perf cross devices
  9259. *
  9260. * Execute PCF on a 3*3 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9263. */
  9264. static readonly QUALITY_MEDIUM: number;
  9265. /**
  9266. * Reserved for PCF and PCSS
  9267. * The lowest quality but the fastest.
  9268. *
  9269. * Execute PCF on a 1*1 kernel.
  9270. *
  9271. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9272. */
  9273. static readonly QUALITY_LOW: number;
  9274. /** Gets or sets the custom shader name to use */
  9275. customShaderOptions: ICustomShaderOptions;
  9276. /**
  9277. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9278. */
  9279. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9280. /**
  9281. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9282. */
  9283. onAfterShadowMapRenderObservable: Observable<Effect>;
  9284. /**
  9285. * Observable triggered before a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9287. */
  9288. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. /**
  9290. * Observable triggered after a mesh is rendered in the shadow map.
  9291. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9292. */
  9293. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9294. private _bias;
  9295. /**
  9296. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9297. */
  9298. /**
  9299. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9300. */
  9301. bias: number;
  9302. private _normalBias;
  9303. /**
  9304. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9305. */
  9306. /**
  9307. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9308. */
  9309. normalBias: number;
  9310. private _blurBoxOffset;
  9311. /**
  9312. * Gets the blur box offset: offset applied during the blur pass.
  9313. * Only useful if useKernelBlur = false
  9314. */
  9315. /**
  9316. * Sets the blur box offset: offset applied during the blur pass.
  9317. * Only useful if useKernelBlur = false
  9318. */
  9319. blurBoxOffset: number;
  9320. private _blurScale;
  9321. /**
  9322. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9323. * 2 means half of the size.
  9324. */
  9325. /**
  9326. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9327. * 2 means half of the size.
  9328. */
  9329. blurScale: number;
  9330. private _blurKernel;
  9331. /**
  9332. * Gets the blur kernel: kernel size of the blur pass.
  9333. * Only useful if useKernelBlur = true
  9334. */
  9335. /**
  9336. * Sets the blur kernel: kernel size of the blur pass.
  9337. * Only useful if useKernelBlur = true
  9338. */
  9339. blurKernel: number;
  9340. private _useKernelBlur;
  9341. /**
  9342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9344. */
  9345. /**
  9346. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9347. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9348. */
  9349. useKernelBlur: boolean;
  9350. private _depthScale;
  9351. /**
  9352. * Gets the depth scale used in ESM mode.
  9353. */
  9354. /**
  9355. * Sets the depth scale used in ESM mode.
  9356. * This can override the scale stored on the light.
  9357. */
  9358. depthScale: number;
  9359. private _filter;
  9360. /**
  9361. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9362. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9363. */
  9364. /**
  9365. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9366. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9367. */
  9368. filter: number;
  9369. /**
  9370. * Gets if the current filter is set to Poisson Sampling.
  9371. */
  9372. /**
  9373. * Sets the current filter to Poisson Sampling.
  9374. */
  9375. usePoissonSampling: boolean;
  9376. /**
  9377. * Gets if the current filter is set to ESM.
  9378. */
  9379. /**
  9380. * Sets the current filter is to ESM.
  9381. */
  9382. useExponentialShadowMap: boolean;
  9383. /**
  9384. * Gets if the current filter is set to filtered ESM.
  9385. */
  9386. /**
  9387. * Gets if the current filter is set to filtered ESM.
  9388. */
  9389. useBlurExponentialShadowMap: boolean;
  9390. /**
  9391. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9392. * exponential to prevent steep falloff artifacts).
  9393. */
  9394. /**
  9395. * Sets the current filter to "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. useCloseExponentialShadowMap: boolean;
  9399. /**
  9400. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9401. * exponential to prevent steep falloff artifacts).
  9402. */
  9403. /**
  9404. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9405. * exponential to prevent steep falloff artifacts).
  9406. */
  9407. useBlurCloseExponentialShadowMap: boolean;
  9408. /**
  9409. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9410. */
  9411. /**
  9412. * Sets the current filter to "PCF" (percentage closer filtering).
  9413. */
  9414. usePercentageCloserFiltering: boolean;
  9415. private _filteringQuality;
  9416. /**
  9417. * Gets the PCF or PCSS Quality.
  9418. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9419. */
  9420. /**
  9421. * Sets the PCF or PCSS Quality.
  9422. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9423. */
  9424. filteringQuality: number;
  9425. /**
  9426. * Gets if the current filter is set to "PCSS" (contact hardening).
  9427. */
  9428. /**
  9429. * Sets the current filter to "PCSS" (contact hardening).
  9430. */
  9431. useContactHardeningShadow: boolean;
  9432. private _contactHardeningLightSizeUVRatio;
  9433. /**
  9434. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9435. * Using a ratio helps keeping shape stability independently of the map size.
  9436. *
  9437. * It does not account for the light projection as it was having too much
  9438. * instability during the light setup or during light position changes.
  9439. *
  9440. * Only valid if useContactHardeningShadow is true.
  9441. */
  9442. /**
  9443. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9444. * Using a ratio helps keeping shape stability independently of the map size.
  9445. *
  9446. * It does not account for the light projection as it was having too much
  9447. * instability during the light setup or during light position changes.
  9448. *
  9449. * Only valid if useContactHardeningShadow is true.
  9450. */
  9451. contactHardeningLightSizeUVRatio: number;
  9452. private _darkness;
  9453. /** Gets or sets the actual darkness of a shadow */
  9454. darkness: number;
  9455. /**
  9456. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9457. * 0 means strongest and 1 would means no shadow.
  9458. * @returns the darkness.
  9459. */
  9460. getDarkness(): number;
  9461. /**
  9462. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9463. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9464. * @returns the shadow generator allowing fluent coding.
  9465. */
  9466. setDarkness(darkness: number): ShadowGenerator;
  9467. private _transparencyShadow;
  9468. /** Gets or sets the ability to have transparent shadow */
  9469. transparencyShadow: boolean;
  9470. /**
  9471. * Sets the ability to have transparent shadow (boolean).
  9472. * @param transparent True if transparent else False
  9473. * @returns the shadow generator allowing fluent coding
  9474. */
  9475. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9476. private _shadowMap;
  9477. private _shadowMap2;
  9478. /**
  9479. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9480. * @returns The render target texture if present otherwise, null
  9481. */
  9482. getShadowMap(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9485. * @returns The render target texture if the shadow map is present otherwise, null
  9486. */
  9487. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9488. /**
  9489. * Gets the class name of that object
  9490. * @returns "ShadowGenerator"
  9491. */
  9492. getClassName(): string;
  9493. /**
  9494. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9495. * @param mesh Mesh to add
  9496. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9497. * @returns the Shadow Generator itself
  9498. */
  9499. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9500. /**
  9501. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9502. * @param mesh Mesh to remove
  9503. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9504. * @returns the Shadow Generator itself
  9505. */
  9506. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9507. /**
  9508. * Controls the extent to which the shadows fade out at the edge of the frustum
  9509. * Used only by directionals and spots
  9510. */
  9511. frustumEdgeFalloff: number;
  9512. private _light;
  9513. /**
  9514. * Returns the associated light object.
  9515. * @returns the light generating the shadow
  9516. */
  9517. getLight(): IShadowLight;
  9518. /**
  9519. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9520. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9521. * It might on the other hand introduce peter panning.
  9522. */
  9523. forceBackFacesOnly: boolean;
  9524. private _scene;
  9525. private _lightDirection;
  9526. private _effect;
  9527. private _viewMatrix;
  9528. private _projectionMatrix;
  9529. private _transformMatrix;
  9530. private _cachedPosition;
  9531. private _cachedDirection;
  9532. private _cachedDefines;
  9533. private _currentRenderID;
  9534. private _boxBlurPostprocess;
  9535. private _kernelBlurXPostprocess;
  9536. private _kernelBlurYPostprocess;
  9537. private _blurPostProcesses;
  9538. private _mapSize;
  9539. private _currentFaceIndex;
  9540. private _currentFaceIndexCache;
  9541. private _textureType;
  9542. private _defaultTextureMatrix;
  9543. /** @hidden */
  9544. static _SceneComponentInitialization: (scene: Scene) => void;
  9545. /**
  9546. * Creates a ShadowGenerator object.
  9547. * A ShadowGenerator is the required tool to use the shadows.
  9548. * Each light casting shadows needs to use its own ShadowGenerator.
  9549. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9550. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9551. * @param light The light object generating the shadows.
  9552. * @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.
  9553. */
  9554. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9555. private _initializeGenerator;
  9556. private _initializeShadowMap;
  9557. private _initializeBlurRTTAndPostProcesses;
  9558. private _renderForShadowMap;
  9559. private _renderSubMeshForShadowMap;
  9560. private _applyFilterValues;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param onCompiled Callback triggered at the and of the effects compilation
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. */
  9566. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): void;
  9569. /**
  9570. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9571. * @param options Sets of optional options forcing the compilation with different modes
  9572. * @returns A promise that resolves when the compilation completes
  9573. */
  9574. forceCompilationAsync(options?: Partial<{
  9575. useInstances: boolean;
  9576. }>): Promise<void>;
  9577. /**
  9578. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9579. * @param subMesh The submesh we want to render in the shadow map
  9580. * @param useInstances Defines wether will draw in the map using instances
  9581. * @returns true if ready otherwise, false
  9582. */
  9583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9584. /**
  9585. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9586. * @param defines Defines of the material we want to update
  9587. * @param lightIndex Index of the light in the enabled light list of the material
  9588. */
  9589. prepareDefines(defines: any, lightIndex: number): void;
  9590. /**
  9591. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9592. * defined in the generator but impacting the effect).
  9593. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9594. * @param effect The effect we are binfing the information for
  9595. */
  9596. bindShadowLight(lightIndex: string, effect: Effect): void;
  9597. /**
  9598. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9599. * (eq to shadow prjection matrix * light transform matrix)
  9600. * @returns The transform matrix used to create the shadow map
  9601. */
  9602. getTransformMatrix(): Matrix;
  9603. /**
  9604. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9605. * Cube and 2D textures for instance.
  9606. */
  9607. recreateShadowMap(): void;
  9608. private _disposeBlurPostProcesses;
  9609. private _disposeRTTandPostProcesses;
  9610. /**
  9611. * Disposes the ShadowGenerator.
  9612. * Returns nothing.
  9613. */
  9614. dispose(): void;
  9615. /**
  9616. * Serializes the shadow generator setup to a json object.
  9617. * @returns The serialized JSON object
  9618. */
  9619. serialize(): any;
  9620. /**
  9621. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9622. * @param parsedShadowGenerator The JSON object to parse
  9623. * @param scene The scene to create the shadow map for
  9624. * @returns The parsed shadow generator
  9625. */
  9626. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9627. }
  9628. }
  9629. declare module BABYLON {
  9630. /**
  9631. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9632. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9633. * 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.
  9634. */
  9635. export abstract class Light extends Node {
  9636. /**
  9637. * Falloff Default: light is falling off following the material specification:
  9638. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9639. */
  9640. static readonly FALLOFF_DEFAULT: number;
  9641. /**
  9642. * Falloff Physical: light is falling off following the inverse squared distance law.
  9643. */
  9644. static readonly FALLOFF_PHYSICAL: number;
  9645. /**
  9646. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9647. * to enhance interoperability with other engines.
  9648. */
  9649. static readonly FALLOFF_GLTF: number;
  9650. /**
  9651. * Falloff Standard: light is falling off like in the standard material
  9652. * to enhance interoperability with other materials.
  9653. */
  9654. static readonly FALLOFF_STANDARD: number;
  9655. /**
  9656. * If every light affecting the material is in this lightmapMode,
  9657. * material.lightmapTexture adds or multiplies
  9658. * (depends on material.useLightmapAsShadowmap)
  9659. * after every other light calculations.
  9660. */
  9661. static readonly LIGHTMAP_DEFAULT: number;
  9662. /**
  9663. * material.lightmapTexture as only diffuse lighting from this light
  9664. * adds only specular lighting from this light
  9665. * adds dynamic shadows
  9666. */
  9667. static readonly LIGHTMAP_SPECULAR: number;
  9668. /**
  9669. * material.lightmapTexture as only lighting
  9670. * no light calculation from this light
  9671. * only adds dynamic shadows from this light
  9672. */
  9673. static readonly LIGHTMAP_SHADOWSONLY: number;
  9674. /**
  9675. * Each light type uses the default quantity according to its type:
  9676. * point/spot lights use luminous intensity
  9677. * directional lights use illuminance
  9678. */
  9679. static readonly INTENSITYMODE_AUTOMATIC: number;
  9680. /**
  9681. * lumen (lm)
  9682. */
  9683. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9684. /**
  9685. * candela (lm/sr)
  9686. */
  9687. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9688. /**
  9689. * lux (lm/m^2)
  9690. */
  9691. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9692. /**
  9693. * nit (cd/m^2)
  9694. */
  9695. static readonly INTENSITYMODE_LUMINANCE: number;
  9696. /**
  9697. * Light type const id of the point light.
  9698. */
  9699. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9700. /**
  9701. * Light type const id of the directional light.
  9702. */
  9703. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9704. /**
  9705. * Light type const id of the spot light.
  9706. */
  9707. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9708. /**
  9709. * Light type const id of the hemispheric light.
  9710. */
  9711. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9712. /**
  9713. * Diffuse gives the basic color to an object.
  9714. */
  9715. diffuse: Color3;
  9716. /**
  9717. * Specular produces a highlight color on an object.
  9718. * Note: This is note affecting PBR materials.
  9719. */
  9720. specular: Color3;
  9721. /**
  9722. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9723. * falling off base on range or angle.
  9724. * This can be set to any values in Light.FALLOFF_x.
  9725. *
  9726. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9727. * other types of materials.
  9728. */
  9729. falloffType: number;
  9730. /**
  9731. * Strength of the light.
  9732. * Note: By default it is define in the framework own unit.
  9733. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9734. */
  9735. intensity: number;
  9736. private _range;
  9737. protected _inverseSquaredRange: number;
  9738. /**
  9739. * Defines how far from the source the light is impacting in scene units.
  9740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9741. */
  9742. /**
  9743. * Defines how far from the source the light is impacting in scene units.
  9744. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9745. */
  9746. range: number;
  9747. /**
  9748. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9749. * of light.
  9750. */
  9751. private _photometricScale;
  9752. private _intensityMode;
  9753. /**
  9754. * Gets the photometric scale used to interpret the intensity.
  9755. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9756. */
  9757. /**
  9758. * Sets the photometric scale used to interpret the intensity.
  9759. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9760. */
  9761. intensityMode: number;
  9762. private _radius;
  9763. /**
  9764. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9765. */
  9766. /**
  9767. * sets the light radius used by PBR Materials to simulate soft area lights.
  9768. */
  9769. radius: number;
  9770. private _renderPriority;
  9771. /**
  9772. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9773. * exceeding the number allowed of the materials.
  9774. */
  9775. renderPriority: number;
  9776. private _shadowEnabled;
  9777. /**
  9778. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9779. * the current shadow generator.
  9780. */
  9781. /**
  9782. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9783. * the current shadow generator.
  9784. */
  9785. shadowEnabled: boolean;
  9786. private _includedOnlyMeshes;
  9787. /**
  9788. * Gets the only meshes impacted by this light.
  9789. */
  9790. /**
  9791. * Sets the only meshes impacted by this light.
  9792. */
  9793. includedOnlyMeshes: AbstractMesh[];
  9794. private _excludedMeshes;
  9795. /**
  9796. * Gets the meshes not impacted by this light.
  9797. */
  9798. /**
  9799. * Sets the meshes not impacted by this light.
  9800. */
  9801. excludedMeshes: AbstractMesh[];
  9802. private _excludeWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are not impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are not impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. excludeWithLayerMask: number;
  9812. private _includeOnlyWithLayerMask;
  9813. /**
  9814. * Gets the layer id use to find what meshes are impacted by the light.
  9815. * Inactive if 0
  9816. */
  9817. /**
  9818. * Sets the layer id use to find what meshes are impacted by the light.
  9819. * Inactive if 0
  9820. */
  9821. includeOnlyWithLayerMask: number;
  9822. private _lightmapMode;
  9823. /**
  9824. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9825. */
  9826. /**
  9827. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9828. */
  9829. lightmapMode: number;
  9830. /**
  9831. * Shadow generator associted to the light.
  9832. * @hidden Internal use only.
  9833. */
  9834. _shadowGenerator: Nullable<IShadowGenerator>;
  9835. /**
  9836. * @hidden Internal use only.
  9837. */
  9838. _excludedMeshesIds: string[];
  9839. /**
  9840. * @hidden Internal use only.
  9841. */
  9842. _includedOnlyMeshesIds: string[];
  9843. /**
  9844. * The current light unifom buffer.
  9845. * @hidden Internal use only.
  9846. */
  9847. _uniformBuffer: UniformBuffer;
  9848. /**
  9849. * Creates a Light object in the scene.
  9850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9851. * @param name The firendly name of the light
  9852. * @param scene The scene the light belongs too
  9853. */
  9854. constructor(name: string, scene: Scene);
  9855. protected abstract _buildUniformLayout(): void;
  9856. /**
  9857. * Sets the passed Effect "effect" with the Light information.
  9858. * @param effect The effect to update
  9859. * @param lightIndex The index of the light in the effect to update
  9860. * @returns The light
  9861. */
  9862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9863. /**
  9864. * Sets the passed Effect "effect" with the Light information.
  9865. * @param effect The effect to update
  9866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9867. * @returns The light
  9868. */
  9869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9870. /**
  9871. * Returns the string "Light".
  9872. * @returns the class name
  9873. */
  9874. getClassName(): string;
  9875. /** @hidden */
  9876. readonly _isLight: boolean;
  9877. /**
  9878. * Converts the light information to a readable string for debug purpose.
  9879. * @param fullDetails Supports for multiple levels of logging within scene loading
  9880. * @returns the human readable light info
  9881. */
  9882. toString(fullDetails?: boolean): string;
  9883. /** @hidden */
  9884. protected _syncParentEnabledState(): void;
  9885. /**
  9886. * Set the enabled state of this node.
  9887. * @param value - the new enabled state
  9888. */
  9889. setEnabled(value: boolean): void;
  9890. /**
  9891. * Returns the Light associated shadow generator if any.
  9892. * @return the associated shadow generator.
  9893. */
  9894. getShadowGenerator(): Nullable<IShadowGenerator>;
  9895. /**
  9896. * Returns a Vector3, the absolute light position in the World.
  9897. * @returns the world space position of the light
  9898. */
  9899. getAbsolutePosition(): Vector3;
  9900. /**
  9901. * Specifies if the light will affect the passed mesh.
  9902. * @param mesh The mesh to test against the light
  9903. * @return true the mesh is affected otherwise, false.
  9904. */
  9905. canAffectMesh(mesh: AbstractMesh): boolean;
  9906. /**
  9907. * Sort function to order lights for rendering.
  9908. * @param a First Light object to compare to second.
  9909. * @param b Second Light object to compare first.
  9910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9911. */
  9912. static CompareLightsPriority(a: Light, b: Light): number;
  9913. /**
  9914. * Releases resources associated with this node.
  9915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9917. */
  9918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9919. /**
  9920. * Returns the light type ID (integer).
  9921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9922. */
  9923. getTypeID(): number;
  9924. /**
  9925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9926. * @returns the scaled intensity in intensity mode unit
  9927. */
  9928. getScaledIntensity(): number;
  9929. /**
  9930. * Returns a new Light object, named "name", from the current one.
  9931. * @param name The name of the cloned light
  9932. * @returns the new created light
  9933. */
  9934. clone(name: string): Nullable<Light>;
  9935. /**
  9936. * Serializes the current light into a Serialization object.
  9937. * @returns the serialized object.
  9938. */
  9939. serialize(): any;
  9940. /**
  9941. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9942. * This new light is named "name" and added to the passed scene.
  9943. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9944. * @param name The friendly name of the light
  9945. * @param scene The scene the new light will belong to
  9946. * @returns the constructor function
  9947. */
  9948. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9949. /**
  9950. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9951. * @param parsedLight The JSON representation of the light
  9952. * @param scene The scene to create the parsed light in
  9953. * @returns the created light after parsing
  9954. */
  9955. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9956. private _hookArrayForExcluded;
  9957. private _hookArrayForIncludedOnly;
  9958. private _resyncMeshes;
  9959. /**
  9960. * Forces the meshes to update their light related information in their rendering used effects
  9961. * @hidden Internal Use Only
  9962. */
  9963. _markMeshesAsLightDirty(): void;
  9964. /**
  9965. * Recomputes the cached photometric scale if needed.
  9966. */
  9967. private _computePhotometricScale;
  9968. /**
  9969. * Returns the Photometric Scale according to the light type and intensity mode.
  9970. */
  9971. private _getPhotometricScale;
  9972. /**
  9973. * Reorder the light in the scene according to their defined priority.
  9974. * @hidden Internal Use Only
  9975. */
  9976. _reorderLightsInScene(): void;
  9977. /**
  9978. * Prepares the list of defines specific to the light type.
  9979. * @param defines the list of defines
  9980. * @param lightIndex defines the index of the light for the effect
  9981. */
  9982. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9983. }
  9984. }
  9985. declare module BABYLON {
  9986. /**
  9987. * Interface used to define Action
  9988. */
  9989. export interface IAction {
  9990. /**
  9991. * Trigger for the action
  9992. */
  9993. trigger: number;
  9994. /** Options of the trigger */
  9995. triggerOptions: any;
  9996. /**
  9997. * Gets the trigger parameters
  9998. * @returns the trigger parameters
  9999. */
  10000. getTriggerParameter(): any;
  10001. /**
  10002. * Internal only - executes current action event
  10003. * @hidden
  10004. */
  10005. _executeCurrent(evt?: ActionEvent): void;
  10006. /**
  10007. * Serialize placeholder for child classes
  10008. * @param parent of child
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. /**
  10013. * Internal only
  10014. * @hidden
  10015. */
  10016. _prepare(): void;
  10017. /**
  10018. * Internal only - manager for action
  10019. * @hidden
  10020. */
  10021. _actionManager: AbstractActionManager;
  10022. /**
  10023. * Adds action to chain of actions, may be a DoNothingAction
  10024. * @param action defines the next action to execute
  10025. * @returns The action passed in
  10026. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10027. */
  10028. then(action: IAction): IAction;
  10029. }
  10030. /**
  10031. * The action to be carried out following a trigger
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10033. */
  10034. export class Action implements IAction {
  10035. /** the trigger, with or without parameters, for the action */
  10036. triggerOptions: any;
  10037. /**
  10038. * Trigger for the action
  10039. */
  10040. trigger: number;
  10041. /**
  10042. * Internal only - manager for action
  10043. * @hidden
  10044. */
  10045. _actionManager: ActionManager;
  10046. private _nextActiveAction;
  10047. private _child;
  10048. private _condition?;
  10049. private _triggerParameter;
  10050. /**
  10051. * An event triggered prior to action being executed.
  10052. */
  10053. onBeforeExecuteObservable: Observable<Action>;
  10054. /**
  10055. * Creates a new Action
  10056. * @param triggerOptions the trigger, with or without parameters, for the action
  10057. * @param condition an optional determinant of action
  10058. */
  10059. constructor(
  10060. /** the trigger, with or without parameters, for the action */
  10061. triggerOptions: any, condition?: Condition);
  10062. /**
  10063. * Internal only
  10064. * @hidden
  10065. */
  10066. _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */
  10076. _executeCurrent(evt?: ActionEvent): void;
  10077. /**
  10078. * Execute placeholder for child classes
  10079. * @param evt optional action event
  10080. */
  10081. execute(evt?: ActionEvent): void;
  10082. /**
  10083. * Skips to next active action
  10084. */
  10085. skipToNextActiveAction(): void;
  10086. /**
  10087. * Adds action to chain of actions, may be a DoNothingAction
  10088. * @param action defines the next action to execute
  10089. * @returns The action passed in
  10090. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10091. */
  10092. then(action: Action): Action;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */
  10097. _getProperty(propertyPath: string): string;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. _getEffectiveTarget(target: any, propertyPath: string): any;
  10103. /**
  10104. * Serialize placeholder for child classes
  10105. * @param parent of child
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. /**
  10110. * Internal only called by serialize
  10111. * @hidden
  10112. */
  10113. protected _serialize(serializedAction: any, parent?: any): any;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. static _SerializeValueAsString: (value: any) => string;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. static _GetTargetProperty: (target: Node | Scene) => {
  10124. name: string;
  10125. targetType: string;
  10126. value: string;
  10127. };
  10128. }
  10129. }
  10130. declare module BABYLON {
  10131. /**
  10132. * A Condition applied to an Action
  10133. */
  10134. export class Condition {
  10135. /**
  10136. * Internal only - manager for action
  10137. * @hidden
  10138. */
  10139. _actionManager: ActionManager;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _evaluationId: number;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _currentResult: boolean;
  10150. /**
  10151. * Creates a new Condition
  10152. * @param actionManager the manager of the action the condition is applied to
  10153. */
  10154. constructor(actionManager: ActionManager);
  10155. /**
  10156. * Check if the current condition is valid
  10157. * @returns a boolean
  10158. */
  10159. isValid(): boolean;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getProperty(propertyPath: string): string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _getEffectiveTarget(target: any, propertyPath: string): any;
  10170. /**
  10171. * Serialize placeholder for child classes
  10172. * @returns the serialized object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. protected _serialize(serializedCondition: any): any;
  10180. }
  10181. /**
  10182. * Defines specific conditional operators as extensions of Condition
  10183. */
  10184. export class ValueCondition extends Condition {
  10185. /** path to specify the property of the target the conditional operator uses */
  10186. propertyPath: string;
  10187. /** the value compared by the conditional operator against the current value of the property */
  10188. value: any;
  10189. /** the conditional operator, default ValueCondition.IsEqual */
  10190. operator: number;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsEqual;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsDifferent;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. private static _IsGreater;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsLesser;
  10211. /**
  10212. * returns the number for IsEqual
  10213. */
  10214. static readonly IsEqual: number;
  10215. /**
  10216. * Returns the number for IsDifferent
  10217. */
  10218. static readonly IsDifferent: number;
  10219. /**
  10220. * Returns the number for IsGreater
  10221. */
  10222. static readonly IsGreater: number;
  10223. /**
  10224. * Returns the number for IsLesser
  10225. */
  10226. static readonly IsLesser: number;
  10227. /**
  10228. * Internal only The action manager for the condition
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _target;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private _effectiveTarget;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. private _property;
  10247. /**
  10248. * Creates a new ValueCondition
  10249. * @param actionManager manager for the action the condition applies to
  10250. * @param target for the action
  10251. * @param propertyPath path to specify the property of the target the conditional operator uses
  10252. * @param value the value compared by the conditional operator against the current value of the property
  10253. * @param operator the conditional operator, default ValueCondition.IsEqual
  10254. */
  10255. constructor(actionManager: ActionManager, target: any,
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string,
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any,
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator?: number);
  10262. /**
  10263. * Compares the given value with the property value for the specified conditional operator
  10264. * @returns the result of the comparison
  10265. */
  10266. isValid(): boolean;
  10267. /**
  10268. * Serialize the ValueCondition into a JSON compatible object
  10269. * @returns serialization object
  10270. */
  10271. serialize(): any;
  10272. /**
  10273. * Gets the name of the conditional operator for the ValueCondition
  10274. * @param operator the conditional operator
  10275. * @returns the name
  10276. */
  10277. static GetOperatorName(operator: number): string;
  10278. }
  10279. /**
  10280. * Defines a predicate condition as an extension of Condition
  10281. */
  10282. export class PredicateCondition extends Condition {
  10283. /** defines the predicate function used to validate the condition */
  10284. predicate: () => boolean;
  10285. /**
  10286. * Internal only - manager for action
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Creates a new PredicateCondition
  10292. * @param actionManager manager for the action the condition applies to
  10293. * @param predicate defines the predicate function used to validate the condition
  10294. */
  10295. constructor(actionManager: ActionManager,
  10296. /** defines the predicate function used to validate the condition */
  10297. predicate: () => boolean);
  10298. /**
  10299. * @returns the validity of the predicate condition
  10300. */
  10301. isValid(): boolean;
  10302. }
  10303. /**
  10304. * Defines a state condition as an extension of Condition
  10305. */
  10306. export class StateCondition extends Condition {
  10307. /** Value to compare with target state */
  10308. value: string;
  10309. /**
  10310. * Internal only - manager for action
  10311. * @hidden
  10312. */
  10313. _actionManager: ActionManager;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. private _target;
  10319. /**
  10320. * Creates a new StateCondition
  10321. * @param actionManager manager for the action the condition applies to
  10322. * @param target of the condition
  10323. * @param value to compare with target state
  10324. */
  10325. constructor(actionManager: ActionManager, target: any,
  10326. /** Value to compare with target state */
  10327. value: string);
  10328. /**
  10329. * Gets a boolean indicating if the current condition is met
  10330. * @returns the validity of the state
  10331. */
  10332. isValid(): boolean;
  10333. /**
  10334. * Serialize the StateCondition into a JSON compatible object
  10335. * @returns serialization object
  10336. */
  10337. serialize(): any;
  10338. }
  10339. }
  10340. declare module BABYLON {
  10341. /**
  10342. * This defines an action responsible to toggle a boolean once triggered.
  10343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10344. */
  10345. export class SwitchBooleanAction extends Action {
  10346. /**
  10347. * The path to the boolean property in the target object
  10348. */
  10349. propertyPath: string;
  10350. private _target;
  10351. private _effectiveTarget;
  10352. private _property;
  10353. /**
  10354. * Instantiate the action
  10355. * @param triggerOptions defines the trigger options
  10356. * @param target defines the object containing the boolean
  10357. * @param propertyPath defines the path to the boolean property in the target object
  10358. * @param condition defines the trigger related conditions
  10359. */
  10360. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10361. /** @hidden */
  10362. _prepare(): void;
  10363. /**
  10364. * Execute the action toggle the boolean value.
  10365. */
  10366. execute(): void;
  10367. /**
  10368. * Serializes the actions and its related information.
  10369. * @param parent defines the object to serialize in
  10370. * @returns the serialized object
  10371. */
  10372. serialize(parent: any): any;
  10373. }
  10374. /**
  10375. * This defines an action responsible to set a the state field of the target
  10376. * to a desired value once triggered.
  10377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10378. */
  10379. export class SetStateAction extends Action {
  10380. /**
  10381. * The value to store in the state field.
  10382. */
  10383. value: string;
  10384. private _target;
  10385. /**
  10386. * Instantiate the action
  10387. * @param triggerOptions defines the trigger options
  10388. * @param target defines the object containing the state property
  10389. * @param value defines the value to store in the state field
  10390. * @param condition defines the trigger related conditions
  10391. */
  10392. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10393. /**
  10394. * Execute the action and store the value on the target state property.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to set a property of the target
  10406. * to a desired value once triggered.
  10407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10408. */
  10409. export class SetValueAction extends Action {
  10410. /**
  10411. * The path of the property to set in the target.
  10412. */
  10413. propertyPath: string;
  10414. /**
  10415. * The value to set in the property
  10416. */
  10417. value: any;
  10418. private _target;
  10419. private _effectiveTarget;
  10420. private _property;
  10421. /**
  10422. * Instantiate the action
  10423. * @param triggerOptions defines the trigger options
  10424. * @param target defines the object containing the property
  10425. * @param propertyPath defines the path of the property to set in the target
  10426. * @param value defines the value to set in the property
  10427. * @param condition defines the trigger related conditions
  10428. */
  10429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10430. /** @hidden */
  10431. _prepare(): void;
  10432. /**
  10433. * Execute the action and set the targetted property to the desired value.
  10434. */
  10435. execute(): void;
  10436. /**
  10437. * Serializes the actions and its related information.
  10438. * @param parent defines the object to serialize in
  10439. * @returns the serialized object
  10440. */
  10441. serialize(parent: any): any;
  10442. }
  10443. /**
  10444. * This defines an action responsible to increment the target value
  10445. * to a desired value once triggered.
  10446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10447. */
  10448. export class IncrementValueAction extends Action {
  10449. /**
  10450. * The path of the property to increment in the target.
  10451. */
  10452. propertyPath: string;
  10453. /**
  10454. * The value we should increment the property by.
  10455. */
  10456. value: any;
  10457. private _target;
  10458. private _effectiveTarget;
  10459. private _property;
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param target defines the object containing the property
  10464. * @param propertyPath defines the path of the property to increment in the target
  10465. * @param value defines the value value we should increment the property by
  10466. * @param condition defines the trigger related conditions
  10467. */
  10468. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10469. /** @hidden */
  10470. _prepare(): void;
  10471. /**
  10472. * Execute the action and increment the target of the value amount.
  10473. */
  10474. execute(): void;
  10475. /**
  10476. * Serializes the actions and its related information.
  10477. * @param parent defines the object to serialize in
  10478. * @returns the serialized object
  10479. */
  10480. serialize(parent: any): any;
  10481. }
  10482. /**
  10483. * This defines an action responsible to start an animation once triggered.
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10485. */
  10486. export class PlayAnimationAction extends Action {
  10487. /**
  10488. * Where the animation should start (animation frame)
  10489. */
  10490. from: number;
  10491. /**
  10492. * Where the animation should stop (animation frame)
  10493. */
  10494. to: number;
  10495. /**
  10496. * Define if the animation should loop or stop after the first play.
  10497. */
  10498. loop?: boolean;
  10499. private _target;
  10500. /**
  10501. * Instantiate the action
  10502. * @param triggerOptions defines the trigger options
  10503. * @param target defines the target animation or animation name
  10504. * @param from defines from where the animation should start (animation frame)
  10505. * @param end defines where the animation should stop (animation frame)
  10506. * @param loop defines if the animation should loop or stop after the first play
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action and play the animation.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to stop an animation once triggered.
  10525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10526. */
  10527. export class StopAnimationAction extends Action {
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the target animation or animation name
  10533. * @param condition defines the trigger related conditions
  10534. */
  10535. constructor(triggerOptions: any, target: any, condition?: Condition);
  10536. /** @hidden */
  10537. _prepare(): void;
  10538. /**
  10539. * Execute the action and stop the animation.
  10540. */
  10541. execute(): void;
  10542. /**
  10543. * Serializes the actions and its related information.
  10544. * @param parent defines the object to serialize in
  10545. * @returns the serialized object
  10546. */
  10547. serialize(parent: any): any;
  10548. }
  10549. /**
  10550. * This defines an action responsible that does nothing once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class DoNothingAction extends Action {
  10554. /**
  10555. * Instantiate the action
  10556. * @param triggerOptions defines the trigger options
  10557. * @param condition defines the trigger related conditions
  10558. */
  10559. constructor(triggerOptions?: any, condition?: Condition);
  10560. /**
  10561. * Execute the action and do nothing.
  10562. */
  10563. execute(): void;
  10564. /**
  10565. * Serializes the actions and its related information.
  10566. * @param parent defines the object to serialize in
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. }
  10571. /**
  10572. * This defines an action responsible to trigger several actions once triggered.
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10574. */
  10575. export class CombineAction extends Action {
  10576. /**
  10577. * The list of aggregated animations to run.
  10578. */
  10579. children: Action[];
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param children defines the list of aggregated animations to run
  10584. * @param condition defines the trigger related conditions
  10585. */
  10586. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10587. /** @hidden */
  10588. _prepare(): void;
  10589. /**
  10590. * Execute the action and executes all the aggregated actions.
  10591. */
  10592. execute(evt: ActionEvent): void;
  10593. /**
  10594. * Serializes the actions and its related information.
  10595. * @param parent defines the object to serialize in
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. }
  10600. /**
  10601. * This defines an action responsible to run code (external event) once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class ExecuteCodeAction extends Action {
  10605. /**
  10606. * The callback function to run.
  10607. */
  10608. func: (evt: ActionEvent) => void;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param func defines the callback function to run
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10616. /**
  10617. * Execute the action and run the attached code.
  10618. */
  10619. execute(evt: ActionEvent): void;
  10620. }
  10621. /**
  10622. * This defines an action responsible to set the parent property of the target once triggered.
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10624. */
  10625. export class SetParentAction extends Action {
  10626. private _parent;
  10627. private _target;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the target containing the parent property
  10632. * @param parent defines from where the animation should start (animation frame)
  10633. * @param condition defines the trigger related conditions
  10634. */
  10635. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10636. /** @hidden */
  10637. _prepare(): void;
  10638. /**
  10639. * Execute the action and set the parent property.
  10640. */
  10641. execute(): void;
  10642. /**
  10643. * Serializes the actions and its related information.
  10644. * @param parent defines the object to serialize in
  10645. * @returns the serialized object
  10646. */
  10647. serialize(parent: any): any;
  10648. }
  10649. }
  10650. declare module BABYLON {
  10651. /**
  10652. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10653. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10655. */
  10656. export class ActionManager extends AbstractActionManager {
  10657. /**
  10658. * Nothing
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly NothingTrigger: number;
  10662. /**
  10663. * On pick
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickTrigger: number;
  10667. /**
  10668. * On left pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnLeftPickTrigger: number;
  10672. /**
  10673. * On right pick
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnRightPickTrigger: number;
  10677. /**
  10678. * On center pick
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnCenterPickTrigger: number;
  10682. /**
  10683. * On pick down
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnPickDownTrigger: number;
  10687. /**
  10688. * On double pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnDoublePickTrigger: number;
  10692. /**
  10693. * On pick up
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnPickUpTrigger: number;
  10697. /**
  10698. * On pick out.
  10699. * This trigger will only be raised if you also declared a OnPickDown
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnPickOutTrigger: number;
  10703. /**
  10704. * On long press
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnLongPressTrigger: number;
  10708. /**
  10709. * On pointer over
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPointerOverTrigger: number;
  10713. /**
  10714. * On pointer out
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPointerOutTrigger: number;
  10718. /**
  10719. * On every frame
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnEveryFrameTrigger: number;
  10723. /**
  10724. * On intersection enter
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnIntersectionEnterTrigger: number;
  10728. /**
  10729. * On intersection exit
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnIntersectionExitTrigger: number;
  10733. /**
  10734. * On key down
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnKeyDownTrigger: number;
  10738. /**
  10739. * On key up
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnKeyUpTrigger: number;
  10743. private _scene;
  10744. /**
  10745. * Creates a new action manager
  10746. * @param scene defines the hosting scene
  10747. */
  10748. constructor(scene: Scene);
  10749. /**
  10750. * Releases all associated resources
  10751. */
  10752. dispose(): void;
  10753. /**
  10754. * Gets hosting scene
  10755. * @returns the hosting scene
  10756. */
  10757. getScene(): Scene;
  10758. /**
  10759. * Does this action manager handles actions of any of the given triggers
  10760. * @param triggers defines the triggers to be tested
  10761. * @return a boolean indicating whether one (or more) of the triggers is handled
  10762. */
  10763. hasSpecificTriggers(triggers: number[]): boolean;
  10764. /**
  10765. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10766. * speed.
  10767. * @param triggerA defines the trigger to be tested
  10768. * @param triggerB defines the trigger to be tested
  10769. * @return a boolean indicating whether one (or more) of the triggers is handled
  10770. */
  10771. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10772. /**
  10773. * Does this action manager handles actions of a given trigger
  10774. * @param trigger defines the trigger to be tested
  10775. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10776. * @return whether the trigger is handled
  10777. */
  10778. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10779. /**
  10780. * Does this action manager has pointer triggers
  10781. */
  10782. readonly hasPointerTriggers: boolean;
  10783. /**
  10784. * Does this action manager has pick triggers
  10785. */
  10786. readonly hasPickTriggers: boolean;
  10787. /**
  10788. * Registers an action to this action manager
  10789. * @param action defines the action to be registered
  10790. * @return the action amended (prepared) after registration
  10791. */
  10792. registerAction(action: IAction): Nullable<IAction>;
  10793. /**
  10794. * Unregisters an action to this action manager
  10795. * @param action defines the action to be unregistered
  10796. * @return a boolean indicating whether the action has been unregistered
  10797. */
  10798. unregisterAction(action: IAction): Boolean;
  10799. /**
  10800. * Process a specific trigger
  10801. * @param trigger defines the trigger to process
  10802. * @param evt defines the event details to be processed
  10803. */
  10804. processTrigger(trigger: number, evt?: IActionEvent): void;
  10805. /** @hidden */
  10806. _getEffectiveTarget(target: any, propertyPath: string): any;
  10807. /** @hidden */
  10808. _getProperty(propertyPath: string): string;
  10809. /**
  10810. * Serialize this manager to a JSON object
  10811. * @param name defines the property name to store this manager
  10812. * @returns a JSON representation of this manager
  10813. */
  10814. serialize(name: string): any;
  10815. /**
  10816. * Creates a new ActionManager from a JSON data
  10817. * @param parsedActions defines the JSON data to read from
  10818. * @param object defines the hosting mesh
  10819. * @param scene defines the hosting scene
  10820. */
  10821. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10822. /**
  10823. * Get a trigger name by index
  10824. * @param trigger defines the trigger index
  10825. * @returns a trigger name
  10826. */
  10827. static GetTriggerName(trigger: number): string;
  10828. }
  10829. }
  10830. declare module BABYLON {
  10831. /**
  10832. * Class representing a ray with position and direction
  10833. */
  10834. export class Ray {
  10835. /** origin point */
  10836. origin: Vector3;
  10837. /** direction */
  10838. direction: Vector3;
  10839. /** length of the ray */
  10840. length: number;
  10841. private static readonly TmpVector3;
  10842. private _tmpRay;
  10843. /**
  10844. * Creates a new ray
  10845. * @param origin origin point
  10846. * @param direction direction
  10847. * @param length length of the ray
  10848. */
  10849. constructor(
  10850. /** origin point */
  10851. origin: Vector3,
  10852. /** direction */
  10853. direction: Vector3,
  10854. /** length of the ray */
  10855. length?: number);
  10856. /**
  10857. * Checks if the ray intersects a box
  10858. * @param minimum bound of the box
  10859. * @param maximum bound of the box
  10860. * @param intersectionTreshold extra extend to be added to the box in all direction
  10861. * @returns if the box was hit
  10862. */
  10863. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10864. /**
  10865. * Checks if the ray intersects a box
  10866. * @param box the bounding box to check
  10867. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10868. * @returns if the box was hit
  10869. */
  10870. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10871. /**
  10872. * If the ray hits a sphere
  10873. * @param sphere the bounding sphere to check
  10874. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10875. * @returns true if it hits the sphere
  10876. */
  10877. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10878. /**
  10879. * If the ray hits a triange
  10880. * @param vertex0 triangle vertex
  10881. * @param vertex1 triangle vertex
  10882. * @param vertex2 triangle vertex
  10883. * @returns intersection information if hit
  10884. */
  10885. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10886. /**
  10887. * Checks if ray intersects a plane
  10888. * @param plane the plane to check
  10889. * @returns the distance away it was hit
  10890. */
  10891. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10892. /**
  10893. * Calculate the intercept of a ray on a given axis
  10894. * @param axis to check 'x' | 'y' | 'z'
  10895. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10896. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10897. */
  10898. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10899. /**
  10900. * Checks if ray intersects a mesh
  10901. * @param mesh the mesh to check
  10902. * @param fastCheck if only the bounding box should checked
  10903. * @returns picking info of the intersecton
  10904. */
  10905. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10906. /**
  10907. * Checks if ray intersects a mesh
  10908. * @param meshes the meshes to check
  10909. * @param fastCheck if only the bounding box should checked
  10910. * @param results array to store result in
  10911. * @returns Array of picking infos
  10912. */
  10913. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10914. private _comparePickingInfo;
  10915. private static smallnum;
  10916. private static rayl;
  10917. /**
  10918. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10919. * @param sega the first point of the segment to test the intersection against
  10920. * @param segb the second point of the segment to test the intersection against
  10921. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10922. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10923. */
  10924. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10925. /**
  10926. * Update the ray from viewport position
  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 this ray updated
  10935. */
  10936. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * Creates a ray with origin and direction of 0,0,0
  10939. * @returns the new ray
  10940. */
  10941. static Zero(): Ray;
  10942. /**
  10943. * Creates a new ray from screen space and viewport
  10944. * @param x position
  10945. * @param y y position
  10946. * @param viewportWidth viewport width
  10947. * @param viewportHeight viewport height
  10948. * @param world world matrix
  10949. * @param view view matrix
  10950. * @param projection projection matrix
  10951. * @returns new ray
  10952. */
  10953. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10954. /**
  10955. * 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
  10956. * transformed to the given world matrix.
  10957. * @param origin The origin point
  10958. * @param end The end point
  10959. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10960. * @returns the new ray
  10961. */
  10962. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10963. /**
  10964. * Transforms a ray by a matrix
  10965. * @param ray ray to transform
  10966. * @param matrix matrix to apply
  10967. * @returns the resulting new ray
  10968. */
  10969. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10970. /**
  10971. * Transforms a ray by a matrix
  10972. * @param ray ray to transform
  10973. * @param matrix matrix to apply
  10974. * @param result ray to store result in
  10975. */
  10976. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10977. /**
  10978. * Unproject a ray from screen space to object space
  10979. * @param sourceX defines the screen space x coordinate to use
  10980. * @param sourceY defines the screen space y coordinate to use
  10981. * @param viewportWidth defines the current width of the viewport
  10982. * @param viewportHeight defines the current height of the viewport
  10983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10984. * @param view defines the view matrix to use
  10985. * @param projection defines the projection matrix to use
  10986. */
  10987. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10988. }
  10989. /**
  10990. * Type used to define predicate used to select faces when a mesh intersection is detected
  10991. */
  10992. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10993. interface Scene {
  10994. /** @hidden */
  10995. _tempPickingRay: Nullable<Ray>;
  10996. /** @hidden */
  10997. _cachedRayForTransform: Ray;
  10998. /** @hidden */
  10999. _pickWithRayInverseMatrix: Matrix;
  11000. /** @hidden */
  11001. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11002. /** @hidden */
  11003. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11004. }
  11005. }
  11006. declare module BABYLON {
  11007. /**
  11008. * Groups all the scene component constants in one place to ease maintenance.
  11009. * @hidden
  11010. */
  11011. export class SceneComponentConstants {
  11012. static readonly NAME_EFFECTLAYER: string;
  11013. static readonly NAME_LAYER: string;
  11014. static readonly NAME_LENSFLARESYSTEM: string;
  11015. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11016. static readonly NAME_PARTICLESYSTEM: string;
  11017. static readonly NAME_GAMEPAD: string;
  11018. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11019. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11020. static readonly NAME_DEPTHRENDERER: string;
  11021. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11022. static readonly NAME_SPRITE: string;
  11023. static readonly NAME_OUTLINERENDERER: string;
  11024. static readonly NAME_PROCEDURALTEXTURE: string;
  11025. static readonly NAME_SHADOWGENERATOR: string;
  11026. static readonly NAME_OCTREE: string;
  11027. static readonly NAME_PHYSICSENGINE: string;
  11028. static readonly NAME_AUDIO: string;
  11029. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11030. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11033. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11038. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11040. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11041. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11042. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11043. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11044. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11045. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11046. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11049. static readonly STEP_AFTERRENDER_AUDIO: number;
  11050. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11051. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11052. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11054. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11055. static readonly STEP_POINTERMOVE_SPRITE: number;
  11056. static readonly STEP_POINTERDOWN_SPRITE: number;
  11057. static readonly STEP_POINTERUP_SPRITE: number;
  11058. }
  11059. /**
  11060. * This represents a scene component.
  11061. *
  11062. * This is used to decouple the dependency the scene is having on the different workloads like
  11063. * layers, post processes...
  11064. */
  11065. export interface ISceneComponent {
  11066. /**
  11067. * The name of the component. Each component must have a unique name.
  11068. */
  11069. name: string;
  11070. /**
  11071. * The scene the component belongs to.
  11072. */
  11073. scene: Scene;
  11074. /**
  11075. * Register the component to one instance of a scene.
  11076. */
  11077. register(): void;
  11078. /**
  11079. * Rebuilds the elements related to this component in case of
  11080. * context lost for instance.
  11081. */
  11082. rebuild(): void;
  11083. /**
  11084. * Disposes the component and the associated ressources.
  11085. */
  11086. dispose(): void;
  11087. }
  11088. /**
  11089. * This represents a SERIALIZABLE scene component.
  11090. *
  11091. * This extends Scene Component to add Serialization methods on top.
  11092. */
  11093. export interface ISceneSerializableComponent extends ISceneComponent {
  11094. /**
  11095. * Adds all the elements from the container to the scene
  11096. * @param container the container holding the elements
  11097. */
  11098. addFromContainer(container: AbstractScene): void;
  11099. /**
  11100. * Removes all the elements in the container from the scene
  11101. * @param container contains the elements to remove
  11102. * @param dispose if the removed element should be disposed (default: false)
  11103. */
  11104. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11105. /**
  11106. * Serializes the component data to the specified json object
  11107. * @param serializationObject The object to serialize to
  11108. */
  11109. serialize(serializationObject: any): void;
  11110. }
  11111. /**
  11112. * Strong typing of a Mesh related stage step action
  11113. */
  11114. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11115. /**
  11116. * Strong typing of a Evaluate Sub Mesh related stage step action
  11117. */
  11118. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11119. /**
  11120. * Strong typing of a Active Mesh related stage step action
  11121. */
  11122. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11123. /**
  11124. * Strong typing of a Camera related stage step action
  11125. */
  11126. export type CameraStageAction = (camera: Camera) => void;
  11127. /**
  11128. * Strong typing of a Camera Frame buffer related stage step action
  11129. */
  11130. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11131. /**
  11132. * Strong typing of a Render Target related stage step action
  11133. */
  11134. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11135. /**
  11136. * Strong typing of a RenderingGroup related stage step action
  11137. */
  11138. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11139. /**
  11140. * Strong typing of a Mesh Render related stage step action
  11141. */
  11142. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11143. /**
  11144. * Strong typing of a simple stage step action
  11145. */
  11146. export type SimpleStageAction = () => void;
  11147. /**
  11148. * Strong typing of a render target action.
  11149. */
  11150. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11151. /**
  11152. * Strong typing of a pointer move action.
  11153. */
  11154. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11155. /**
  11156. * Strong typing of a pointer up/down action.
  11157. */
  11158. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11159. /**
  11160. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11161. * @hidden
  11162. */
  11163. export class Stage<T extends Function> extends Array<{
  11164. index: number;
  11165. component: ISceneComponent;
  11166. action: T;
  11167. }> {
  11168. /**
  11169. * Hide ctor from the rest of the world.
  11170. * @param items The items to add.
  11171. */
  11172. private constructor();
  11173. /**
  11174. * Creates a new Stage.
  11175. * @returns A new instance of a Stage
  11176. */
  11177. static Create<T extends Function>(): Stage<T>;
  11178. /**
  11179. * Registers a step in an ordered way in the targeted stage.
  11180. * @param index Defines the position to register the step in
  11181. * @param component Defines the component attached to the step
  11182. * @param action Defines the action to launch during the step
  11183. */
  11184. registerStep(index: number, component: ISceneComponent, action: T): void;
  11185. /**
  11186. * Clears all the steps from the stage.
  11187. */
  11188. clear(): void;
  11189. }
  11190. }
  11191. declare module BABYLON {
  11192. interface Scene {
  11193. /** @hidden */
  11194. _pointerOverSprite: Nullable<Sprite>;
  11195. /** @hidden */
  11196. _pickedDownSprite: Nullable<Sprite>;
  11197. /** @hidden */
  11198. _tempSpritePickingRay: Nullable<Ray>;
  11199. /**
  11200. * All of the sprite managers added to this scene
  11201. * @see http://doc.babylonjs.com/babylon101/sprites
  11202. */
  11203. spriteManagers: Array<ISpriteManager>;
  11204. /**
  11205. * An event triggered when sprites rendering is about to start
  11206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11207. */
  11208. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11209. /**
  11210. * An event triggered when sprites rendering is done
  11211. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11212. */
  11213. onAfterSpritesRenderingObservable: Observable<Scene>;
  11214. /** @hidden */
  11215. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /** Launch a ray to try to pick a sprite in the scene
  11217. * @param x position on screen
  11218. * @param y position on screen
  11219. * @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
  11220. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11221. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11222. * @returns a PickingInfo
  11223. */
  11224. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11225. /** Use the given ray to pick a sprite in the scene
  11226. * @param ray The ray (in world space) to use to pick meshes
  11227. * @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
  11228. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11230. * @returns a PickingInfo
  11231. */
  11232. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11233. /** @hidden */
  11234. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11235. /** Launch a ray to try to pick sprites in the scene
  11236. * @param x position on screen
  11237. * @param y position on screen
  11238. * @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
  11239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11240. * @returns a PickingInfo array
  11241. */
  11242. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11243. /** Use the given ray to pick sprites in the scene
  11244. * @param ray The ray (in world space) to use to pick meshes
  11245. * @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
  11246. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo array
  11248. */
  11249. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /**
  11251. * Force the sprite under the pointer
  11252. * @param sprite defines the sprite to use
  11253. */
  11254. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11255. /**
  11256. * Gets the sprite under the pointer
  11257. * @returns a Sprite or null if no sprite is under the pointer
  11258. */
  11259. getPointerOverSprite(): Nullable<Sprite>;
  11260. }
  11261. /**
  11262. * Defines the sprite scene component responsible to manage sprites
  11263. * in a given scene.
  11264. */
  11265. export class SpriteSceneComponent implements ISceneComponent {
  11266. /**
  11267. * The component name helpfull to identify the component in the list of scene components.
  11268. */
  11269. readonly name: string;
  11270. /**
  11271. * The scene the component belongs to.
  11272. */
  11273. scene: Scene;
  11274. /** @hidden */
  11275. private _spritePredicate;
  11276. /**
  11277. * Creates a new instance of the component for the given scene
  11278. * @param scene Defines the scene to register the component in
  11279. */
  11280. constructor(scene: Scene);
  11281. /**
  11282. * Registers the component in a given scene
  11283. */
  11284. register(): void;
  11285. /**
  11286. * Rebuilds the elements related to this component in case of
  11287. * context lost for instance.
  11288. */
  11289. rebuild(): void;
  11290. /**
  11291. * Disposes the component and the associated ressources.
  11292. */
  11293. dispose(): void;
  11294. private _pickSpriteButKeepRay;
  11295. private _pointerMove;
  11296. private _pointerDown;
  11297. private _pointerUp;
  11298. }
  11299. }
  11300. declare module BABYLON {
  11301. /** @hidden */
  11302. export var fogFragmentDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module BABYLON {
  11308. /** @hidden */
  11309. export var fogFragment: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module BABYLON {
  11315. /** @hidden */
  11316. export var spritesPixelShader: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var fogVertexDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var spritesVertexShader: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /**
  11337. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11338. */
  11339. export interface ISpriteManager extends IDisposable {
  11340. /**
  11341. * Restricts the camera to viewing objects with the same layerMask.
  11342. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11343. */
  11344. layerMask: number;
  11345. /**
  11346. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11347. */
  11348. isPickable: boolean;
  11349. /**
  11350. * Specifies the rendering group id for this mesh (0 by default)
  11351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11352. */
  11353. renderingGroupId: number;
  11354. /**
  11355. * Defines the list of sprites managed by the manager.
  11356. */
  11357. sprites: Array<Sprite>;
  11358. /**
  11359. * Tests the intersection of a sprite with a specific ray.
  11360. * @param ray The ray we are sending to test the collision
  11361. * @param camera The camera space we are sending rays in
  11362. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11363. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11364. * @returns picking info or null.
  11365. */
  11366. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11367. /**
  11368. * Intersects the sprites with a ray
  11369. * @param ray defines the ray to intersect with
  11370. * @param camera defines the current active camera
  11371. * @param predicate defines a predicate used to select candidate sprites
  11372. * @returns null if no hit or a PickingInfo array
  11373. */
  11374. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11375. /**
  11376. * Renders the list of sprites on screen.
  11377. */
  11378. render(): void;
  11379. }
  11380. /**
  11381. * Class used to manage multiple sprites on the same spritesheet
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. export class SpriteManager implements ISpriteManager {
  11385. /** defines the manager's name */
  11386. name: string;
  11387. /** Gets the list of sprites */
  11388. sprites: Sprite[];
  11389. /** Gets or sets the rendering group id (0 by default) */
  11390. renderingGroupId: number;
  11391. /** Gets or sets camera layer mask */
  11392. layerMask: number;
  11393. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11394. fogEnabled: boolean;
  11395. /** Gets or sets a boolean indicating if the sprites are pickable */
  11396. isPickable: boolean;
  11397. /** Defines the default width of a cell in the spritesheet */
  11398. cellWidth: number;
  11399. /** Defines the default height of a cell in the spritesheet */
  11400. cellHeight: number;
  11401. /** Associative array from JSON sprite data file */
  11402. private _cellData;
  11403. /** Array of sprite names from JSON sprite data file */
  11404. private _spriteMap;
  11405. /** True when packed cell data from JSON file is ready*/
  11406. private _packedAndReady;
  11407. /**
  11408. * An event triggered when the manager is disposed.
  11409. */
  11410. onDisposeObservable: Observable<SpriteManager>;
  11411. private _onDisposeObserver;
  11412. /**
  11413. * Callback called when the manager is disposed
  11414. */
  11415. onDispose: () => void;
  11416. private _capacity;
  11417. private _fromPacked;
  11418. private _spriteTexture;
  11419. private _epsilon;
  11420. private _scene;
  11421. private _vertexData;
  11422. private _buffer;
  11423. private _vertexBuffers;
  11424. private _indexBuffer;
  11425. private _effectBase;
  11426. private _effectFog;
  11427. /**
  11428. * Gets or sets the spritesheet texture
  11429. */
  11430. texture: Texture;
  11431. /**
  11432. * Creates a new sprite manager
  11433. * @param name defines the manager's name
  11434. * @param imgUrl defines the sprite sheet url
  11435. * @param capacity defines the maximum allowed number of sprites
  11436. * @param cellSize defines the size of a sprite cell
  11437. * @param scene defines the hosting scene
  11438. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11439. * @param samplingMode defines the smapling mode to use with spritesheet
  11440. * @param fromPacked set to false; do not alter
  11441. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11442. */
  11443. constructor(
  11444. /** defines the manager's name */
  11445. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11446. private _makePacked;
  11447. private _appendSpriteVertex;
  11448. /**
  11449. * Intersects the sprites with a ray
  11450. * @param ray defines the ray to intersect with
  11451. * @param camera defines the current active camera
  11452. * @param predicate defines a predicate used to select candidate sprites
  11453. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11454. * @returns null if no hit or a PickingInfo
  11455. */
  11456. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11457. /**
  11458. * Intersects the sprites with a ray
  11459. * @param ray defines the ray to intersect with
  11460. * @param camera defines the current active camera
  11461. * @param predicate defines a predicate used to select candidate sprites
  11462. * @returns null if no hit or a PickingInfo array
  11463. */
  11464. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11465. /**
  11466. * Render all child sprites
  11467. */
  11468. render(): void;
  11469. /**
  11470. * Release associated resources
  11471. */
  11472. dispose(): void;
  11473. }
  11474. }
  11475. declare module BABYLON {
  11476. /**
  11477. * Class used to represent a sprite
  11478. * @see http://doc.babylonjs.com/babylon101/sprites
  11479. */
  11480. export class Sprite {
  11481. /** defines the name */
  11482. name: string;
  11483. /** Gets or sets the current world position */
  11484. position: Vector3;
  11485. /** Gets or sets the main color */
  11486. color: Color4;
  11487. /** Gets or sets the width */
  11488. width: number;
  11489. /** Gets or sets the height */
  11490. height: number;
  11491. /** Gets or sets rotation angle */
  11492. angle: number;
  11493. /** Gets or sets the cell index in the sprite sheet */
  11494. cellIndex: number;
  11495. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11496. cellRef: string;
  11497. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11498. invertU: number;
  11499. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11500. invertV: number;
  11501. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11502. disposeWhenFinishedAnimating: boolean;
  11503. /** Gets the list of attached animations */
  11504. animations: Animation[];
  11505. /** Gets or sets a boolean indicating if the sprite can be picked */
  11506. isPickable: boolean;
  11507. /**
  11508. * Gets or sets the associated action manager
  11509. */
  11510. actionManager: Nullable<ActionManager>;
  11511. private _animationStarted;
  11512. private _loopAnimation;
  11513. private _fromIndex;
  11514. private _toIndex;
  11515. private _delay;
  11516. private _direction;
  11517. private _manager;
  11518. private _time;
  11519. private _onAnimationEnd;
  11520. /**
  11521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11522. */
  11523. isVisible: boolean;
  11524. /**
  11525. * Gets or sets the sprite size
  11526. */
  11527. size: number;
  11528. /**
  11529. * Creates a new Sprite
  11530. * @param name defines the name
  11531. * @param manager defines the manager
  11532. */
  11533. constructor(
  11534. /** defines the name */
  11535. name: string, manager: ISpriteManager);
  11536. /**
  11537. * Starts an animation
  11538. * @param from defines the initial key
  11539. * @param to defines the end key
  11540. * @param loop defines if the animation must loop
  11541. * @param delay defines the start delay (in ms)
  11542. * @param onAnimationEnd defines a callback to call when animation ends
  11543. */
  11544. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11545. /** Stops current animation (if any) */
  11546. stopAnimation(): void;
  11547. /** @hidden */
  11548. _animate(deltaTime: number): void;
  11549. /** Release associated resources */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Information about the result of picking within a scene
  11556. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11557. */
  11558. export class PickingInfo {
  11559. /** @hidden */
  11560. _pickingUnavailable: boolean;
  11561. /**
  11562. * If the pick collided with an object
  11563. */
  11564. hit: boolean;
  11565. /**
  11566. * Distance away where the pick collided
  11567. */
  11568. distance: number;
  11569. /**
  11570. * The location of pick collision
  11571. */
  11572. pickedPoint: Nullable<Vector3>;
  11573. /**
  11574. * The mesh corresponding the the pick collision
  11575. */
  11576. pickedMesh: Nullable<AbstractMesh>;
  11577. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11578. bu: number;
  11579. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11580. bv: number;
  11581. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11582. faceId: number;
  11583. /** Id of the the submesh that was picked */
  11584. subMeshId: number;
  11585. /** If a sprite was picked, this will be the sprite the pick collided with */
  11586. pickedSprite: Nullable<Sprite>;
  11587. /**
  11588. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11589. */
  11590. originMesh: Nullable<AbstractMesh>;
  11591. /**
  11592. * The ray that was used to perform the picking.
  11593. */
  11594. ray: Nullable<Ray>;
  11595. /**
  11596. * Gets the normal correspodning to the face the pick collided with
  11597. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11598. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11599. * @returns The normal correspodning to the face the pick collided with
  11600. */
  11601. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11602. /**
  11603. * Gets the texture coordinates of where the pick occured
  11604. * @returns the vector containing the coordnates of the texture
  11605. */
  11606. getTextureCoordinates(): Nullable<Vector2>;
  11607. }
  11608. }
  11609. declare module BABYLON {
  11610. /**
  11611. * Gather the list of pointer event types as constants.
  11612. */
  11613. export class PointerEventTypes {
  11614. /**
  11615. * 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.
  11616. */
  11617. static readonly POINTERDOWN: number;
  11618. /**
  11619. * The pointerup event is fired when a pointer is no longer active.
  11620. */
  11621. static readonly POINTERUP: number;
  11622. /**
  11623. * The pointermove event is fired when a pointer changes coordinates.
  11624. */
  11625. static readonly POINTERMOVE: number;
  11626. /**
  11627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11628. */
  11629. static readonly POINTERWHEEL: number;
  11630. /**
  11631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11632. */
  11633. static readonly POINTERPICK: number;
  11634. /**
  11635. * The pointertap event is fired when a the object has been touched and released without drag.
  11636. */
  11637. static readonly POINTERTAP: number;
  11638. /**
  11639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11640. */
  11641. static readonly POINTERDOUBLETAP: number;
  11642. }
  11643. /**
  11644. * Base class of pointer info types.
  11645. */
  11646. export class PointerInfoBase {
  11647. /**
  11648. * Defines the type of event (PointerEventTypes)
  11649. */
  11650. type: number;
  11651. /**
  11652. * Defines the related dom event
  11653. */
  11654. event: PointerEvent | MouseWheelEvent;
  11655. /**
  11656. * Instantiates the base class of pointers info.
  11657. * @param type Defines the type of event (PointerEventTypes)
  11658. * @param event Defines the related dom event
  11659. */
  11660. constructor(
  11661. /**
  11662. * Defines the type of event (PointerEventTypes)
  11663. */
  11664. type: number,
  11665. /**
  11666. * Defines the related dom event
  11667. */
  11668. event: PointerEvent | MouseWheelEvent);
  11669. }
  11670. /**
  11671. * This class is used to store pointer related info for the onPrePointerObservable event.
  11672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11673. */
  11674. export class PointerInfoPre extends PointerInfoBase {
  11675. /**
  11676. * Ray from a pointer if availible (eg. 6dof controller)
  11677. */
  11678. ray: Nullable<Ray>;
  11679. /**
  11680. * Defines the local position of the pointer on the canvas.
  11681. */
  11682. localPosition: Vector2;
  11683. /**
  11684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11685. */
  11686. skipOnPointerObservable: boolean;
  11687. /**
  11688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11689. * @param type Defines the type of event (PointerEventTypes)
  11690. * @param event Defines the related dom event
  11691. * @param localX Defines the local x coordinates of the pointer when the event occured
  11692. * @param localY Defines the local y coordinates of the pointer when the event occured
  11693. */
  11694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11695. }
  11696. /**
  11697. * This type contains all the data related to a pointer event in Babylon.js.
  11698. * 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.
  11699. */
  11700. export class PointerInfo extends PointerInfoBase {
  11701. /**
  11702. * Defines the picking info associated to the info (if any)\
  11703. */
  11704. pickInfo: Nullable<PickingInfo>;
  11705. /**
  11706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11707. * @param type Defines the type of event (PointerEventTypes)
  11708. * @param event Defines the related dom event
  11709. * @param pickInfo Defines the picking info associated to the info (if any)\
  11710. */
  11711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11712. /**
  11713. * Defines the picking info associated to the info (if any)\
  11714. */
  11715. pickInfo: Nullable<PickingInfo>);
  11716. }
  11717. /**
  11718. * Data relating to a touch event on the screen.
  11719. */
  11720. export interface PointerTouch {
  11721. /**
  11722. * X coordinate of touch.
  11723. */
  11724. x: number;
  11725. /**
  11726. * Y coordinate of touch.
  11727. */
  11728. y: number;
  11729. /**
  11730. * Id of touch. Unique for each finger.
  11731. */
  11732. pointerId: number;
  11733. /**
  11734. * Event type passed from DOM.
  11735. */
  11736. type: any;
  11737. }
  11738. }
  11739. declare module BABYLON {
  11740. /**
  11741. * Manage the mouse inputs to control the movement of a free camera.
  11742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11743. */
  11744. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11745. /**
  11746. * Define if touch is enabled in the mouse input
  11747. */
  11748. touchEnabled: boolean;
  11749. /**
  11750. * Defines the camera the input is attached to.
  11751. */
  11752. camera: FreeCamera;
  11753. /**
  11754. * Defines the buttons associated with the input to handle camera move.
  11755. */
  11756. buttons: number[];
  11757. /**
  11758. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11759. */
  11760. angularSensibility: number;
  11761. private _pointerInput;
  11762. private _onMouseMove;
  11763. private _observer;
  11764. private previousPosition;
  11765. /**
  11766. * Observable for when a pointer move event occurs containing the move offset
  11767. */
  11768. onPointerMovedObservable: Observable<{
  11769. offsetX: number;
  11770. offsetY: number;
  11771. }>;
  11772. /**
  11773. * @hidden
  11774. * If the camera should be rotated automatically based on pointer movement
  11775. */
  11776. _allowCameraRotation: boolean;
  11777. /**
  11778. * Manage the mouse inputs to control the movement of a free camera.
  11779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11780. * @param touchEnabled Defines if touch is enabled or not
  11781. */
  11782. constructor(
  11783. /**
  11784. * Define if touch is enabled in the mouse input
  11785. */
  11786. touchEnabled?: boolean);
  11787. /**
  11788. * Attach the input controls to a specific dom element to get the input from.
  11789. * @param element Defines the element the controls should be listened from
  11790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11791. */
  11792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11793. /**
  11794. * Called on JS contextmenu event.
  11795. * Override this method to provide functionality.
  11796. */
  11797. protected onContextMenu(evt: PointerEvent): void;
  11798. /**
  11799. * Detach the current controls from the specified dom element.
  11800. * @param element Defines the element to stop listening the inputs from
  11801. */
  11802. detachControl(element: Nullable<HTMLElement>): void;
  11803. /**
  11804. * Gets the class name of the current intput.
  11805. * @returns the class name
  11806. */
  11807. getClassName(): string;
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. getSimpleName(): string;
  11813. }
  11814. }
  11815. declare module BABYLON {
  11816. /**
  11817. * Manage the touch inputs to control the movement of a free camera.
  11818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11819. */
  11820. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11821. /**
  11822. * Defines the camera the input is attached to.
  11823. */
  11824. camera: FreeCamera;
  11825. /**
  11826. * Defines the touch sensibility for rotation.
  11827. * The higher the faster.
  11828. */
  11829. touchAngularSensibility: number;
  11830. /**
  11831. * Defines the touch sensibility for move.
  11832. * The higher the faster.
  11833. */
  11834. touchMoveSensibility: number;
  11835. private _offsetX;
  11836. private _offsetY;
  11837. private _pointerPressed;
  11838. private _pointerInput;
  11839. private _observer;
  11840. private _onLostFocus;
  11841. /**
  11842. * Attach the input controls to a specific dom element to get the input from.
  11843. * @param element Defines the element the controls should be listened from
  11844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11845. */
  11846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11847. /**
  11848. * Detach the current controls from the specified dom element.
  11849. * @param element Defines the element to stop listening the inputs from
  11850. */
  11851. detachControl(element: Nullable<HTMLElement>): void;
  11852. /**
  11853. * Update the current camera state depending on the inputs that have been used this frame.
  11854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11855. */
  11856. checkInputs(): void;
  11857. /**
  11858. * Gets the class name of the current intput.
  11859. * @returns the class name
  11860. */
  11861. getClassName(): string;
  11862. /**
  11863. * Get the friendly name associated with the input class.
  11864. * @returns the input friendly name
  11865. */
  11866. getSimpleName(): string;
  11867. }
  11868. }
  11869. declare module BABYLON {
  11870. /**
  11871. * Default Inputs manager for the FreeCamera.
  11872. * It groups all the default supported inputs for ease of use.
  11873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11874. */
  11875. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11876. /**
  11877. * @hidden
  11878. */
  11879. _mouseInput: Nullable<FreeCameraMouseInput>;
  11880. /**
  11881. * Instantiates a new FreeCameraInputsManager.
  11882. * @param camera Defines the camera the inputs belong to
  11883. */
  11884. constructor(camera: FreeCamera);
  11885. /**
  11886. * Add keyboard input support to the input manager.
  11887. * @returns the current input manager
  11888. */
  11889. addKeyboard(): FreeCameraInputsManager;
  11890. /**
  11891. * Add mouse input support to the input manager.
  11892. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11893. * @returns the current input manager
  11894. */
  11895. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11896. /**
  11897. * Removes the mouse input support from the manager
  11898. * @returns the current input manager
  11899. */
  11900. removeMouse(): FreeCameraInputsManager;
  11901. /**
  11902. * Add touch input support to the input manager.
  11903. * @returns the current input manager
  11904. */
  11905. addTouch(): FreeCameraInputsManager;
  11906. /**
  11907. * Remove all attached input methods from a camera
  11908. */
  11909. clear(): void;
  11910. }
  11911. }
  11912. declare module BABYLON {
  11913. /**
  11914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11917. */
  11918. export class FreeCamera extends TargetCamera {
  11919. /**
  11920. * Define the collision ellipsoid of the camera.
  11921. * This is helpful to simulate a camera body like the player body around the camera
  11922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11923. */
  11924. ellipsoid: Vector3;
  11925. /**
  11926. * Define an offset for the position of the ellipsoid around the camera.
  11927. * This can be helpful to determine the center of the body near the gravity center of the body
  11928. * instead of its head.
  11929. */
  11930. ellipsoidOffset: Vector3;
  11931. /**
  11932. * Enable or disable collisions of the camera with the rest of the scene objects.
  11933. */
  11934. checkCollisions: boolean;
  11935. /**
  11936. * Enable or disable gravity on the camera.
  11937. */
  11938. applyGravity: boolean;
  11939. /**
  11940. * Define the input manager associated to the camera.
  11941. */
  11942. inputs: FreeCameraInputsManager;
  11943. /**
  11944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11945. * Higher values reduce sensitivity.
  11946. */
  11947. /**
  11948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11949. * Higher values reduce sensitivity.
  11950. */
  11951. angularSensibility: number;
  11952. /**
  11953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11954. */
  11955. keysUp: number[];
  11956. /**
  11957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11958. */
  11959. keysDown: number[];
  11960. /**
  11961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11962. */
  11963. keysLeft: number[];
  11964. /**
  11965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11966. */
  11967. keysRight: number[];
  11968. /**
  11969. * Event raised when the camera collide with a mesh in the scene.
  11970. */
  11971. onCollide: (collidedMesh: AbstractMesh) => void;
  11972. private _collider;
  11973. private _needMoveForGravity;
  11974. private _oldPosition;
  11975. private _diffPosition;
  11976. private _newPosition;
  11977. /** @hidden */
  11978. _localDirection: Vector3;
  11979. /** @hidden */
  11980. _transformedDirection: Vector3;
  11981. /**
  11982. * Instantiates a Free Camera.
  11983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11984. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11986. * @param name Define the name of the camera in the scene
  11987. * @param position Define the start position of the camera in the scene
  11988. * @param scene Define the scene the camera belongs to
  11989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11990. */
  11991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11992. /**
  11993. * Attached controls to the current camera.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Detach the current controls from the camera.
  12000. * The camera will stop reacting to inputs.
  12001. * @param element Defines the element to stop listening the inputs from
  12002. */
  12003. detachControl(element: HTMLElement): void;
  12004. private _collisionMask;
  12005. /**
  12006. * Define a collision mask to limit the list of object the camera can collide with
  12007. */
  12008. collisionMask: number;
  12009. /** @hidden */
  12010. _collideWithWorld(displacement: Vector3): void;
  12011. private _onCollisionPositionChange;
  12012. /** @hidden */
  12013. _checkInputs(): void;
  12014. /** @hidden */
  12015. _decideIfNeedsToMove(): boolean;
  12016. /** @hidden */
  12017. _updatePosition(): void;
  12018. /**
  12019. * Destroy the camera and release the current resources hold by it.
  12020. */
  12021. dispose(): void;
  12022. /**
  12023. * Gets the current object class name.
  12024. * @return the class name
  12025. */
  12026. getClassName(): string;
  12027. }
  12028. }
  12029. declare module BABYLON {
  12030. /**
  12031. * Represents a gamepad control stick position
  12032. */
  12033. export class StickValues {
  12034. /**
  12035. * The x component of the control stick
  12036. */
  12037. x: number;
  12038. /**
  12039. * The y component of the control stick
  12040. */
  12041. y: number;
  12042. /**
  12043. * Initializes the gamepad x and y control stick values
  12044. * @param x The x component of the gamepad control stick value
  12045. * @param y The y component of the gamepad control stick value
  12046. */
  12047. constructor(
  12048. /**
  12049. * The x component of the control stick
  12050. */
  12051. x: number,
  12052. /**
  12053. * The y component of the control stick
  12054. */
  12055. y: number);
  12056. }
  12057. /**
  12058. * An interface which manages callbacks for gamepad button changes
  12059. */
  12060. export interface GamepadButtonChanges {
  12061. /**
  12062. * Called when a gamepad has been changed
  12063. */
  12064. changed: boolean;
  12065. /**
  12066. * Called when a gamepad press event has been triggered
  12067. */
  12068. pressChanged: boolean;
  12069. /**
  12070. * Called when a touch event has been triggered
  12071. */
  12072. touchChanged: boolean;
  12073. /**
  12074. * Called when a value has changed
  12075. */
  12076. valueChanged: boolean;
  12077. }
  12078. /**
  12079. * Represents a gamepad
  12080. */
  12081. export class Gamepad {
  12082. /**
  12083. * The id of the gamepad
  12084. */
  12085. id: string;
  12086. /**
  12087. * The index of the gamepad
  12088. */
  12089. index: number;
  12090. /**
  12091. * The browser gamepad
  12092. */
  12093. browserGamepad: any;
  12094. /**
  12095. * Specifies what type of gamepad this represents
  12096. */
  12097. type: number;
  12098. private _leftStick;
  12099. private _rightStick;
  12100. /** @hidden */
  12101. _isConnected: boolean;
  12102. private _leftStickAxisX;
  12103. private _leftStickAxisY;
  12104. private _rightStickAxisX;
  12105. private _rightStickAxisY;
  12106. /**
  12107. * Triggered when the left control stick has been changed
  12108. */
  12109. private _onleftstickchanged;
  12110. /**
  12111. * Triggered when the right control stick has been changed
  12112. */
  12113. private _onrightstickchanged;
  12114. /**
  12115. * Represents a gamepad controller
  12116. */
  12117. static GAMEPAD: number;
  12118. /**
  12119. * Represents a generic controller
  12120. */
  12121. static GENERIC: number;
  12122. /**
  12123. * Represents an XBox controller
  12124. */
  12125. static XBOX: number;
  12126. /**
  12127. * Represents a pose-enabled controller
  12128. */
  12129. static POSE_ENABLED: number;
  12130. /**
  12131. * Represents an Dual Shock controller
  12132. */
  12133. static DUALSHOCK: number;
  12134. /**
  12135. * Specifies whether the left control stick should be Y-inverted
  12136. */
  12137. protected _invertLeftStickY: boolean;
  12138. /**
  12139. * Specifies if the gamepad has been connected
  12140. */
  12141. readonly isConnected: boolean;
  12142. /**
  12143. * Initializes the gamepad
  12144. * @param id The id of the gamepad
  12145. * @param index The index of the gamepad
  12146. * @param browserGamepad The browser gamepad
  12147. * @param leftStickX The x component of the left joystick
  12148. * @param leftStickY The y component of the left joystick
  12149. * @param rightStickX The x component of the right joystick
  12150. * @param rightStickY The y component of the right joystick
  12151. */
  12152. constructor(
  12153. /**
  12154. * The id of the gamepad
  12155. */
  12156. id: string,
  12157. /**
  12158. * The index of the gamepad
  12159. */
  12160. index: number,
  12161. /**
  12162. * The browser gamepad
  12163. */
  12164. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12165. /**
  12166. * Callback triggered when the left joystick has changed
  12167. * @param callback
  12168. */
  12169. onleftstickchanged(callback: (values: StickValues) => void): void;
  12170. /**
  12171. * Callback triggered when the right joystick has changed
  12172. * @param callback
  12173. */
  12174. onrightstickchanged(callback: (values: StickValues) => void): void;
  12175. /**
  12176. * Gets the left joystick
  12177. */
  12178. /**
  12179. * Sets the left joystick values
  12180. */
  12181. leftStick: StickValues;
  12182. /**
  12183. * Gets the right joystick
  12184. */
  12185. /**
  12186. * Sets the right joystick value
  12187. */
  12188. rightStick: StickValues;
  12189. /**
  12190. * Updates the gamepad joystick positions
  12191. */
  12192. update(): void;
  12193. /**
  12194. * Disposes the gamepad
  12195. */
  12196. dispose(): void;
  12197. }
  12198. /**
  12199. * Represents a generic gamepad
  12200. */
  12201. export class GenericPad extends Gamepad {
  12202. private _buttons;
  12203. private _onbuttondown;
  12204. private _onbuttonup;
  12205. /**
  12206. * Observable triggered when a button has been pressed
  12207. */
  12208. onButtonDownObservable: Observable<number>;
  12209. /**
  12210. * Observable triggered when a button has been released
  12211. */
  12212. onButtonUpObservable: Observable<number>;
  12213. /**
  12214. * Callback triggered when a button has been pressed
  12215. * @param callback Called when a button has been pressed
  12216. */
  12217. onbuttondown(callback: (buttonPressed: number) => void): void;
  12218. /**
  12219. * Callback triggered when a button has been released
  12220. * @param callback Called when a button has been released
  12221. */
  12222. onbuttonup(callback: (buttonReleased: number) => void): void;
  12223. /**
  12224. * Initializes the generic gamepad
  12225. * @param id The id of the generic gamepad
  12226. * @param index The index of the generic gamepad
  12227. * @param browserGamepad The browser gamepad
  12228. */
  12229. constructor(id: string, index: number, browserGamepad: any);
  12230. private _setButtonValue;
  12231. /**
  12232. * Updates the generic gamepad
  12233. */
  12234. update(): void;
  12235. /**
  12236. * Disposes the generic gamepad
  12237. */
  12238. dispose(): void;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. interface Engine {
  12243. /**
  12244. * Creates a raw texture
  12245. * @param data defines the data to store in the texture
  12246. * @param width defines the width of the texture
  12247. * @param height defines the height of the texture
  12248. * @param format defines the format of the data
  12249. * @param generateMipMaps defines if the engine should generate the mip levels
  12250. * @param invertY defines if data must be stored with Y axis inverted
  12251. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12252. * @param compression defines the compression used (null by default)
  12253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12254. * @returns the raw texture inside an InternalTexture
  12255. */
  12256. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12257. /**
  12258. * Update a raw texture
  12259. * @param texture defines the texture to update
  12260. * @param data defines the data to store in the texture
  12261. * @param format defines the format of the data
  12262. * @param invertY defines if data must be stored with Y axis inverted
  12263. */
  12264. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12265. /**
  12266. * Update a raw texture
  12267. * @param texture defines the texture to update
  12268. * @param data defines the data to store in the texture
  12269. * @param format defines the format of the data
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12273. */
  12274. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12275. /**
  12276. * Creates a new raw cube texture
  12277. * @param data defines the array of data to use to create each face
  12278. * @param size defines the size of the textures
  12279. * @param format defines the format of the data
  12280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12281. * @param generateMipMaps defines if the engine should generate the mip levels
  12282. * @param invertY defines if data must be stored with Y axis inverted
  12283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12284. * @param compression defines the compression used (null by default)
  12285. * @returns the cube texture as an InternalTexture
  12286. */
  12287. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12288. /**
  12289. * Update a raw cube texture
  12290. * @param texture defines the texture to udpdate
  12291. * @param data defines the data to store
  12292. * @param format defines the data format
  12293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12294. * @param invertY defines if data must be stored with Y axis inverted
  12295. */
  12296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12297. /**
  12298. * Update a raw cube texture
  12299. * @param texture defines the texture to udpdate
  12300. * @param data defines the data to store
  12301. * @param format defines the data format
  12302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param compression defines the compression used (null by default)
  12305. */
  12306. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12307. /**
  12308. * Update a raw cube texture
  12309. * @param texture defines the texture to udpdate
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12313. * @param invertY defines if data must be stored with Y axis inverted
  12314. * @param compression defines the compression used (null by default)
  12315. * @param level defines which level of the texture to update
  12316. */
  12317. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12318. /**
  12319. * Creates a new raw cube texture from a specified url
  12320. * @param url defines the url where the data is located
  12321. * @param scene defines the current scene
  12322. * @param size defines the size of the textures
  12323. * @param format defines the format of the data
  12324. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12325. * @param noMipmap defines if the engine should avoid generating the mip levels
  12326. * @param callback defines a callback used to extract texture data from loaded data
  12327. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12328. * @param onLoad defines a callback called when texture is loaded
  12329. * @param onError defines a callback called if there is an error
  12330. * @returns the cube texture as an InternalTexture
  12331. */
  12332. 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;
  12333. /**
  12334. * Creates a new raw cube texture from a specified url
  12335. * @param url defines the url where the data is located
  12336. * @param scene defines the current scene
  12337. * @param size defines the size of the textures
  12338. * @param format defines the format of the data
  12339. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12340. * @param noMipmap defines if the engine should avoid generating the mip levels
  12341. * @param callback defines a callback used to extract texture data from loaded data
  12342. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12343. * @param onLoad defines a callback called when texture is loaded
  12344. * @param onError defines a callback called if there is an error
  12345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12346. * @param invertY defines if data must be stored with Y axis inverted
  12347. * @returns the cube texture as an InternalTexture
  12348. */
  12349. 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;
  12350. /**
  12351. * Creates a new raw 3D texture
  12352. * @param data defines the data used to create the texture
  12353. * @param width defines the width of the texture
  12354. * @param height defines the height of the texture
  12355. * @param depth defines the depth of the texture
  12356. * @param format defines the format of the texture
  12357. * @param generateMipMaps defines if the engine must generate mip levels
  12358. * @param invertY defines if data must be stored with Y axis inverted
  12359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12360. * @param compression defines the compressed used (can be null)
  12361. * @param textureType defines the compressed used (can be null)
  12362. * @returns a new raw 3D texture (stored in an InternalTexture)
  12363. */
  12364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12365. /**
  12366. * Update a raw 3D texture
  12367. * @param texture defines the texture to update
  12368. * @param data defines the data to store
  12369. * @param format defines the data format
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. */
  12372. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12373. /**
  12374. * Update a raw 3D texture
  12375. * @param texture defines the texture to update
  12376. * @param data defines the data to store
  12377. * @param format defines the data format
  12378. * @param invertY defines if data must be stored with Y axis inverted
  12379. * @param compression defines the used compression (can be null)
  12380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12381. */
  12382. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12383. }
  12384. }
  12385. declare module BABYLON {
  12386. /**
  12387. * Raw texture can help creating a texture directly from an array of data.
  12388. * This can be super useful if you either get the data from an uncompressed source or
  12389. * if you wish to create your texture pixel by pixel.
  12390. */
  12391. export class RawTexture extends Texture {
  12392. /**
  12393. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12394. */
  12395. format: number;
  12396. private _engine;
  12397. /**
  12398. * Instantiates a new RawTexture.
  12399. * Raw texture can help creating a texture directly from an array of data.
  12400. * This can be super useful if you either get the data from an uncompressed source or
  12401. * if you wish to create your texture pixel by pixel.
  12402. * @param data define the array of data to use to create the texture
  12403. * @param width define the width of the texture
  12404. * @param height define the height of the texture
  12405. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12406. * @param scene define the scene the texture belongs to
  12407. * @param generateMipMaps define whether mip maps should be generated or not
  12408. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12409. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12410. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12411. */
  12412. constructor(data: ArrayBufferView, width: number, height: number,
  12413. /**
  12414. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12415. */
  12416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12417. /**
  12418. * Updates the texture underlying data.
  12419. * @param data Define the new data of the texture
  12420. */
  12421. update(data: ArrayBufferView): void;
  12422. /**
  12423. * Creates a luminance texture from some data.
  12424. * @param data Define the texture data
  12425. * @param width Define the width of the texture
  12426. * @param height Define the height of the texture
  12427. * @param scene Define the scene the texture belongs to
  12428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @returns the luminance texture
  12432. */
  12433. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12434. /**
  12435. * Creates a luminance alpha texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @returns the luminance alpha texture
  12444. */
  12445. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12446. /**
  12447. * Creates an alpha texture from some data.
  12448. * @param data Define the texture data
  12449. * @param width Define the width of the texture
  12450. * @param height Define the height of the texture
  12451. * @param scene Define the scene the texture belongs to
  12452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12455. * @returns the alpha texture
  12456. */
  12457. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12458. /**
  12459. * Creates a RGB texture from some data.
  12460. * @param data Define the texture data
  12461. * @param width Define the width of the texture
  12462. * @param height Define the height of the texture
  12463. * @param scene Define the scene the texture belongs to
  12464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12468. * @returns the RGB alpha texture
  12469. */
  12470. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12471. /**
  12472. * Creates a RGBA texture from some data.
  12473. * @param data Define the texture data
  12474. * @param width Define the width of the texture
  12475. * @param height Define the height of the texture
  12476. * @param scene Define the scene the texture belongs to
  12477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12481. * @returns the RGBA texture
  12482. */
  12483. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12484. /**
  12485. * Creates a R texture from some data.
  12486. * @param data Define the texture data
  12487. * @param width Define the width of the texture
  12488. * @param height Define the height of the texture
  12489. * @param scene Define the scene the texture belongs to
  12490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12494. * @returns the R texture
  12495. */
  12496. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Interface for the size containing width and height
  12502. */
  12503. export interface ISize {
  12504. /**
  12505. * Width
  12506. */
  12507. width: number;
  12508. /**
  12509. * Heighht
  12510. */
  12511. height: number;
  12512. }
  12513. /**
  12514. * Size containing widht and height
  12515. */
  12516. export class Size implements ISize {
  12517. /**
  12518. * Width
  12519. */
  12520. width: number;
  12521. /**
  12522. * Height
  12523. */
  12524. height: number;
  12525. /**
  12526. * Creates a Size object from the given width and height (floats).
  12527. * @param width width of the new size
  12528. * @param height height of the new size
  12529. */
  12530. constructor(width: number, height: number);
  12531. /**
  12532. * Returns a string with the Size width and height
  12533. * @returns a string with the Size width and height
  12534. */
  12535. toString(): string;
  12536. /**
  12537. * "Size"
  12538. * @returns the string "Size"
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Returns the Size hash code.
  12543. * @returns a hash code for a unique width and height
  12544. */
  12545. getHashCode(): number;
  12546. /**
  12547. * Updates the current size from the given one.
  12548. * @param src the given size
  12549. */
  12550. copyFrom(src: Size): void;
  12551. /**
  12552. * Updates in place the current Size from the given floats.
  12553. * @param width width of the new size
  12554. * @param height height of the new size
  12555. * @returns the updated Size.
  12556. */
  12557. copyFromFloats(width: number, height: number): Size;
  12558. /**
  12559. * Updates in place the current Size from the given floats.
  12560. * @param width width to set
  12561. * @param height height to set
  12562. * @returns the updated Size.
  12563. */
  12564. set(width: number, height: number): Size;
  12565. /**
  12566. * Multiplies the width and height by numbers
  12567. * @param w factor to multiple the width by
  12568. * @param h factor to multiple the height by
  12569. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12570. */
  12571. multiplyByFloats(w: number, h: number): Size;
  12572. /**
  12573. * Clones the size
  12574. * @returns a new Size copied from the given one.
  12575. */
  12576. clone(): Size;
  12577. /**
  12578. * True if the current Size and the given one width and height are strictly equal.
  12579. * @param other the other size to compare against
  12580. * @returns True if the current Size and the given one width and height are strictly equal.
  12581. */
  12582. equals(other: Size): boolean;
  12583. /**
  12584. * The surface of the Size : width * height (float).
  12585. */
  12586. readonly surface: number;
  12587. /**
  12588. * Create a new size of zero
  12589. * @returns a new Size set to (0.0, 0.0)
  12590. */
  12591. static Zero(): Size;
  12592. /**
  12593. * Sums the width and height of two sizes
  12594. * @param otherSize size to add to this size
  12595. * @returns a new Size set as the addition result of the current Size and the given one.
  12596. */
  12597. add(otherSize: Size): Size;
  12598. /**
  12599. * Subtracts the width and height of two
  12600. * @param otherSize size to subtract to this size
  12601. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12602. */
  12603. subtract(otherSize: Size): Size;
  12604. /**
  12605. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12606. * @param start starting size to lerp between
  12607. * @param end end size to lerp between
  12608. * @param amount amount to lerp between the start and end values
  12609. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12610. */
  12611. static Lerp(start: Size, end: Size, amount: number): Size;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * Defines a runtime animation
  12617. */
  12618. export class RuntimeAnimation {
  12619. private _events;
  12620. /**
  12621. * The current frame of the runtime animation
  12622. */
  12623. private _currentFrame;
  12624. /**
  12625. * The animation used by the runtime animation
  12626. */
  12627. private _animation;
  12628. /**
  12629. * The target of the runtime animation
  12630. */
  12631. private _target;
  12632. /**
  12633. * The initiating animatable
  12634. */
  12635. private _host;
  12636. /**
  12637. * The original value of the runtime animation
  12638. */
  12639. private _originalValue;
  12640. /**
  12641. * The original blend value of the runtime animation
  12642. */
  12643. private _originalBlendValue;
  12644. /**
  12645. * The offsets cache of the runtime animation
  12646. */
  12647. private _offsetsCache;
  12648. /**
  12649. * The high limits cache of the runtime animation
  12650. */
  12651. private _highLimitsCache;
  12652. /**
  12653. * Specifies if the runtime animation has been stopped
  12654. */
  12655. private _stopped;
  12656. /**
  12657. * The blending factor of the runtime animation
  12658. */
  12659. private _blendingFactor;
  12660. /**
  12661. * The BabylonJS scene
  12662. */
  12663. private _scene;
  12664. /**
  12665. * The current value of the runtime animation
  12666. */
  12667. private _currentValue;
  12668. /** @hidden */
  12669. _animationState: _IAnimationState;
  12670. /**
  12671. * The active target of the runtime animation
  12672. */
  12673. private _activeTargets;
  12674. private _currentActiveTarget;
  12675. private _directTarget;
  12676. /**
  12677. * The target path of the runtime animation
  12678. */
  12679. private _targetPath;
  12680. /**
  12681. * The weight of the runtime animation
  12682. */
  12683. private _weight;
  12684. /**
  12685. * The ratio offset of the runtime animation
  12686. */
  12687. private _ratioOffset;
  12688. /**
  12689. * The previous delay of the runtime animation
  12690. */
  12691. private _previousDelay;
  12692. /**
  12693. * The previous ratio of the runtime animation
  12694. */
  12695. private _previousRatio;
  12696. private _enableBlending;
  12697. private _keys;
  12698. private _minFrame;
  12699. private _maxFrame;
  12700. private _minValue;
  12701. private _maxValue;
  12702. private _targetIsArray;
  12703. /**
  12704. * Gets the current frame of the runtime animation
  12705. */
  12706. readonly currentFrame: number;
  12707. /**
  12708. * Gets the weight of the runtime animation
  12709. */
  12710. readonly weight: number;
  12711. /**
  12712. * Gets the current value of the runtime animation
  12713. */
  12714. readonly currentValue: any;
  12715. /**
  12716. * Gets the target path of the runtime animation
  12717. */
  12718. readonly targetPath: string;
  12719. /**
  12720. * Gets the actual target of the runtime animation
  12721. */
  12722. readonly target: any;
  12723. /** @hidden */
  12724. _onLoop: () => void;
  12725. /**
  12726. * Create a new RuntimeAnimation object
  12727. * @param target defines the target of the animation
  12728. * @param animation defines the source animation object
  12729. * @param scene defines the hosting scene
  12730. * @param host defines the initiating Animatable
  12731. */
  12732. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12733. private _preparePath;
  12734. /**
  12735. * Gets the animation from the runtime animation
  12736. */
  12737. readonly animation: Animation;
  12738. /**
  12739. * Resets the runtime animation to the beginning
  12740. * @param restoreOriginal defines whether to restore the target property to the original value
  12741. */
  12742. reset(restoreOriginal?: boolean): void;
  12743. /**
  12744. * Specifies if the runtime animation is stopped
  12745. * @returns Boolean specifying if the runtime animation is stopped
  12746. */
  12747. isStopped(): boolean;
  12748. /**
  12749. * Disposes of the runtime animation
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Apply the interpolated value to the target
  12754. * @param currentValue defines the value computed by the animation
  12755. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12756. */
  12757. setValue(currentValue: any, weight: number): void;
  12758. private _getOriginalValues;
  12759. private _setValue;
  12760. /**
  12761. * Gets the loop pmode of the runtime animation
  12762. * @returns Loop Mode
  12763. */
  12764. private _getCorrectLoopMode;
  12765. /**
  12766. * Move the current animation to a given frame
  12767. * @param frame defines the frame to move to
  12768. */
  12769. goToFrame(frame: number): void;
  12770. /**
  12771. * @hidden Internal use only
  12772. */
  12773. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12774. /**
  12775. * Execute the current animation
  12776. * @param delay defines the delay to add to the current frame
  12777. * @param from defines the lower bound of the animation range
  12778. * @param to defines the upper bound of the animation range
  12779. * @param loop defines if the current animation must loop
  12780. * @param speedRatio defines the current speed ratio
  12781. * @param weight defines the weight of the animation (default is -1 so no weight)
  12782. * @param onLoop optional callback called when animation loops
  12783. * @returns a boolean indicating if the animation is running
  12784. */
  12785. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Class used to store an actual running animation
  12791. */
  12792. export class Animatable {
  12793. /** defines the target object */
  12794. target: any;
  12795. /** defines the starting frame number (default is 0) */
  12796. fromFrame: number;
  12797. /** defines the ending frame number (default is 100) */
  12798. toFrame: number;
  12799. /** defines if the animation must loop (default is false) */
  12800. loopAnimation: boolean;
  12801. /** defines a callback to call when animation ends if it is not looping */
  12802. onAnimationEnd?: (() => void) | null | undefined;
  12803. /** defines a callback to call when animation loops */
  12804. onAnimationLoop?: (() => void) | null | undefined;
  12805. private _localDelayOffset;
  12806. private _pausedDelay;
  12807. private _runtimeAnimations;
  12808. private _paused;
  12809. private _scene;
  12810. private _speedRatio;
  12811. private _weight;
  12812. private _syncRoot;
  12813. /**
  12814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12815. * This will only apply for non looping animation (default is true)
  12816. */
  12817. disposeOnEnd: boolean;
  12818. /**
  12819. * Gets a boolean indicating if the animation has started
  12820. */
  12821. animationStarted: boolean;
  12822. /**
  12823. * Observer raised when the animation ends
  12824. */
  12825. onAnimationEndObservable: Observable<Animatable>;
  12826. /**
  12827. * Observer raised when the animation loops
  12828. */
  12829. onAnimationLoopObservable: Observable<Animatable>;
  12830. /**
  12831. * Gets the root Animatable used to synchronize and normalize animations
  12832. */
  12833. readonly syncRoot: Nullable<Animatable>;
  12834. /**
  12835. * Gets the current frame of the first RuntimeAnimation
  12836. * Used to synchronize Animatables
  12837. */
  12838. readonly masterFrame: number;
  12839. /**
  12840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12841. */
  12842. weight: number;
  12843. /**
  12844. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12845. */
  12846. speedRatio: number;
  12847. /**
  12848. * Creates a new Animatable
  12849. * @param scene defines the hosting scene
  12850. * @param target defines the target object
  12851. * @param fromFrame defines the starting frame number (default is 0)
  12852. * @param toFrame defines the ending frame number (default is 100)
  12853. * @param loopAnimation defines if the animation must loop (default is false)
  12854. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12855. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12856. * @param animations defines a group of animation to add to the new Animatable
  12857. * @param onAnimationLoop defines a callback to call when animation loops
  12858. */
  12859. constructor(scene: Scene,
  12860. /** defines the target object */
  12861. target: any,
  12862. /** defines the starting frame number (default is 0) */
  12863. fromFrame?: number,
  12864. /** defines the ending frame number (default is 100) */
  12865. toFrame?: number,
  12866. /** defines if the animation must loop (default is false) */
  12867. loopAnimation?: boolean, speedRatio?: number,
  12868. /** defines a callback to call when animation ends if it is not looping */
  12869. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12870. /** defines a callback to call when animation loops */
  12871. onAnimationLoop?: (() => void) | null | undefined);
  12872. /**
  12873. * Synchronize and normalize current Animatable with a source Animatable
  12874. * This is useful when using animation weights and when animations are not of the same length
  12875. * @param root defines the root Animatable to synchronize with
  12876. * @returns the current Animatable
  12877. */
  12878. syncWith(root: Animatable): Animatable;
  12879. /**
  12880. * Gets the list of runtime animations
  12881. * @returns an array of RuntimeAnimation
  12882. */
  12883. getAnimations(): RuntimeAnimation[];
  12884. /**
  12885. * Adds more animations to the current animatable
  12886. * @param target defines the target of the animations
  12887. * @param animations defines the new animations to add
  12888. */
  12889. appendAnimations(target: any, animations: Animation[]): void;
  12890. /**
  12891. * Gets the source animation for a specific property
  12892. * @param property defines the propertyu to look for
  12893. * @returns null or the source animation for the given property
  12894. */
  12895. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12896. /**
  12897. * Gets the runtime animation for a specific property
  12898. * @param property defines the propertyu to look for
  12899. * @returns null or the runtime animation for the given property
  12900. */
  12901. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12902. /**
  12903. * Resets the animatable to its original state
  12904. */
  12905. reset(): void;
  12906. /**
  12907. * Allows the animatable to blend with current running animations
  12908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12909. * @param blendingSpeed defines the blending speed to use
  12910. */
  12911. enableBlending(blendingSpeed: number): void;
  12912. /**
  12913. * Disable animation blending
  12914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12915. */
  12916. disableBlending(): void;
  12917. /**
  12918. * Jump directly to a given frame
  12919. * @param frame defines the frame to jump to
  12920. */
  12921. goToFrame(frame: number): void;
  12922. /**
  12923. * Pause the animation
  12924. */
  12925. pause(): void;
  12926. /**
  12927. * Restart the animation
  12928. */
  12929. restart(): void;
  12930. private _raiseOnAnimationEnd;
  12931. /**
  12932. * Stop and delete the current animation
  12933. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12934. * @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)
  12935. */
  12936. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12937. /**
  12938. * Wait asynchronously for the animation to end
  12939. * @returns a promise which will be fullfilled when the animation ends
  12940. */
  12941. waitAsync(): Promise<Animatable>;
  12942. /** @hidden */
  12943. _animate(delay: number): boolean;
  12944. }
  12945. interface Scene {
  12946. /** @hidden */
  12947. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12948. /** @hidden */
  12949. _processLateAnimationBindingsForMatrices(holder: {
  12950. totalWeight: number;
  12951. animations: RuntimeAnimation[];
  12952. originalValue: Matrix;
  12953. }): any;
  12954. /** @hidden */
  12955. _processLateAnimationBindingsForQuaternions(holder: {
  12956. totalWeight: number;
  12957. animations: RuntimeAnimation[];
  12958. originalValue: Quaternion;
  12959. }, refQuaternion: Quaternion): Quaternion;
  12960. /** @hidden */
  12961. _processLateAnimationBindings(): void;
  12962. /**
  12963. * Will start the animation sequence of a given target
  12964. * @param target defines the target
  12965. * @param from defines from which frame should animation start
  12966. * @param to defines until which frame should animation run.
  12967. * @param weight defines the weight to apply to the animation (1.0 by default)
  12968. * @param loop defines if the animation loops
  12969. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12970. * @param onAnimationEnd defines the function to be executed when the animation ends
  12971. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12972. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12973. * @param onAnimationLoop defines the callback to call when an animation loops
  12974. * @returns the animatable object created for this animation
  12975. */
  12976. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12977. /**
  12978. * Will start the animation sequence of a given target
  12979. * @param target defines the target
  12980. * @param from defines from which frame should animation start
  12981. * @param to defines until which frame should animation run.
  12982. * @param loop defines if the animation loops
  12983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12984. * @param onAnimationEnd defines the function to be executed when the animation ends
  12985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12986. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12987. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12988. * @param onAnimationLoop defines the callback to call when an animation loops
  12989. * @returns the animatable object created for this animation
  12990. */
  12991. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12992. /**
  12993. * Will start the animation sequence of a given target and its hierarchy
  12994. * @param target defines the target
  12995. * @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.
  12996. * @param from defines from which frame should animation start
  12997. * @param to defines until which frame should animation run.
  12998. * @param loop defines if the animation loops
  12999. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13000. * @param onAnimationEnd defines the function to be executed when the animation ends
  13001. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13002. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13003. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13004. * @param onAnimationLoop defines the callback to call when an animation loops
  13005. * @returns the list of created animatables
  13006. */
  13007. 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[];
  13008. /**
  13009. * Begin a new animation on a given node
  13010. * @param target defines the target where the animation will take place
  13011. * @param animations defines the list of animations to start
  13012. * @param from defines the initial value
  13013. * @param to defines the final value
  13014. * @param loop defines if you want animation to loop (off by default)
  13015. * @param speedRatio defines the speed ratio to apply to all animations
  13016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13017. * @param onAnimationLoop defines the callback to call when an animation loops
  13018. * @returns the list of created animatables
  13019. */
  13020. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13021. /**
  13022. * Begin a new animation on a given node and its hierarchy
  13023. * @param target defines the root node where the animation will take place
  13024. * @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.
  13025. * @param animations defines the list of animations to start
  13026. * @param from defines the initial value
  13027. * @param to defines the final value
  13028. * @param loop defines if you want animation to loop (off by default)
  13029. * @param speedRatio defines the speed ratio to apply to all animations
  13030. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13031. * @param onAnimationLoop defines the callback to call when an animation loops
  13032. * @returns the list of animatables created for all nodes
  13033. */
  13034. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13035. /**
  13036. * Gets the animatable associated with a specific target
  13037. * @param target defines the target of the animatable
  13038. * @returns the required animatable if found
  13039. */
  13040. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13041. /**
  13042. * Gets all animatables associated with a given target
  13043. * @param target defines the target to look animatables for
  13044. * @returns an array of Animatables
  13045. */
  13046. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13047. /**
  13048. * Stops and removes all animations that have been applied to the scene
  13049. */
  13050. stopAllAnimations(): void;
  13051. }
  13052. interface Bone {
  13053. /**
  13054. * Copy an animation range from another bone
  13055. * @param source defines the source bone
  13056. * @param rangeName defines the range name to copy
  13057. * @param frameOffset defines the frame offset
  13058. * @param rescaleAsRequired defines if rescaling must be applied if required
  13059. * @param skelDimensionsRatio defines the scaling ratio
  13060. * @returns true if operation was successful
  13061. */
  13062. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Class used to override all child animations of a given target
  13068. */
  13069. export class AnimationPropertiesOverride {
  13070. /**
  13071. * Gets or sets a value indicating if animation blending must be used
  13072. */
  13073. enableBlending: boolean;
  13074. /**
  13075. * Gets or sets the blending speed to use when enableBlending is true
  13076. */
  13077. blendingSpeed: number;
  13078. /**
  13079. * Gets or sets the default loop mode to use
  13080. */
  13081. loopMode: number;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Class used to handle skinning animations
  13087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13088. */
  13089. export class Skeleton implements IAnimatable {
  13090. /** defines the skeleton name */
  13091. name: string;
  13092. /** defines the skeleton Id */
  13093. id: string;
  13094. /**
  13095. * Defines the list of child bones
  13096. */
  13097. bones: Bone[];
  13098. /**
  13099. * Defines an estimate of the dimension of the skeleton at rest
  13100. */
  13101. dimensionsAtRest: Vector3;
  13102. /**
  13103. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13104. */
  13105. needInitialSkinMatrix: boolean;
  13106. /**
  13107. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13108. */
  13109. overrideMesh: Nullable<AbstractMesh>;
  13110. /**
  13111. * Gets the list of animations attached to this skeleton
  13112. */
  13113. animations: Array<Animation>;
  13114. private _scene;
  13115. private _isDirty;
  13116. private _transformMatrices;
  13117. private _transformMatrixTexture;
  13118. private _meshesWithPoseMatrix;
  13119. private _animatables;
  13120. private _identity;
  13121. private _synchronizedWithMesh;
  13122. private _ranges;
  13123. private _lastAbsoluteTransformsUpdateId;
  13124. private _canUseTextureForBones;
  13125. private _uniqueId;
  13126. /** @hidden */
  13127. _numBonesWithLinkedTransformNode: number;
  13128. /** @hidden */
  13129. _hasWaitingData: Nullable<boolean>;
  13130. /**
  13131. * Specifies if the skeleton should be serialized
  13132. */
  13133. doNotSerialize: boolean;
  13134. private _useTextureToStoreBoneMatrices;
  13135. /**
  13136. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13137. * Please note that this option is not available if the hardware does not support it
  13138. */
  13139. useTextureToStoreBoneMatrices: boolean;
  13140. private _animationPropertiesOverride;
  13141. /**
  13142. * Gets or sets the animation properties override
  13143. */
  13144. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13145. /**
  13146. * List of inspectable custom properties (used by the Inspector)
  13147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13148. */
  13149. inspectableCustomProperties: IInspectable[];
  13150. /**
  13151. * An observable triggered before computing the skeleton's matrices
  13152. */
  13153. onBeforeComputeObservable: Observable<Skeleton>;
  13154. /**
  13155. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13156. */
  13157. readonly isUsingTextureForMatrices: boolean;
  13158. /**
  13159. * Gets the unique ID of this skeleton
  13160. */
  13161. readonly uniqueId: number;
  13162. /**
  13163. * Creates a new skeleton
  13164. * @param name defines the skeleton name
  13165. * @param id defines the skeleton Id
  13166. * @param scene defines the hosting scene
  13167. */
  13168. constructor(
  13169. /** defines the skeleton name */
  13170. name: string,
  13171. /** defines the skeleton Id */
  13172. id: string, scene: Scene);
  13173. /**
  13174. * Gets the current object class name.
  13175. * @return the class name
  13176. */
  13177. getClassName(): string;
  13178. /**
  13179. * Returns an array containing the root bones
  13180. * @returns an array containing the root bones
  13181. */
  13182. getChildren(): Array<Bone>;
  13183. /**
  13184. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13185. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13186. * @returns a Float32Array containing matrices data
  13187. */
  13188. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13189. /**
  13190. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13191. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13192. * @returns a raw texture containing the data
  13193. */
  13194. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13195. /**
  13196. * Gets the current hosting scene
  13197. * @returns a scene object
  13198. */
  13199. getScene(): Scene;
  13200. /**
  13201. * Gets a string representing the current skeleton data
  13202. * @param fullDetails defines a boolean indicating if we want a verbose version
  13203. * @returns a string representing the current skeleton data
  13204. */
  13205. toString(fullDetails?: boolean): string;
  13206. /**
  13207. * Get bone's index searching by name
  13208. * @param name defines bone's name to search for
  13209. * @return the indice of the bone. Returns -1 if not found
  13210. */
  13211. getBoneIndexByName(name: string): number;
  13212. /**
  13213. * Creater a new animation range
  13214. * @param name defines the name of the range
  13215. * @param from defines the start key
  13216. * @param to defines the end key
  13217. */
  13218. createAnimationRange(name: string, from: number, to: number): void;
  13219. /**
  13220. * Delete a specific animation range
  13221. * @param name defines the name of the range
  13222. * @param deleteFrames defines if frames must be removed as well
  13223. */
  13224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13225. /**
  13226. * Gets a specific animation range
  13227. * @param name defines the name of the range to look for
  13228. * @returns the requested animation range or null if not found
  13229. */
  13230. getAnimationRange(name: string): Nullable<AnimationRange>;
  13231. /**
  13232. * Gets the list of all animation ranges defined on this skeleton
  13233. * @returns an array
  13234. */
  13235. getAnimationRanges(): Nullable<AnimationRange>[];
  13236. /**
  13237. * Copy animation range from a source skeleton.
  13238. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13239. * @param source defines the source skeleton
  13240. * @param name defines the name of the range to copy
  13241. * @param rescaleAsRequired defines if rescaling must be applied if required
  13242. * @returns true if operation was successful
  13243. */
  13244. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13245. /**
  13246. * Forces the skeleton to go to rest pose
  13247. */
  13248. returnToRest(): void;
  13249. private _getHighestAnimationFrame;
  13250. /**
  13251. * Begin a specific animation range
  13252. * @param name defines the name of the range to start
  13253. * @param loop defines if looping must be turned on (false by default)
  13254. * @param speedRatio defines the speed ratio to apply (1 by default)
  13255. * @param onAnimationEnd defines a callback which will be called when animation will end
  13256. * @returns a new animatable
  13257. */
  13258. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13259. /** @hidden */
  13260. _markAsDirty(): void;
  13261. /** @hidden */
  13262. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13263. /** @hidden */
  13264. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13265. private _computeTransformMatrices;
  13266. /**
  13267. * Build all resources required to render a skeleton
  13268. */
  13269. prepare(): void;
  13270. /**
  13271. * Gets the list of animatables currently running for this skeleton
  13272. * @returns an array of animatables
  13273. */
  13274. getAnimatables(): IAnimatable[];
  13275. /**
  13276. * Clone the current skeleton
  13277. * @param name defines the name of the new skeleton
  13278. * @param id defines the id of the new skeleton
  13279. * @returns the new skeleton
  13280. */
  13281. clone(name: string, id: string): Skeleton;
  13282. /**
  13283. * Enable animation blending for this skeleton
  13284. * @param blendingSpeed defines the blending speed to apply
  13285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13286. */
  13287. enableBlending(blendingSpeed?: number): void;
  13288. /**
  13289. * Releases all resources associated with the current skeleton
  13290. */
  13291. dispose(): void;
  13292. /**
  13293. * Serialize the skeleton in a JSON object
  13294. * @returns a JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Creates a new skeleton from serialized data
  13299. * @param parsedSkeleton defines the serialized data
  13300. * @param scene defines the hosting scene
  13301. * @returns a new skeleton
  13302. */
  13303. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13304. /**
  13305. * Compute all node absolute transforms
  13306. * @param forceUpdate defines if computation must be done even if cache is up to date
  13307. */
  13308. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13309. /**
  13310. * Gets the root pose matrix
  13311. * @returns a matrix
  13312. */
  13313. getPoseMatrix(): Nullable<Matrix>;
  13314. /**
  13315. * Sorts bones per internal index
  13316. */
  13317. sortBones(): void;
  13318. private _sortBones;
  13319. }
  13320. }
  13321. declare module BABYLON {
  13322. /**
  13323. * Class used to store bone information
  13324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13325. */
  13326. export class Bone extends Node {
  13327. /**
  13328. * defines the bone name
  13329. */
  13330. name: string;
  13331. private static _tmpVecs;
  13332. private static _tmpQuat;
  13333. private static _tmpMats;
  13334. /**
  13335. * Gets the list of child bones
  13336. */
  13337. children: Bone[];
  13338. /** Gets the animations associated with this bone */
  13339. animations: Animation[];
  13340. /**
  13341. * Gets or sets bone length
  13342. */
  13343. length: number;
  13344. /**
  13345. * @hidden Internal only
  13346. * Set this value to map this bone to a different index in the transform matrices
  13347. * Set this value to -1 to exclude the bone from the transform matrices
  13348. */
  13349. _index: Nullable<number>;
  13350. private _skeleton;
  13351. private _localMatrix;
  13352. private _restPose;
  13353. private _baseMatrix;
  13354. private _absoluteTransform;
  13355. private _invertedAbsoluteTransform;
  13356. private _parent;
  13357. private _scalingDeterminant;
  13358. private _worldTransform;
  13359. private _localScaling;
  13360. private _localRotation;
  13361. private _localPosition;
  13362. private _needToDecompose;
  13363. private _needToCompose;
  13364. /** @hidden */
  13365. _linkedTransformNode: Nullable<TransformNode>;
  13366. /** @hidden */
  13367. _waitingTransformNodeId: Nullable<string>;
  13368. /** @hidden */
  13369. /** @hidden */
  13370. _matrix: Matrix;
  13371. /**
  13372. * Create a new bone
  13373. * @param name defines the bone name
  13374. * @param skeleton defines the parent skeleton
  13375. * @param parentBone defines the parent (can be null if the bone is the root)
  13376. * @param localMatrix defines the local matrix
  13377. * @param restPose defines the rest pose matrix
  13378. * @param baseMatrix defines the base matrix
  13379. * @param index defines index of the bone in the hiearchy
  13380. */
  13381. constructor(
  13382. /**
  13383. * defines the bone name
  13384. */
  13385. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13386. /**
  13387. * Gets the current object class name.
  13388. * @return the class name
  13389. */
  13390. getClassName(): string;
  13391. /**
  13392. * Gets the parent skeleton
  13393. * @returns a skeleton
  13394. */
  13395. getSkeleton(): Skeleton;
  13396. /**
  13397. * Gets parent bone
  13398. * @returns a bone or null if the bone is the root of the bone hierarchy
  13399. */
  13400. getParent(): Nullable<Bone>;
  13401. /**
  13402. * Returns an array containing the root bones
  13403. * @returns an array containing the root bones
  13404. */
  13405. getChildren(): Array<Bone>;
  13406. /**
  13407. * Sets the parent bone
  13408. * @param parent defines the parent (can be null if the bone is the root)
  13409. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13410. */
  13411. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13412. /**
  13413. * Gets the local matrix
  13414. * @returns a matrix
  13415. */
  13416. getLocalMatrix(): Matrix;
  13417. /**
  13418. * Gets the base matrix (initial matrix which remains unchanged)
  13419. * @returns a matrix
  13420. */
  13421. getBaseMatrix(): Matrix;
  13422. /**
  13423. * Gets the rest pose matrix
  13424. * @returns a matrix
  13425. */
  13426. getRestPose(): Matrix;
  13427. /**
  13428. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13429. */
  13430. getWorldMatrix(): Matrix;
  13431. /**
  13432. * Sets the local matrix to rest pose matrix
  13433. */
  13434. returnToRest(): void;
  13435. /**
  13436. * Gets the inverse of the absolute transform matrix.
  13437. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13438. * @returns a matrix
  13439. */
  13440. getInvertedAbsoluteTransform(): Matrix;
  13441. /**
  13442. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13443. * @returns a matrix
  13444. */
  13445. getAbsoluteTransform(): Matrix;
  13446. /**
  13447. * Links with the given transform node.
  13448. * The local matrix of this bone is copied from the transform node every frame.
  13449. * @param transformNode defines the transform node to link to
  13450. */
  13451. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13452. /**
  13453. * Gets the node used to drive the bone's transformation
  13454. * @returns a transform node or null
  13455. */
  13456. getTransformNode(): Nullable<TransformNode>;
  13457. /** Gets or sets current position (in local space) */
  13458. position: Vector3;
  13459. /** Gets or sets current rotation (in local space) */
  13460. rotation: Vector3;
  13461. /** Gets or sets current rotation quaternion (in local space) */
  13462. rotationQuaternion: Quaternion;
  13463. /** Gets or sets current scaling (in local space) */
  13464. scaling: Vector3;
  13465. /**
  13466. * Gets the animation properties override
  13467. */
  13468. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13469. private _decompose;
  13470. private _compose;
  13471. /**
  13472. * Update the base and local matrices
  13473. * @param matrix defines the new base or local matrix
  13474. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13475. * @param updateLocalMatrix defines if the local matrix should be updated
  13476. */
  13477. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13478. /** @hidden */
  13479. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13480. /**
  13481. * Flag the bone as dirty (Forcing it to update everything)
  13482. */
  13483. markAsDirty(): void;
  13484. /** @hidden */
  13485. _markAsDirtyAndCompose(): void;
  13486. private _markAsDirtyAndDecompose;
  13487. /**
  13488. * Translate the bone in local or world space
  13489. * @param vec The amount to translate the bone
  13490. * @param space The space that the translation is in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. */
  13493. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13494. /**
  13495. * Set the postion of the bone in local or world space
  13496. * @param position The position to set the bone
  13497. * @param space The space that the position is in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. */
  13500. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13501. /**
  13502. * Set the absolute position of the bone (world space)
  13503. * @param position The position to set the bone
  13504. * @param mesh The mesh that this bone is attached to
  13505. */
  13506. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13507. /**
  13508. * Scale the bone on the x, y and z axes (in local space)
  13509. * @param x The amount to scale the bone on the x axis
  13510. * @param y The amount to scale the bone on the y axis
  13511. * @param z The amount to scale the bone on the z axis
  13512. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13513. */
  13514. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13515. /**
  13516. * Set the bone scaling in local space
  13517. * @param scale defines the scaling vector
  13518. */
  13519. setScale(scale: Vector3): void;
  13520. /**
  13521. * Gets the current scaling in local space
  13522. * @returns the current scaling vector
  13523. */
  13524. getScale(): Vector3;
  13525. /**
  13526. * Gets the current scaling in local space and stores it in a target vector
  13527. * @param result defines the target vector
  13528. */
  13529. getScaleToRef(result: Vector3): void;
  13530. /**
  13531. * Set the yaw, pitch, and roll of the bone in local or world space
  13532. * @param yaw The rotation of the bone on the y axis
  13533. * @param pitch The rotation of the bone on the x axis
  13534. * @param roll The rotation of the bone on the z axis
  13535. * @param space The space that the axes of rotation are in
  13536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13537. */
  13538. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13539. /**
  13540. * Add a rotation to the bone on an axis in local or world space
  13541. * @param axis The axis to rotate the bone on
  13542. * @param amount The amount to rotate the bone
  13543. * @param space The space that the axis is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13547. /**
  13548. * Set the rotation of the bone to a particular axis angle in local or world space
  13549. * @param axis The axis to rotate the bone on
  13550. * @param angle The angle that the bone should be rotated to
  13551. * @param space The space that the axis is in
  13552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13553. */
  13554. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13555. /**
  13556. * Set the euler rotation of the bone in local of world space
  13557. * @param rotation The euler rotation that the bone should be set to
  13558. * @param space The space that the rotation is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Set the quaternion rotation of the bone in local of world space
  13564. * @param quat The quaternion rotation that the bone should be set to
  13565. * @param space The space that the rotation is in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. */
  13568. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13569. /**
  13570. * Set the rotation matrix of the bone in local of world space
  13571. * @param rotMat The rotation matrix that the bone should be set to
  13572. * @param space The space that the rotation is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13576. private _rotateWithMatrix;
  13577. private _getNegativeRotationToRef;
  13578. /**
  13579. * Get the position of the bone in local or world space
  13580. * @param space The space that the returned position is in
  13581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13582. * @returns The position of the bone
  13583. */
  13584. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13585. /**
  13586. * Copy the position of the bone to a vector3 in local or world space
  13587. * @param space The space that the returned position is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. * @param result The vector3 to copy the position to
  13590. */
  13591. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13592. /**
  13593. * Get the absolute position of the bone (world space)
  13594. * @param mesh The mesh that this bone is attached to
  13595. * @returns The absolute position of the bone
  13596. */
  13597. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13598. /**
  13599. * Copy the absolute position of the bone (world space) to the result param
  13600. * @param mesh The mesh that this bone is attached to
  13601. * @param result The vector3 to copy the absolute position to
  13602. */
  13603. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13604. /**
  13605. * Compute the absolute transforms of this bone and its children
  13606. */
  13607. computeAbsoluteTransforms(): void;
  13608. /**
  13609. * Get the world direction from an axis that is in the local space of the bone
  13610. * @param localAxis The local direction that is used to compute the world direction
  13611. * @param mesh The mesh that this bone is attached to
  13612. * @returns The world direction
  13613. */
  13614. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13615. /**
  13616. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13617. * @param localAxis The local direction that is used to compute the world direction
  13618. * @param mesh The mesh that this bone is attached to
  13619. * @param result The vector3 that the world direction will be copied to
  13620. */
  13621. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13622. /**
  13623. * Get the euler rotation of the bone in local or world space
  13624. * @param space The space that the rotation should be in
  13625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13626. * @returns The euler rotation
  13627. */
  13628. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13629. /**
  13630. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13631. * @param space The space that the rotation should be in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. * @param result The vector3 that the rotation should be copied to
  13634. */
  13635. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13636. /**
  13637. * Get the quaternion rotation of the bone in either local or world space
  13638. * @param space The space that the rotation should be in
  13639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13640. * @returns The quaternion rotation
  13641. */
  13642. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13643. /**
  13644. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13645. * @param space The space that the rotation should be in
  13646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13647. * @param result The quaternion that the rotation should be copied to
  13648. */
  13649. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13650. /**
  13651. * Get the rotation matrix of the bone in local or world space
  13652. * @param space The space that the rotation should be in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. * @returns The rotation matrix
  13655. */
  13656. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13657. /**
  13658. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13659. * @param space The space that the rotation should be in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. * @param result The quaternion that the rotation should be copied to
  13662. */
  13663. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13664. /**
  13665. * Get the world position of a point that is in the local space of the bone
  13666. * @param position The local position
  13667. * @param mesh The mesh that this bone is attached to
  13668. * @returns The world position
  13669. */
  13670. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13671. /**
  13672. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13673. * @param position The local position
  13674. * @param mesh The mesh that this bone is attached to
  13675. * @param result The vector3 that the world position should be copied to
  13676. */
  13677. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13678. /**
  13679. * Get the local position of a point that is in world space
  13680. * @param position The world position
  13681. * @param mesh The mesh that this bone is attached to
  13682. * @returns The local position
  13683. */
  13684. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13685. /**
  13686. * Get the local position of a point that is in world space and copy it to the result param
  13687. * @param position The world position
  13688. * @param mesh The mesh that this bone is attached to
  13689. * @param result The vector3 that the local position should be copied to
  13690. */
  13691. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * 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.
  13697. * @see https://doc.babylonjs.com/how_to/transformnode
  13698. */
  13699. export class TransformNode extends Node {
  13700. /**
  13701. * Object will not rotate to face the camera
  13702. */
  13703. static BILLBOARDMODE_NONE: number;
  13704. /**
  13705. * Object will rotate to face the camera but only on the x axis
  13706. */
  13707. static BILLBOARDMODE_X: number;
  13708. /**
  13709. * Object will rotate to face the camera but only on the y axis
  13710. */
  13711. static BILLBOARDMODE_Y: number;
  13712. /**
  13713. * Object will rotate to face the camera but only on the z axis
  13714. */
  13715. static BILLBOARDMODE_Z: number;
  13716. /**
  13717. * Object will rotate to face the camera
  13718. */
  13719. static BILLBOARDMODE_ALL: number;
  13720. /**
  13721. * Object will rotate to face the camera's position instead of orientation
  13722. */
  13723. static BILLBOARDMODE_USE_POSITION: number;
  13724. private _forward;
  13725. private _forwardInverted;
  13726. private _up;
  13727. private _right;
  13728. private _rightInverted;
  13729. private _position;
  13730. private _rotation;
  13731. private _rotationQuaternion;
  13732. protected _scaling: Vector3;
  13733. protected _isDirty: boolean;
  13734. private _transformToBoneReferal;
  13735. private _isAbsoluteSynced;
  13736. private _billboardMode;
  13737. /**
  13738. * Gets or sets the billboard mode. Default is 0.
  13739. *
  13740. * | Value | Type | Description |
  13741. * | --- | --- | --- |
  13742. * | 0 | BILLBOARDMODE_NONE | |
  13743. * | 1 | BILLBOARDMODE_X | |
  13744. * | 2 | BILLBOARDMODE_Y | |
  13745. * | 4 | BILLBOARDMODE_Z | |
  13746. * | 7 | BILLBOARDMODE_ALL | |
  13747. *
  13748. */
  13749. billboardMode: number;
  13750. private _preserveParentRotationForBillboard;
  13751. /**
  13752. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13753. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13754. */
  13755. preserveParentRotationForBillboard: boolean;
  13756. /**
  13757. * 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
  13758. */
  13759. scalingDeterminant: number;
  13760. private _infiniteDistance;
  13761. /**
  13762. * Gets or sets the distance of the object to max, often used by skybox
  13763. */
  13764. infiniteDistance: boolean;
  13765. /**
  13766. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13767. * By default the system will update normals to compensate
  13768. */
  13769. ignoreNonUniformScaling: boolean;
  13770. /**
  13771. * 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
  13772. */
  13773. reIntegrateRotationIntoRotationQuaternion: boolean;
  13774. /** @hidden */
  13775. _poseMatrix: Nullable<Matrix>;
  13776. /** @hidden */
  13777. _localMatrix: Matrix;
  13778. private _usePivotMatrix;
  13779. private _absolutePosition;
  13780. private _absoluteScaling;
  13781. private _absoluteRotationQuaternion;
  13782. private _pivotMatrix;
  13783. private _pivotMatrixInverse;
  13784. protected _postMultiplyPivotMatrix: boolean;
  13785. protected _isWorldMatrixFrozen: boolean;
  13786. /** @hidden */
  13787. _indexInSceneTransformNodesArray: number;
  13788. /**
  13789. * An event triggered after the world matrix is updated
  13790. */
  13791. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13792. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13793. /**
  13794. * Gets a string identifying the name of the class
  13795. * @returns "TransformNode" string
  13796. */
  13797. getClassName(): string;
  13798. /**
  13799. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13800. */
  13801. position: Vector3;
  13802. /**
  13803. * 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)).
  13804. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13805. */
  13806. rotation: Vector3;
  13807. /**
  13808. * 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)).
  13809. */
  13810. scaling: Vector3;
  13811. /**
  13812. * 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).
  13813. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13814. */
  13815. rotationQuaternion: Nullable<Quaternion>;
  13816. /**
  13817. * The forward direction of that transform in world space.
  13818. */
  13819. readonly forward: Vector3;
  13820. /**
  13821. * The up direction of that transform in world space.
  13822. */
  13823. readonly up: Vector3;
  13824. /**
  13825. * The right direction of that transform in world space.
  13826. */
  13827. readonly right: Vector3;
  13828. /**
  13829. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13830. * @param matrix the matrix to copy the pose from
  13831. * @returns this TransformNode.
  13832. */
  13833. updatePoseMatrix(matrix: Matrix): TransformNode;
  13834. /**
  13835. * Returns the mesh Pose matrix.
  13836. * @returns the pose matrix
  13837. */
  13838. getPoseMatrix(): Matrix;
  13839. /** @hidden */
  13840. _isSynchronized(): boolean;
  13841. /** @hidden */
  13842. _initCache(): void;
  13843. /**
  13844. * Flag the transform node as dirty (Forcing it to update everything)
  13845. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13846. * @returns this transform node
  13847. */
  13848. markAsDirty(property: string): TransformNode;
  13849. /**
  13850. * Returns the current mesh absolute position.
  13851. * Returns a Vector3.
  13852. */
  13853. readonly absolutePosition: Vector3;
  13854. /**
  13855. * Returns the current mesh absolute scaling.
  13856. * Returns a Vector3.
  13857. */
  13858. readonly absoluteScaling: Vector3;
  13859. /**
  13860. * Returns the current mesh absolute rotation.
  13861. * Returns a Quaternion.
  13862. */
  13863. readonly absoluteRotationQuaternion: Quaternion;
  13864. /**
  13865. * Sets a new matrix to apply before all other transformation
  13866. * @param matrix defines the transform matrix
  13867. * @returns the current TransformNode
  13868. */
  13869. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13870. /**
  13871. * Sets a new pivot matrix to the current node
  13872. * @param matrix defines the new pivot matrix to use
  13873. * @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
  13874. * @returns the current TransformNode
  13875. */
  13876. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13877. /**
  13878. * Returns the mesh pivot matrix.
  13879. * Default : Identity.
  13880. * @returns the matrix
  13881. */
  13882. getPivotMatrix(): Matrix;
  13883. /**
  13884. * Instantiate (when possible) or clone that node with its hierarchy
  13885. * @param newParent defines the new parent to use for the instance (or clone)
  13886. * @returns an instance (or a clone) of the current node with its hiearchy
  13887. */
  13888. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13889. /**
  13890. * Prevents the World matrix to be computed any longer
  13891. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13892. * @returns the TransformNode.
  13893. */
  13894. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13895. /**
  13896. * Allows back the World matrix computation.
  13897. * @returns the TransformNode.
  13898. */
  13899. unfreezeWorldMatrix(): this;
  13900. /**
  13901. * True if the World matrix has been frozen.
  13902. */
  13903. readonly isWorldMatrixFrozen: boolean;
  13904. /**
  13905. * Retuns the mesh absolute position in the World.
  13906. * @returns a Vector3.
  13907. */
  13908. getAbsolutePosition(): Vector3;
  13909. /**
  13910. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13911. * @param absolutePosition the absolute position to set
  13912. * @returns the TransformNode.
  13913. */
  13914. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13915. /**
  13916. * Sets the mesh position in its local space.
  13917. * @param vector3 the position to set in localspace
  13918. * @returns the TransformNode.
  13919. */
  13920. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13921. /**
  13922. * Returns the mesh position in the local space from the current World matrix values.
  13923. * @returns a new Vector3.
  13924. */
  13925. getPositionExpressedInLocalSpace(): Vector3;
  13926. /**
  13927. * Translates the mesh along the passed Vector3 in its local space.
  13928. * @param vector3 the distance to translate in localspace
  13929. * @returns the TransformNode.
  13930. */
  13931. locallyTranslate(vector3: Vector3): TransformNode;
  13932. private static _lookAtVectorCache;
  13933. /**
  13934. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13935. * @param targetPoint the position (must be in same space as current mesh) to look at
  13936. * @param yawCor optional yaw (y-axis) correction in radians
  13937. * @param pitchCor optional pitch (x-axis) correction in radians
  13938. * @param rollCor optional roll (z-axis) correction in radians
  13939. * @param space the choosen space of the target
  13940. * @returns the TransformNode.
  13941. */
  13942. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13943. /**
  13944. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13945. * This Vector3 is expressed in the World space.
  13946. * @param localAxis axis to rotate
  13947. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13948. */
  13949. getDirection(localAxis: Vector3): Vector3;
  13950. /**
  13951. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13952. * localAxis is expressed in the mesh local space.
  13953. * result is computed in the Wordl space from the mesh World matrix.
  13954. * @param localAxis axis to rotate
  13955. * @param result the resulting transformnode
  13956. * @returns this TransformNode.
  13957. */
  13958. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13959. /**
  13960. * Sets this transform node rotation to the given local axis.
  13961. * @param localAxis the axis in local space
  13962. * @param yawCor optional yaw (y-axis) correction in radians
  13963. * @param pitchCor optional pitch (x-axis) correction in radians
  13964. * @param rollCor optional roll (z-axis) correction in radians
  13965. * @returns this TransformNode
  13966. */
  13967. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13968. /**
  13969. * Sets a new pivot point to the current node
  13970. * @param point defines the new pivot point to use
  13971. * @param space defines if the point is in world or local space (local by default)
  13972. * @returns the current TransformNode
  13973. */
  13974. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13975. /**
  13976. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13977. * @returns the pivot point
  13978. */
  13979. getPivotPoint(): Vector3;
  13980. /**
  13981. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13982. * @param result the vector3 to store the result
  13983. * @returns this TransformNode.
  13984. */
  13985. getPivotPointToRef(result: Vector3): TransformNode;
  13986. /**
  13987. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13988. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13989. */
  13990. getAbsolutePivotPoint(): Vector3;
  13991. /**
  13992. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13993. * @param result vector3 to store the result
  13994. * @returns this TransformNode.
  13995. */
  13996. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13997. /**
  13998. * Defines the passed node as the parent of the current node.
  13999. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14000. * @see https://doc.babylonjs.com/how_to/parenting
  14001. * @param node the node ot set as the parent
  14002. * @returns this TransformNode.
  14003. */
  14004. setParent(node: Nullable<Node>): TransformNode;
  14005. private _nonUniformScaling;
  14006. /**
  14007. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14008. */
  14009. readonly nonUniformScaling: boolean;
  14010. /** @hidden */
  14011. _updateNonUniformScalingState(value: boolean): boolean;
  14012. /**
  14013. * Attach the current TransformNode to another TransformNode associated with a bone
  14014. * @param bone Bone affecting the TransformNode
  14015. * @param affectedTransformNode TransformNode associated with the bone
  14016. * @returns this object
  14017. */
  14018. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14019. /**
  14020. * Detach the transform node if its associated with a bone
  14021. * @returns this object
  14022. */
  14023. detachFromBone(): TransformNode;
  14024. private static _rotationAxisCache;
  14025. /**
  14026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14028. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14029. * The passed axis is also normalized.
  14030. * @param axis the axis to rotate around
  14031. * @param amount the amount to rotate in radians
  14032. * @param space Space to rotate in (Default: local)
  14033. * @returns the TransformNode.
  14034. */
  14035. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14036. /**
  14037. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14038. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14039. * The passed axis is also normalized. .
  14040. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14041. * @param point the point to rotate around
  14042. * @param axis the axis to rotate around
  14043. * @param amount the amount to rotate in radians
  14044. * @returns the TransformNode
  14045. */
  14046. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14047. /**
  14048. * Translates the mesh along the axis vector for the passed distance in the given space.
  14049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14050. * @param axis the axis to translate in
  14051. * @param distance the distance to translate
  14052. * @param space Space to rotate in (Default: local)
  14053. * @returns the TransformNode.
  14054. */
  14055. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14056. /**
  14057. * Adds a rotation step to the mesh current rotation.
  14058. * x, y, z are Euler angles expressed in radians.
  14059. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14060. * This means this rotation is made in the mesh local space only.
  14061. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14062. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14063. * ```javascript
  14064. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14065. * ```
  14066. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14067. * 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.
  14068. * @param x Rotation to add
  14069. * @param y Rotation to add
  14070. * @param z Rotation to add
  14071. * @returns the TransformNode.
  14072. */
  14073. addRotation(x: number, y: number, z: number): TransformNode;
  14074. /**
  14075. * @hidden
  14076. */
  14077. protected _getEffectiveParent(): Nullable<Node>;
  14078. /**
  14079. * Computes the world matrix of the node
  14080. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14081. * @returns the world matrix
  14082. */
  14083. computeWorldMatrix(force?: boolean): Matrix;
  14084. protected _afterComputeWorldMatrix(): void;
  14085. /**
  14086. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14087. * @param func callback function to add
  14088. *
  14089. * @returns the TransformNode.
  14090. */
  14091. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14092. /**
  14093. * Removes a registered callback function.
  14094. * @param func callback function to remove
  14095. * @returns the TransformNode.
  14096. */
  14097. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14098. /**
  14099. * Gets the position of the current mesh in camera space
  14100. * @param camera defines the camera to use
  14101. * @returns a position
  14102. */
  14103. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14104. /**
  14105. * Returns the distance from the mesh to the active camera
  14106. * @param camera defines the camera to use
  14107. * @returns the distance
  14108. */
  14109. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14110. /**
  14111. * Clone the current transform node
  14112. * @param name Name of the new clone
  14113. * @param newParent New parent for the clone
  14114. * @param doNotCloneChildren Do not clone children hierarchy
  14115. * @returns the new transform node
  14116. */
  14117. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14118. /**
  14119. * Serializes the objects information.
  14120. * @param currentSerializationObject defines the object to serialize in
  14121. * @returns the serialized object
  14122. */
  14123. serialize(currentSerializationObject?: any): any;
  14124. /**
  14125. * Returns a new TransformNode object parsed from the source provided.
  14126. * @param parsedTransformNode is the source.
  14127. * @param scene the scne the object belongs to
  14128. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14129. * @returns a new TransformNode object parsed from the source provided.
  14130. */
  14131. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14132. /**
  14133. * Get all child-transformNodes of this node
  14134. * @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
  14135. * @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
  14136. * @returns an array of TransformNode
  14137. */
  14138. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14139. /**
  14140. * Releases resources associated with this transform node.
  14141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14143. */
  14144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14145. /**
  14146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14148. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14149. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14150. * @returns the current mesh
  14151. */
  14152. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14153. private _syncAbsoluteScalingAndRotation;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /**
  14158. * Defines the types of pose enabled controllers that are supported
  14159. */
  14160. export enum PoseEnabledControllerType {
  14161. /**
  14162. * HTC Vive
  14163. */
  14164. VIVE = 0,
  14165. /**
  14166. * Oculus Rift
  14167. */
  14168. OCULUS = 1,
  14169. /**
  14170. * Windows mixed reality
  14171. */
  14172. WINDOWS = 2,
  14173. /**
  14174. * Samsung gear VR
  14175. */
  14176. GEAR_VR = 3,
  14177. /**
  14178. * Google Daydream
  14179. */
  14180. DAYDREAM = 4,
  14181. /**
  14182. * Generic
  14183. */
  14184. GENERIC = 5
  14185. }
  14186. /**
  14187. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14188. */
  14189. export interface MutableGamepadButton {
  14190. /**
  14191. * Value of the button/trigger
  14192. */
  14193. value: number;
  14194. /**
  14195. * If the button/trigger is currently touched
  14196. */
  14197. touched: boolean;
  14198. /**
  14199. * If the button/trigger is currently pressed
  14200. */
  14201. pressed: boolean;
  14202. }
  14203. /**
  14204. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14205. * @hidden
  14206. */
  14207. export interface ExtendedGamepadButton extends GamepadButton {
  14208. /**
  14209. * If the button/trigger is currently pressed
  14210. */
  14211. readonly pressed: boolean;
  14212. /**
  14213. * If the button/trigger is currently touched
  14214. */
  14215. readonly touched: boolean;
  14216. /**
  14217. * Value of the button/trigger
  14218. */
  14219. readonly value: number;
  14220. }
  14221. /** @hidden */
  14222. export interface _GamePadFactory {
  14223. /**
  14224. * Returns wether or not the current gamepad can be created for this type of controller.
  14225. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14226. * @returns true if it can be created, otherwise false
  14227. */
  14228. canCreate(gamepadInfo: any): boolean;
  14229. /**
  14230. * Creates a new instance of the Gamepad.
  14231. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14232. * @returns the new gamepad instance
  14233. */
  14234. create(gamepadInfo: any): Gamepad;
  14235. }
  14236. /**
  14237. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14238. */
  14239. export class PoseEnabledControllerHelper {
  14240. /** @hidden */
  14241. static _ControllerFactories: _GamePadFactory[];
  14242. /** @hidden */
  14243. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14244. /**
  14245. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14246. * @param vrGamepad the gamepad to initialized
  14247. * @returns a vr controller of the type the gamepad identified as
  14248. */
  14249. static InitiateController(vrGamepad: any): Gamepad;
  14250. }
  14251. /**
  14252. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14253. */
  14254. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14255. /**
  14256. * If the controller is used in a webXR session
  14257. */
  14258. isXR: boolean;
  14259. private _deviceRoomPosition;
  14260. private _deviceRoomRotationQuaternion;
  14261. /**
  14262. * The device position in babylon space
  14263. */
  14264. devicePosition: Vector3;
  14265. /**
  14266. * The device rotation in babylon space
  14267. */
  14268. deviceRotationQuaternion: Quaternion;
  14269. /**
  14270. * The scale factor of the device in babylon space
  14271. */
  14272. deviceScaleFactor: number;
  14273. /**
  14274. * (Likely devicePosition should be used instead) The device position in its room space
  14275. */
  14276. position: Vector3;
  14277. /**
  14278. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14279. */
  14280. rotationQuaternion: Quaternion;
  14281. /**
  14282. * The type of controller (Eg. Windows mixed reality)
  14283. */
  14284. controllerType: PoseEnabledControllerType;
  14285. protected _calculatedPosition: Vector3;
  14286. private _calculatedRotation;
  14287. /**
  14288. * The raw pose from the device
  14289. */
  14290. rawPose: DevicePose;
  14291. private _trackPosition;
  14292. private _maxRotationDistFromHeadset;
  14293. private _draggedRoomRotation;
  14294. /**
  14295. * @hidden
  14296. */
  14297. _disableTrackPosition(fixedPosition: Vector3): void;
  14298. /**
  14299. * Internal, the mesh attached to the controller
  14300. * @hidden
  14301. */
  14302. _mesh: Nullable<AbstractMesh>;
  14303. private _poseControlledCamera;
  14304. private _leftHandSystemQuaternion;
  14305. /**
  14306. * Internal, matrix used to convert room space to babylon space
  14307. * @hidden
  14308. */
  14309. _deviceToWorld: Matrix;
  14310. /**
  14311. * Node to be used when casting a ray from the controller
  14312. * @hidden
  14313. */
  14314. _pointingPoseNode: Nullable<TransformNode>;
  14315. /**
  14316. * Name of the child mesh that can be used to cast a ray from the controller
  14317. */
  14318. static readonly POINTING_POSE: string;
  14319. /**
  14320. * Creates a new PoseEnabledController from a gamepad
  14321. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14322. */
  14323. constructor(browserGamepad: any);
  14324. private _workingMatrix;
  14325. /**
  14326. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14327. */
  14328. update(): void;
  14329. /**
  14330. * Updates only the pose device and mesh without doing any button event checking
  14331. */
  14332. protected _updatePoseAndMesh(): void;
  14333. /**
  14334. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14335. * @param poseData raw pose fromthe device
  14336. */
  14337. updateFromDevice(poseData: DevicePose): void;
  14338. /**
  14339. * @hidden
  14340. */
  14341. _meshAttachedObservable: Observable<AbstractMesh>;
  14342. /**
  14343. * Attaches a mesh to the controller
  14344. * @param mesh the mesh to be attached
  14345. */
  14346. attachToMesh(mesh: AbstractMesh): void;
  14347. /**
  14348. * Attaches the controllers mesh to a camera
  14349. * @param camera the camera the mesh should be attached to
  14350. */
  14351. attachToPoseControlledCamera(camera: TargetCamera): void;
  14352. /**
  14353. * Disposes of the controller
  14354. */
  14355. dispose(): void;
  14356. /**
  14357. * The mesh that is attached to the controller
  14358. */
  14359. readonly mesh: Nullable<AbstractMesh>;
  14360. /**
  14361. * Gets the ray of the controller in the direction the controller is pointing
  14362. * @param length the length the resulting ray should be
  14363. * @returns a ray in the direction the controller is pointing
  14364. */
  14365. getForwardRay(length?: number): Ray;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * Defines the WebVRController object that represents controllers tracked in 3D space
  14371. */
  14372. export abstract class WebVRController extends PoseEnabledController {
  14373. /**
  14374. * Internal, the default controller model for the controller
  14375. */
  14376. protected _defaultModel: AbstractMesh;
  14377. /**
  14378. * Fired when the trigger state has changed
  14379. */
  14380. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14381. /**
  14382. * Fired when the main button state has changed
  14383. */
  14384. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14385. /**
  14386. * Fired when the secondary button state has changed
  14387. */
  14388. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14389. /**
  14390. * Fired when the pad state has changed
  14391. */
  14392. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14393. /**
  14394. * Fired when controllers stick values have changed
  14395. */
  14396. onPadValuesChangedObservable: Observable<StickValues>;
  14397. /**
  14398. * Array of button availible on the controller
  14399. */
  14400. protected _buttons: Array<MutableGamepadButton>;
  14401. private _onButtonStateChange;
  14402. /**
  14403. * Fired when a controller button's state has changed
  14404. * @param callback the callback containing the button that was modified
  14405. */
  14406. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14407. /**
  14408. * X and Y axis corresponding to the controllers joystick
  14409. */
  14410. pad: StickValues;
  14411. /**
  14412. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14413. */
  14414. hand: string;
  14415. /**
  14416. * The default controller model for the controller
  14417. */
  14418. readonly defaultModel: AbstractMesh;
  14419. /**
  14420. * Creates a new WebVRController from a gamepad
  14421. * @param vrGamepad the gamepad that the WebVRController should be created from
  14422. */
  14423. constructor(vrGamepad: any);
  14424. /**
  14425. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14426. */
  14427. update(): void;
  14428. /**
  14429. * Function to be called when a button is modified
  14430. */
  14431. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14432. /**
  14433. * Loads a mesh and attaches it to the controller
  14434. * @param scene the scene the mesh should be added to
  14435. * @param meshLoaded callback for when the mesh has been loaded
  14436. */
  14437. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14438. private _setButtonValue;
  14439. private _changes;
  14440. private _checkChanges;
  14441. /**
  14442. * Disposes of th webVRCOntroller
  14443. */
  14444. dispose(): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * The HemisphericLight simulates the ambient environment light,
  14450. * so the passed direction is the light reflection direction, not the incoming direction.
  14451. */
  14452. export class HemisphericLight extends Light {
  14453. /**
  14454. * The groundColor is the light in the opposite direction to the one specified during creation.
  14455. * 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.
  14456. */
  14457. groundColor: Color3;
  14458. /**
  14459. * The light reflection direction, not the incoming direction.
  14460. */
  14461. direction: Vector3;
  14462. /**
  14463. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14464. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14465. * The HemisphericLight can't cast shadows.
  14466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14467. * @param name The friendly name of the light
  14468. * @param direction The direction of the light reflection
  14469. * @param scene The scene the light belongs to
  14470. */
  14471. constructor(name: string, direction: Vector3, scene: Scene);
  14472. protected _buildUniformLayout(): void;
  14473. /**
  14474. * Returns the string "HemisphericLight".
  14475. * @return The class name
  14476. */
  14477. getClassName(): string;
  14478. /**
  14479. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14480. * Returns the updated direction.
  14481. * @param target The target the direction should point to
  14482. * @return The computed direction
  14483. */
  14484. setDirectionToTarget(target: Vector3): Vector3;
  14485. /**
  14486. * Returns the shadow generator associated to the light.
  14487. * @returns Always null for hemispheric lights because it does not support shadows.
  14488. */
  14489. getShadowGenerator(): Nullable<IShadowGenerator>;
  14490. /**
  14491. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14492. * @param effect The effect to update
  14493. * @param lightIndex The index of the light in the effect to update
  14494. * @returns The hemispheric light
  14495. */
  14496. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14498. /**
  14499. * Computes the world matrix of the node
  14500. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14501. * @param useWasUpdatedFlag defines a reserved property
  14502. * @returns the world matrix
  14503. */
  14504. computeWorldMatrix(): Matrix;
  14505. /**
  14506. * Returns the integer 3.
  14507. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14508. */
  14509. getTypeID(): number;
  14510. /**
  14511. * Prepares the list of defines specific to the light type.
  14512. * @param defines the list of defines
  14513. * @param lightIndex defines the index of the light for the effect
  14514. */
  14515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /** @hidden */
  14520. export var vrMultiviewToSingleviewPixelShader: {
  14521. name: string;
  14522. shader: string;
  14523. };
  14524. }
  14525. declare module BABYLON {
  14526. /**
  14527. * Renders to multiple views with a single draw call
  14528. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14529. */
  14530. export class MultiviewRenderTarget extends RenderTargetTexture {
  14531. /**
  14532. * Creates a multiview render target
  14533. * @param scene scene used with the render target
  14534. * @param size the size of the render target (used for each view)
  14535. */
  14536. constructor(scene: Scene, size?: number | {
  14537. width: number;
  14538. height: number;
  14539. } | {
  14540. ratio: number;
  14541. });
  14542. /**
  14543. * @hidden
  14544. * @param faceIndex the face index, if its a cube texture
  14545. */
  14546. _bindFrameBuffer(faceIndex?: number): void;
  14547. /**
  14548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14549. * @returns the view count
  14550. */
  14551. getViewCount(): number;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Reprasents a camera frustum
  14557. */
  14558. export class Frustum {
  14559. /**
  14560. * Gets the planes representing the frustum
  14561. * @param transform matrix to be applied to the returned planes
  14562. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14563. */
  14564. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14565. /**
  14566. * Gets the near frustum plane transformed by the transform matrix
  14567. * @param transform transformation matrix to be applied to the resulting frustum plane
  14568. * @param frustumPlane the resuling frustum plane
  14569. */
  14570. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Gets the far frustum plane transformed by the transform matrix
  14573. * @param transform transformation matrix to be applied to the resulting frustum plane
  14574. * @param frustumPlane the resuling frustum plane
  14575. */
  14576. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14577. /**
  14578. * Gets the left frustum plane transformed by the transform matrix
  14579. * @param transform transformation matrix to be applied to the resulting frustum plane
  14580. * @param frustumPlane the resuling frustum plane
  14581. */
  14582. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14583. /**
  14584. * Gets the right frustum plane transformed by the transform matrix
  14585. * @param transform transformation matrix to be applied to the resulting frustum plane
  14586. * @param frustumPlane the resuling frustum plane
  14587. */
  14588. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14589. /**
  14590. * Gets the top frustum plane transformed by the transform matrix
  14591. * @param transform transformation matrix to be applied to the resulting frustum plane
  14592. * @param frustumPlane the resuling frustum plane
  14593. */
  14594. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14595. /**
  14596. * Gets the bottom frustum plane transformed by the transform matrix
  14597. * @param transform transformation matrix to be applied to the resulting frustum plane
  14598. * @param frustumPlane the resuling frustum plane
  14599. */
  14600. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14601. /**
  14602. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14603. * @param transform transformation matrix to be applied to the resulting frustum planes
  14604. * @param frustumPlanes the resuling frustum planes
  14605. */
  14606. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. interface Engine {
  14611. /**
  14612. * Creates a new multiview render target
  14613. * @param width defines the width of the texture
  14614. * @param height defines the height of the texture
  14615. * @returns the created multiview texture
  14616. */
  14617. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14618. /**
  14619. * Binds a multiview framebuffer to be drawn to
  14620. * @param multiviewTexture texture to bind
  14621. */
  14622. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14623. }
  14624. interface Camera {
  14625. /**
  14626. * @hidden
  14627. * 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)
  14628. */
  14629. _useMultiviewToSingleView: boolean;
  14630. /**
  14631. * @hidden
  14632. * 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)
  14633. */
  14634. _multiviewTexture: Nullable<RenderTargetTexture>;
  14635. /**
  14636. * @hidden
  14637. * ensures the multiview texture of the camera exists and has the specified width/height
  14638. * @param width height to set on the multiview texture
  14639. * @param height width to set on the multiview texture
  14640. */
  14641. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14642. }
  14643. interface Scene {
  14644. /** @hidden */
  14645. _transformMatrixR: Matrix;
  14646. /** @hidden */
  14647. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14648. /** @hidden */
  14649. _createMultiviewUbo(): void;
  14650. /** @hidden */
  14651. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14652. /** @hidden */
  14653. _renderMultiviewToSingleView(camera: Camera): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /**
  14658. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14659. * This will not be used for webXR as it supports displaying texture arrays directly
  14660. */
  14661. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14662. /**
  14663. * Initializes a VRMultiviewToSingleview
  14664. * @param name name of the post process
  14665. * @param camera camera to be applied to
  14666. * @param scaleFactor scaling factor to the size of the output texture
  14667. */
  14668. constructor(name: string, camera: Camera, scaleFactor: number);
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. interface Engine {
  14673. /** @hidden */
  14674. _vrDisplay: any;
  14675. /** @hidden */
  14676. _vrSupported: boolean;
  14677. /** @hidden */
  14678. _oldSize: Size;
  14679. /** @hidden */
  14680. _oldHardwareScaleFactor: number;
  14681. /** @hidden */
  14682. _vrExclusivePointerMode: boolean;
  14683. /** @hidden */
  14684. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14685. /** @hidden */
  14686. _onVRDisplayPointerRestricted: () => void;
  14687. /** @hidden */
  14688. _onVRDisplayPointerUnrestricted: () => void;
  14689. /** @hidden */
  14690. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14691. /** @hidden */
  14692. _onVrDisplayDisconnect: Nullable<() => void>;
  14693. /** @hidden */
  14694. _onVrDisplayPresentChange: Nullable<() => void>;
  14695. /**
  14696. * Observable signaled when VR display mode changes
  14697. */
  14698. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14699. /**
  14700. * Observable signaled when VR request present is complete
  14701. */
  14702. onVRRequestPresentComplete: Observable<boolean>;
  14703. /**
  14704. * Observable signaled when VR request present starts
  14705. */
  14706. onVRRequestPresentStart: Observable<Engine>;
  14707. /**
  14708. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14709. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14710. */
  14711. isInVRExclusivePointerMode: boolean;
  14712. /**
  14713. * Gets a boolean indicating if a webVR device was detected
  14714. * @returns true if a webVR device was detected
  14715. */
  14716. isVRDevicePresent(): boolean;
  14717. /**
  14718. * Gets the current webVR device
  14719. * @returns the current webVR device (or null)
  14720. */
  14721. getVRDevice(): any;
  14722. /**
  14723. * Initializes a webVR display and starts listening to display change events
  14724. * The onVRDisplayChangedObservable will be notified upon these changes
  14725. * @returns A promise containing a VRDisplay and if vr is supported
  14726. */
  14727. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14728. /** @hidden */
  14729. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14730. /**
  14731. * Call this function to switch to webVR mode
  14732. * Will do nothing if webVR is not supported or if there is no webVR device
  14733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14734. */
  14735. enableVR(): void;
  14736. /** @hidden */
  14737. _onVRFullScreenTriggered(): void;
  14738. }
  14739. }
  14740. declare module BABYLON {
  14741. /**
  14742. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14743. * IMPORTANT!! The data is right-hand data.
  14744. * @export
  14745. * @interface DevicePose
  14746. */
  14747. export interface DevicePose {
  14748. /**
  14749. * The position of the device, values in array are [x,y,z].
  14750. */
  14751. readonly position: Nullable<Float32Array>;
  14752. /**
  14753. * The linearVelocity of the device, values in array are [x,y,z].
  14754. */
  14755. readonly linearVelocity: Nullable<Float32Array>;
  14756. /**
  14757. * The linearAcceleration of the device, values in array are [x,y,z].
  14758. */
  14759. readonly linearAcceleration: Nullable<Float32Array>;
  14760. /**
  14761. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14762. */
  14763. readonly orientation: Nullable<Float32Array>;
  14764. /**
  14765. * The angularVelocity of the device, values in array are [x,y,z].
  14766. */
  14767. readonly angularVelocity: Nullable<Float32Array>;
  14768. /**
  14769. * The angularAcceleration of the device, values in array are [x,y,z].
  14770. */
  14771. readonly angularAcceleration: Nullable<Float32Array>;
  14772. }
  14773. /**
  14774. * Interface representing a pose controlled object in Babylon.
  14775. * A pose controlled object has both regular pose values as well as pose values
  14776. * from an external device such as a VR head mounted display
  14777. */
  14778. export interface PoseControlled {
  14779. /**
  14780. * The position of the object in babylon space.
  14781. */
  14782. position: Vector3;
  14783. /**
  14784. * The rotation quaternion of the object in babylon space.
  14785. */
  14786. rotationQuaternion: Quaternion;
  14787. /**
  14788. * The position of the device in babylon space.
  14789. */
  14790. devicePosition?: Vector3;
  14791. /**
  14792. * The rotation quaternion of the device in babylon space.
  14793. */
  14794. deviceRotationQuaternion: Quaternion;
  14795. /**
  14796. * The raw pose coming from the device.
  14797. */
  14798. rawPose: Nullable<DevicePose>;
  14799. /**
  14800. * The scale of the device to be used when translating from device space to babylon space.
  14801. */
  14802. deviceScaleFactor: number;
  14803. /**
  14804. * Updates the poseControlled values based on the input device pose.
  14805. * @param poseData the pose data to update the object with
  14806. */
  14807. updateFromDevice(poseData: DevicePose): void;
  14808. }
  14809. /**
  14810. * Set of options to customize the webVRCamera
  14811. */
  14812. export interface WebVROptions {
  14813. /**
  14814. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14815. */
  14816. trackPosition?: boolean;
  14817. /**
  14818. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14819. */
  14820. positionScale?: number;
  14821. /**
  14822. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14823. */
  14824. displayName?: string;
  14825. /**
  14826. * Should the native controller meshes be initialized. (default: true)
  14827. */
  14828. controllerMeshes?: boolean;
  14829. /**
  14830. * Creating a default HemiLight only on controllers. (default: true)
  14831. */
  14832. defaultLightingOnControllers?: boolean;
  14833. /**
  14834. * If you don't want to use the default VR button of the helper. (default: false)
  14835. */
  14836. useCustomVRButton?: boolean;
  14837. /**
  14838. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14839. */
  14840. customVRButton?: HTMLButtonElement;
  14841. /**
  14842. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14843. */
  14844. rayLength?: number;
  14845. /**
  14846. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14847. */
  14848. defaultHeight?: number;
  14849. /**
  14850. * If multiview should be used if availible (default: false)
  14851. */
  14852. useMultiview?: boolean;
  14853. }
  14854. /**
  14855. * This represents a WebVR camera.
  14856. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14857. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14858. */
  14859. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14860. private webVROptions;
  14861. /**
  14862. * @hidden
  14863. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14864. */
  14865. _vrDevice: any;
  14866. /**
  14867. * The rawPose of the vrDevice.
  14868. */
  14869. rawPose: Nullable<DevicePose>;
  14870. private _onVREnabled;
  14871. private _specsVersion;
  14872. private _attached;
  14873. private _frameData;
  14874. protected _descendants: Array<Node>;
  14875. private _deviceRoomPosition;
  14876. /** @hidden */
  14877. _deviceRoomRotationQuaternion: Quaternion;
  14878. private _standingMatrix;
  14879. /**
  14880. * Represents device position in babylon space.
  14881. */
  14882. devicePosition: Vector3;
  14883. /**
  14884. * Represents device rotation in babylon space.
  14885. */
  14886. deviceRotationQuaternion: Quaternion;
  14887. /**
  14888. * The scale of the device to be used when translating from device space to babylon space.
  14889. */
  14890. deviceScaleFactor: number;
  14891. private _deviceToWorld;
  14892. private _worldToDevice;
  14893. /**
  14894. * References to the webVR controllers for the vrDevice.
  14895. */
  14896. controllers: Array<WebVRController>;
  14897. /**
  14898. * Emits an event when a controller is attached.
  14899. */
  14900. onControllersAttachedObservable: Observable<WebVRController[]>;
  14901. /**
  14902. * Emits an event when a controller's mesh has been loaded;
  14903. */
  14904. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14905. /**
  14906. * Emits an event when the HMD's pose has been updated.
  14907. */
  14908. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14909. private _poseSet;
  14910. /**
  14911. * If the rig cameras be used as parent instead of this camera.
  14912. */
  14913. rigParenting: boolean;
  14914. private _lightOnControllers;
  14915. private _defaultHeight?;
  14916. /**
  14917. * Instantiates a WebVRFreeCamera.
  14918. * @param name The name of the WebVRFreeCamera
  14919. * @param position The starting anchor position for the camera
  14920. * @param scene The scene the camera belongs to
  14921. * @param webVROptions a set of customizable options for the webVRCamera
  14922. */
  14923. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14924. /**
  14925. * Gets the device distance from the ground in meters.
  14926. * @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.
  14927. */
  14928. deviceDistanceToRoomGround(): number;
  14929. /**
  14930. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14931. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14932. */
  14933. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14934. /**
  14935. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14936. * @returns A promise with a boolean set to if the standing matrix is supported.
  14937. */
  14938. useStandingMatrixAsync(): Promise<boolean>;
  14939. /**
  14940. * Disposes the camera
  14941. */
  14942. dispose(): void;
  14943. /**
  14944. * Gets a vrController by name.
  14945. * @param name The name of the controller to retreive
  14946. * @returns the controller matching the name specified or null if not found
  14947. */
  14948. getControllerByName(name: string): Nullable<WebVRController>;
  14949. private _leftController;
  14950. /**
  14951. * The controller corresponding to the users left hand.
  14952. */
  14953. readonly leftController: Nullable<WebVRController>;
  14954. private _rightController;
  14955. /**
  14956. * The controller corresponding to the users right hand.
  14957. */
  14958. readonly rightController: Nullable<WebVRController>;
  14959. /**
  14960. * Casts a ray forward from the vrCamera's gaze.
  14961. * @param length Length of the ray (default: 100)
  14962. * @returns the ray corresponding to the gaze
  14963. */
  14964. getForwardRay(length?: number): Ray;
  14965. /**
  14966. * @hidden
  14967. * Updates the camera based on device's frame data
  14968. */
  14969. _checkInputs(): void;
  14970. /**
  14971. * Updates the poseControlled values based on the input device pose.
  14972. * @param poseData Pose coming from the device
  14973. */
  14974. updateFromDevice(poseData: DevicePose): void;
  14975. private _htmlElementAttached;
  14976. private _detachIfAttached;
  14977. /**
  14978. * WebVR's attach control will start broadcasting frames to the device.
  14979. * Note that in certain browsers (chrome for example) this function must be called
  14980. * within a user-interaction callback. Example:
  14981. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14982. *
  14983. * @param element html element to attach the vrDevice to
  14984. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14985. */
  14986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14987. /**
  14988. * Detaches the camera from the html element and disables VR
  14989. *
  14990. * @param element html element to detach from
  14991. */
  14992. detachControl(element: HTMLElement): void;
  14993. /**
  14994. * @returns the name of this class
  14995. */
  14996. getClassName(): string;
  14997. /**
  14998. * Calls resetPose on the vrDisplay
  14999. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15000. */
  15001. resetToCurrentRotation(): void;
  15002. /**
  15003. * @hidden
  15004. * Updates the rig cameras (left and right eye)
  15005. */
  15006. _updateRigCameras(): void;
  15007. private _workingVector;
  15008. private _oneVector;
  15009. private _workingMatrix;
  15010. private updateCacheCalled;
  15011. private _correctPositionIfNotTrackPosition;
  15012. /**
  15013. * @hidden
  15014. * Updates the cached values of the camera
  15015. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15016. */
  15017. _updateCache(ignoreParentClass?: boolean): void;
  15018. /**
  15019. * @hidden
  15020. * Get current device position in babylon world
  15021. */
  15022. _computeDevicePosition(): void;
  15023. /**
  15024. * Updates the current device position and rotation in the babylon world
  15025. */
  15026. update(): void;
  15027. /**
  15028. * @hidden
  15029. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15030. * @returns an identity matrix
  15031. */
  15032. _getViewMatrix(): Matrix;
  15033. private _tmpMatrix;
  15034. /**
  15035. * This function is called by the two RIG cameras.
  15036. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15037. * @hidden
  15038. */
  15039. _getWebVRViewMatrix(): Matrix;
  15040. /** @hidden */
  15041. _getWebVRProjectionMatrix(): Matrix;
  15042. private _onGamepadConnectedObserver;
  15043. private _onGamepadDisconnectedObserver;
  15044. private _updateCacheWhenTrackingDisabledObserver;
  15045. /**
  15046. * Initializes the controllers and their meshes
  15047. */
  15048. initControllers(): void;
  15049. }
  15050. }
  15051. declare module BABYLON {
  15052. /**
  15053. * Size options for a post process
  15054. */
  15055. export type PostProcessOptions = {
  15056. width: number;
  15057. height: number;
  15058. };
  15059. /**
  15060. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15061. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15062. */
  15063. export class PostProcess {
  15064. /** Name of the PostProcess. */
  15065. name: string;
  15066. /**
  15067. * Gets or sets the unique id of the post process
  15068. */
  15069. uniqueId: number;
  15070. /**
  15071. * Width of the texture to apply the post process on
  15072. */
  15073. width: number;
  15074. /**
  15075. * Height of the texture to apply the post process on
  15076. */
  15077. height: number;
  15078. /**
  15079. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15080. * @hidden
  15081. */
  15082. _outputTexture: Nullable<InternalTexture>;
  15083. /**
  15084. * Sampling mode used by the shader
  15085. * See https://doc.babylonjs.com/classes/3.1/texture
  15086. */
  15087. renderTargetSamplingMode: number;
  15088. /**
  15089. * Clear color to use when screen clearing
  15090. */
  15091. clearColor: Color4;
  15092. /**
  15093. * If the buffer needs to be cleared before applying the post process. (default: true)
  15094. * Should be set to false if shader will overwrite all previous pixels.
  15095. */
  15096. autoClear: boolean;
  15097. /**
  15098. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15099. */
  15100. alphaMode: number;
  15101. /**
  15102. * Sets the setAlphaBlendConstants of the babylon engine
  15103. */
  15104. alphaConstants: Color4;
  15105. /**
  15106. * Animations to be used for the post processing
  15107. */
  15108. animations: Animation[];
  15109. /**
  15110. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15111. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15112. */
  15113. enablePixelPerfectMode: boolean;
  15114. /**
  15115. * Force the postprocess to be applied without taking in account viewport
  15116. */
  15117. forceFullscreenViewport: boolean;
  15118. /**
  15119. * List of inspectable custom properties (used by the Inspector)
  15120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15121. */
  15122. inspectableCustomProperties: IInspectable[];
  15123. /**
  15124. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15125. *
  15126. * | Value | Type | Description |
  15127. * | ----- | ----------------------------------- | ----------- |
  15128. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15129. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15130. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15131. *
  15132. */
  15133. scaleMode: number;
  15134. /**
  15135. * Force textures to be a power of two (default: false)
  15136. */
  15137. alwaysForcePOT: boolean;
  15138. private _samples;
  15139. /**
  15140. * Number of sample textures (default: 1)
  15141. */
  15142. samples: number;
  15143. /**
  15144. * Modify the scale of the post process to be the same as the viewport (default: false)
  15145. */
  15146. adaptScaleToCurrentViewport: boolean;
  15147. private _camera;
  15148. private _scene;
  15149. private _engine;
  15150. private _options;
  15151. private _reusable;
  15152. private _textureType;
  15153. /**
  15154. * Smart array of input and output textures for the post process.
  15155. * @hidden
  15156. */
  15157. _textures: SmartArray<InternalTexture>;
  15158. /**
  15159. * The index in _textures that corresponds to the output texture.
  15160. * @hidden
  15161. */
  15162. _currentRenderTextureInd: number;
  15163. private _effect;
  15164. private _samplers;
  15165. private _fragmentUrl;
  15166. private _vertexUrl;
  15167. private _parameters;
  15168. private _scaleRatio;
  15169. protected _indexParameters: any;
  15170. private _shareOutputWithPostProcess;
  15171. private _texelSize;
  15172. private _forcedOutputTexture;
  15173. /**
  15174. * Returns the fragment url or shader name used in the post process.
  15175. * @returns the fragment url or name in the shader store.
  15176. */
  15177. getEffectName(): string;
  15178. /**
  15179. * An event triggered when the postprocess is activated.
  15180. */
  15181. onActivateObservable: Observable<Camera>;
  15182. private _onActivateObserver;
  15183. /**
  15184. * A function that is added to the onActivateObservable
  15185. */
  15186. onActivate: Nullable<(camera: Camera) => void>;
  15187. /**
  15188. * An event triggered when the postprocess changes its size.
  15189. */
  15190. onSizeChangedObservable: Observable<PostProcess>;
  15191. private _onSizeChangedObserver;
  15192. /**
  15193. * A function that is added to the onSizeChangedObservable
  15194. */
  15195. onSizeChanged: (postProcess: PostProcess) => void;
  15196. /**
  15197. * An event triggered when the postprocess applies its effect.
  15198. */
  15199. onApplyObservable: Observable<Effect>;
  15200. private _onApplyObserver;
  15201. /**
  15202. * A function that is added to the onApplyObservable
  15203. */
  15204. onApply: (effect: Effect) => void;
  15205. /**
  15206. * An event triggered before rendering the postprocess
  15207. */
  15208. onBeforeRenderObservable: Observable<Effect>;
  15209. private _onBeforeRenderObserver;
  15210. /**
  15211. * A function that is added to the onBeforeRenderObservable
  15212. */
  15213. onBeforeRender: (effect: Effect) => void;
  15214. /**
  15215. * An event triggered after rendering the postprocess
  15216. */
  15217. onAfterRenderObservable: Observable<Effect>;
  15218. private _onAfterRenderObserver;
  15219. /**
  15220. * A function that is added to the onAfterRenderObservable
  15221. */
  15222. onAfterRender: (efect: Effect) => void;
  15223. /**
  15224. * 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
  15225. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15226. */
  15227. inputTexture: InternalTexture;
  15228. /**
  15229. * Gets the camera which post process is applied to.
  15230. * @returns The camera the post process is applied to.
  15231. */
  15232. getCamera(): Camera;
  15233. /**
  15234. * Gets the texel size of the postprocess.
  15235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15236. */
  15237. readonly texelSize: Vector2;
  15238. /**
  15239. * Creates a new instance PostProcess
  15240. * @param name The name of the PostProcess.
  15241. * @param fragmentUrl The url of the fragment shader to be used.
  15242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15245. * @param camera The camera to apply the render pass to.
  15246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15247. * @param engine The engine which the post process will be applied. (default: current engine)
  15248. * @param reusable If the post process can be reused on the same frame. (default: false)
  15249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15250. * @param textureType Type of textures used when performing the post process. (default: 0)
  15251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15252. * @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
  15253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15254. */
  15255. constructor(
  15256. /** Name of the PostProcess. */
  15257. 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);
  15258. /**
  15259. * Gets a string idenfifying the name of the class
  15260. * @returns "PostProcess" string
  15261. */
  15262. getClassName(): string;
  15263. /**
  15264. * Gets the engine which this post process belongs to.
  15265. * @returns The engine the post process was enabled with.
  15266. */
  15267. getEngine(): Engine;
  15268. /**
  15269. * The effect that is created when initializing the post process.
  15270. * @returns The created effect corresponding the the postprocess.
  15271. */
  15272. getEffect(): Effect;
  15273. /**
  15274. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15275. * @param postProcess The post process to share the output with.
  15276. * @returns This post process.
  15277. */
  15278. shareOutputWith(postProcess: PostProcess): PostProcess;
  15279. /**
  15280. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15281. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15282. */
  15283. useOwnOutput(): void;
  15284. /**
  15285. * Updates the effect with the current post process compile time values and recompiles the shader.
  15286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15289. * @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
  15290. * @param onCompiled Called when the shader has been compiled.
  15291. * @param onError Called if there is an error when compiling a shader.
  15292. */
  15293. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15294. /**
  15295. * The post process is reusable if it can be used multiple times within one frame.
  15296. * @returns If the post process is reusable
  15297. */
  15298. isReusable(): boolean;
  15299. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15300. markTextureDirty(): void;
  15301. /**
  15302. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15303. * 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.
  15304. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15305. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15306. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15307. * @returns The target texture that was bound to be written to.
  15308. */
  15309. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15310. /**
  15311. * If the post process is supported.
  15312. */
  15313. readonly isSupported: boolean;
  15314. /**
  15315. * The aspect ratio of the output texture.
  15316. */
  15317. readonly aspectRatio: number;
  15318. /**
  15319. * Get a value indicating if the post-process is ready to be used
  15320. * @returns true if the post-process is ready (shader is compiled)
  15321. */
  15322. isReady(): boolean;
  15323. /**
  15324. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15325. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15326. */
  15327. apply(): Nullable<Effect>;
  15328. private _disposeTextures;
  15329. /**
  15330. * Disposes the post process.
  15331. * @param camera The camera to dispose the post process on.
  15332. */
  15333. dispose(camera?: Camera): void;
  15334. }
  15335. }
  15336. declare module BABYLON {
  15337. /** @hidden */
  15338. export var kernelBlurVaryingDeclaration: {
  15339. name: string;
  15340. shader: string;
  15341. };
  15342. }
  15343. declare module BABYLON {
  15344. /** @hidden */
  15345. export var kernelBlurFragment: {
  15346. name: string;
  15347. shader: string;
  15348. };
  15349. }
  15350. declare module BABYLON {
  15351. /** @hidden */
  15352. export var kernelBlurFragment2: {
  15353. name: string;
  15354. shader: string;
  15355. };
  15356. }
  15357. declare module BABYLON {
  15358. /** @hidden */
  15359. export var kernelBlurPixelShader: {
  15360. name: string;
  15361. shader: string;
  15362. };
  15363. }
  15364. declare module BABYLON {
  15365. /** @hidden */
  15366. export var kernelBlurVertex: {
  15367. name: string;
  15368. shader: string;
  15369. };
  15370. }
  15371. declare module BABYLON {
  15372. /** @hidden */
  15373. export var kernelBlurVertexShader: {
  15374. name: string;
  15375. shader: string;
  15376. };
  15377. }
  15378. declare module BABYLON {
  15379. /**
  15380. * The Blur Post Process which blurs an image based on a kernel and direction.
  15381. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15382. */
  15383. export class BlurPostProcess extends PostProcess {
  15384. /** The direction in which to blur the image. */
  15385. direction: Vector2;
  15386. private blockCompilation;
  15387. protected _kernel: number;
  15388. protected _idealKernel: number;
  15389. protected _packedFloat: boolean;
  15390. private _staticDefines;
  15391. /**
  15392. * Sets the length in pixels of the blur sample region
  15393. */
  15394. /**
  15395. * Gets the length in pixels of the blur sample region
  15396. */
  15397. kernel: number;
  15398. /**
  15399. * Sets wether or not the blur needs to unpack/repack floats
  15400. */
  15401. /**
  15402. * Gets wether or not the blur is unpacking/repacking floats
  15403. */
  15404. packedFloat: boolean;
  15405. /**
  15406. * Creates a new instance BlurPostProcess
  15407. * @param name The name of the effect.
  15408. * @param direction The direction in which to blur the image.
  15409. * @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.
  15410. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15411. * @param camera The camera to apply the render pass to.
  15412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15413. * @param engine The engine which the post process will be applied. (default: current engine)
  15414. * @param reusable If the post process can be reused on the same frame. (default: false)
  15415. * @param textureType Type of textures used when performing the post process. (default: 0)
  15416. * @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)
  15417. */
  15418. constructor(name: string,
  15419. /** The direction in which to blur the image. */
  15420. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15421. /**
  15422. * Updates the effect with the current post process compile time values and recompiles the shader.
  15423. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15424. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15425. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15426. * @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
  15427. * @param onCompiled Called when the shader has been compiled.
  15428. * @param onError Called if there is an error when compiling a shader.
  15429. */
  15430. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15431. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15432. /**
  15433. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15434. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15435. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15436. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15437. * The gaps between physical kernels are compensated for in the weighting of the samples
  15438. * @param idealKernel Ideal blur kernel.
  15439. * @return Nearest best kernel.
  15440. */
  15441. protected _nearestBestKernel(idealKernel: number): number;
  15442. /**
  15443. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15444. * @param x The point on the Gaussian distribution to sample.
  15445. * @return the value of the Gaussian function at x.
  15446. */
  15447. protected _gaussianWeight(x: number): number;
  15448. /**
  15449. * Generates a string that can be used as a floating point number in GLSL.
  15450. * @param x Value to print.
  15451. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15452. * @return GLSL float string.
  15453. */
  15454. protected _glslFloat(x: number, decimalFigures?: number): string;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15460. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15461. * You can then easily use it as a reflectionTexture on a flat surface.
  15462. * In case the surface is not a plane, please consider relying on reflection probes.
  15463. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15464. */
  15465. export class MirrorTexture extends RenderTargetTexture {
  15466. private scene;
  15467. /**
  15468. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15469. * 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.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. */
  15472. mirrorPlane: Plane;
  15473. /**
  15474. * Define the blur ratio used to blur the reflection if needed.
  15475. */
  15476. blurRatio: number;
  15477. /**
  15478. * Define the adaptive blur kernel used to blur the reflection if needed.
  15479. * This will autocompute the closest best match for the `blurKernel`
  15480. */
  15481. adaptiveBlurKernel: number;
  15482. /**
  15483. * Define the blur kernel used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernel: number;
  15487. /**
  15488. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelX: number;
  15492. /**
  15493. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15494. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15495. */
  15496. blurKernelY: number;
  15497. private _autoComputeBlurKernel;
  15498. protected _onRatioRescale(): void;
  15499. private _updateGammaSpace;
  15500. private _imageProcessingConfigChangeObserver;
  15501. private _transformMatrix;
  15502. private _mirrorMatrix;
  15503. private _savedViewMatrix;
  15504. private _blurX;
  15505. private _blurY;
  15506. private _adaptiveBlurKernel;
  15507. private _blurKernelX;
  15508. private _blurKernelY;
  15509. private _blurRatio;
  15510. /**
  15511. * Instantiates a Mirror Texture.
  15512. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15513. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15514. * You can then easily use it as a reflectionTexture on a flat surface.
  15515. * In case the surface is not a plane, please consider relying on reflection probes.
  15516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15517. * @param name
  15518. * @param size
  15519. * @param scene
  15520. * @param generateMipMaps
  15521. * @param type
  15522. * @param samplingMode
  15523. * @param generateDepthBuffer
  15524. */
  15525. constructor(name: string, size: number | {
  15526. width: number;
  15527. height: number;
  15528. } | {
  15529. ratio: number;
  15530. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15531. private _preparePostProcesses;
  15532. /**
  15533. * Clone the mirror texture.
  15534. * @returns the cloned texture
  15535. */
  15536. clone(): MirrorTexture;
  15537. /**
  15538. * Serialize the texture to a JSON representation you could use in Parse later on
  15539. * @returns the serialized JSON representation
  15540. */
  15541. serialize(): any;
  15542. /**
  15543. * Dispose the texture and release its associated resources.
  15544. */
  15545. dispose(): void;
  15546. }
  15547. }
  15548. declare module BABYLON {
  15549. /**
  15550. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15551. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15552. */
  15553. export class Texture extends BaseTexture {
  15554. /** @hidden */
  15555. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15556. /** @hidden */
  15557. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15558. /** @hidden */
  15559. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15560. /** nearest is mag = nearest and min = nearest and mip = linear */
  15561. static readonly NEAREST_SAMPLINGMODE: number;
  15562. /** nearest is mag = nearest and min = nearest and mip = linear */
  15563. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15565. static readonly BILINEAR_SAMPLINGMODE: number;
  15566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15567. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15568. /** Trilinear is mag = linear and min = linear and mip = linear */
  15569. static readonly TRILINEAR_SAMPLINGMODE: number;
  15570. /** Trilinear is mag = linear and min = linear and mip = linear */
  15571. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15572. /** mag = nearest and min = nearest and mip = nearest */
  15573. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15574. /** mag = nearest and min = linear and mip = nearest */
  15575. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15576. /** mag = nearest and min = linear and mip = linear */
  15577. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15578. /** mag = nearest and min = linear and mip = none */
  15579. static readonly NEAREST_LINEAR: number;
  15580. /** mag = nearest and min = nearest and mip = none */
  15581. static readonly NEAREST_NEAREST: number;
  15582. /** mag = linear and min = nearest and mip = nearest */
  15583. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15584. /** mag = linear and min = nearest and mip = linear */
  15585. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15586. /** mag = linear and min = linear and mip = none */
  15587. static readonly LINEAR_LINEAR: number;
  15588. /** mag = linear and min = nearest and mip = none */
  15589. static readonly LINEAR_NEAREST: number;
  15590. /** Explicit coordinates mode */
  15591. static readonly EXPLICIT_MODE: number;
  15592. /** Spherical coordinates mode */
  15593. static readonly SPHERICAL_MODE: number;
  15594. /** Planar coordinates mode */
  15595. static readonly PLANAR_MODE: number;
  15596. /** Cubic coordinates mode */
  15597. static readonly CUBIC_MODE: number;
  15598. /** Projection coordinates mode */
  15599. static readonly PROJECTION_MODE: number;
  15600. /** Inverse Cubic coordinates mode */
  15601. static readonly SKYBOX_MODE: number;
  15602. /** Inverse Cubic coordinates mode */
  15603. static readonly INVCUBIC_MODE: number;
  15604. /** Equirectangular coordinates mode */
  15605. static readonly EQUIRECTANGULAR_MODE: number;
  15606. /** Equirectangular Fixed coordinates mode */
  15607. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15608. /** Equirectangular Fixed Mirrored coordinates mode */
  15609. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15610. /** Texture is not repeating outside of 0..1 UVs */
  15611. static readonly CLAMP_ADDRESSMODE: number;
  15612. /** Texture is repeating outside of 0..1 UVs */
  15613. static readonly WRAP_ADDRESSMODE: number;
  15614. /** Texture is repeating and mirrored */
  15615. static readonly MIRROR_ADDRESSMODE: number;
  15616. /**
  15617. * 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
  15618. */
  15619. static UseSerializedUrlIfAny: boolean;
  15620. /**
  15621. * Define the url of the texture.
  15622. */
  15623. url: Nullable<string>;
  15624. /**
  15625. * Define an offset on the texture to offset the u coordinates of the UVs
  15626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15627. */
  15628. uOffset: number;
  15629. /**
  15630. * Define an offset on the texture to offset the v coordinates of the UVs
  15631. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15632. */
  15633. vOffset: number;
  15634. /**
  15635. * Define an offset on the texture to scale the u coordinates of the UVs
  15636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15637. */
  15638. uScale: number;
  15639. /**
  15640. * Define an offset on the texture to scale the v coordinates of the UVs
  15641. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15642. */
  15643. vScale: number;
  15644. /**
  15645. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15646. * @see http://doc.babylonjs.com/how_to/more_materials
  15647. */
  15648. uAng: number;
  15649. /**
  15650. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15651. * @see http://doc.babylonjs.com/how_to/more_materials
  15652. */
  15653. vAng: number;
  15654. /**
  15655. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15656. * @see http://doc.babylonjs.com/how_to/more_materials
  15657. */
  15658. wAng: number;
  15659. /**
  15660. * Defines the center of rotation (U)
  15661. */
  15662. uRotationCenter: number;
  15663. /**
  15664. * Defines the center of rotation (V)
  15665. */
  15666. vRotationCenter: number;
  15667. /**
  15668. * Defines the center of rotation (W)
  15669. */
  15670. wRotationCenter: number;
  15671. /**
  15672. * Are mip maps generated for this texture or not.
  15673. */
  15674. readonly noMipmap: boolean;
  15675. /**
  15676. * List of inspectable custom properties (used by the Inspector)
  15677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15678. */
  15679. inspectableCustomProperties: Nullable<IInspectable[]>;
  15680. private _noMipmap;
  15681. /** @hidden */
  15682. _invertY: boolean;
  15683. private _rowGenerationMatrix;
  15684. private _cachedTextureMatrix;
  15685. private _projectionModeMatrix;
  15686. private _t0;
  15687. private _t1;
  15688. private _t2;
  15689. private _cachedUOffset;
  15690. private _cachedVOffset;
  15691. private _cachedUScale;
  15692. private _cachedVScale;
  15693. private _cachedUAng;
  15694. private _cachedVAng;
  15695. private _cachedWAng;
  15696. private _cachedProjectionMatrixId;
  15697. private _cachedCoordinatesMode;
  15698. /** @hidden */
  15699. protected _initialSamplingMode: number;
  15700. /** @hidden */
  15701. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15702. private _deleteBuffer;
  15703. protected _format: Nullable<number>;
  15704. private _delayedOnLoad;
  15705. private _delayedOnError;
  15706. /**
  15707. * Observable triggered once the texture has been loaded.
  15708. */
  15709. onLoadObservable: Observable<Texture>;
  15710. protected _isBlocking: boolean;
  15711. /**
  15712. * Is the texture preventing material to render while loading.
  15713. * If false, a default texture will be used instead of the loading one during the preparation step.
  15714. */
  15715. isBlocking: boolean;
  15716. /**
  15717. * Get the current sampling mode associated with the texture.
  15718. */
  15719. readonly samplingMode: number;
  15720. /**
  15721. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15722. */
  15723. readonly invertY: boolean;
  15724. /**
  15725. * Instantiates a new texture.
  15726. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15727. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15728. * @param url define the url of the picture to load as a texture
  15729. * @param scene define the scene or engine the texture will belong to
  15730. * @param noMipmap define if the texture will require mip maps or not
  15731. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15732. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15733. * @param onLoad define a callback triggered when the texture has been loaded
  15734. * @param onError define a callback triggered when an error occurred during the loading session
  15735. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15736. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15738. */
  15739. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15740. /**
  15741. * Update the url (and optional buffer) of this texture if url was null during construction.
  15742. * @param url the url of the texture
  15743. * @param buffer the buffer of the texture (defaults to null)
  15744. * @param onLoad callback called when the texture is loaded (defaults to null)
  15745. */
  15746. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15747. /**
  15748. * Finish the loading sequence of a texture flagged as delayed load.
  15749. * @hidden
  15750. */
  15751. delayLoad(): void;
  15752. private _prepareRowForTextureGeneration;
  15753. /**
  15754. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15755. * @returns the transform matrix of the texture.
  15756. */
  15757. getTextureMatrix(): Matrix;
  15758. /**
  15759. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15760. * @returns The reflection texture transform
  15761. */
  15762. getReflectionTextureMatrix(): Matrix;
  15763. /**
  15764. * Clones the texture.
  15765. * @returns the cloned texture
  15766. */
  15767. clone(): Texture;
  15768. /**
  15769. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15770. * @returns The JSON representation of the texture
  15771. */
  15772. serialize(): any;
  15773. /**
  15774. * Get the current class name of the texture useful for serialization or dynamic coding.
  15775. * @returns "Texture"
  15776. */
  15777. getClassName(): string;
  15778. /**
  15779. * Dispose the texture and release its associated resources.
  15780. */
  15781. dispose(): void;
  15782. /**
  15783. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15784. * @param parsedTexture Define the JSON representation of the texture
  15785. * @param scene Define the scene the parsed texture should be instantiated in
  15786. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15787. * @returns The parsed texture if successful
  15788. */
  15789. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15790. /**
  15791. * Creates a texture from its base 64 representation.
  15792. * @param data Define the base64 payload without the data: prefix
  15793. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15794. * @param scene Define the scene the texture should belong to
  15795. * @param noMipmap Forces the texture to not create mip map information if true
  15796. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15797. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15798. * @param onLoad define a callback triggered when the texture has been loaded
  15799. * @param onError define a callback triggered when an error occurred during the loading session
  15800. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15801. * @returns the created texture
  15802. */
  15803. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15804. /**
  15805. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15806. * @param data Define the base64 payload without the data: prefix
  15807. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15808. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15809. * @param scene Define the scene the texture should belong to
  15810. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15811. * @param noMipmap Forces the texture to not create mip map information if true
  15812. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15813. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15814. * @param onLoad define a callback triggered when the texture has been loaded
  15815. * @param onError define a callback triggered when an error occurred during the loading session
  15816. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15817. * @returns the created texture
  15818. */
  15819. 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;
  15820. }
  15821. }
  15822. declare module BABYLON {
  15823. /**
  15824. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15825. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15826. */
  15827. export class PostProcessManager {
  15828. private _scene;
  15829. private _indexBuffer;
  15830. private _vertexBuffers;
  15831. /**
  15832. * Creates a new instance PostProcess
  15833. * @param scene The scene that the post process is associated with.
  15834. */
  15835. constructor(scene: Scene);
  15836. private _prepareBuffers;
  15837. private _buildIndexBuffer;
  15838. /**
  15839. * Rebuilds the vertex buffers of the manager.
  15840. * @hidden
  15841. */
  15842. _rebuild(): void;
  15843. /**
  15844. * Prepares a frame to be run through a post process.
  15845. * @param sourceTexture The input texture to the post procesess. (default: null)
  15846. * @param postProcesses An array of post processes to be run. (default: null)
  15847. * @returns True if the post processes were able to be run.
  15848. * @hidden
  15849. */
  15850. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15851. /**
  15852. * Manually render a set of post processes to a texture.
  15853. * @param postProcesses An array of post processes to be run.
  15854. * @param targetTexture The target texture to render to.
  15855. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15856. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15857. * @param lodLevel defines which lod of the texture to render to
  15858. */
  15859. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15860. /**
  15861. * Finalize the result of the output of the postprocesses.
  15862. * @param doNotPresent If true the result will not be displayed to the screen.
  15863. * @param targetTexture The target texture to render to.
  15864. * @param faceIndex The index of the face to bind the target texture to.
  15865. * @param postProcesses The array of post processes to render.
  15866. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15867. * @hidden
  15868. */
  15869. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15870. /**
  15871. * Disposes of the post process manager.
  15872. */
  15873. dispose(): void;
  15874. }
  15875. }
  15876. declare module BABYLON {
  15877. /** Interface used by value gradients (color, factor, ...) */
  15878. export interface IValueGradient {
  15879. /**
  15880. * Gets or sets the gradient value (between 0 and 1)
  15881. */
  15882. gradient: number;
  15883. }
  15884. /** Class used to store color4 gradient */
  15885. export class ColorGradient implements IValueGradient {
  15886. /**
  15887. * Gets or sets the gradient value (between 0 and 1)
  15888. */
  15889. gradient: number;
  15890. /**
  15891. * Gets or sets first associated color
  15892. */
  15893. color1: Color4;
  15894. /**
  15895. * Gets or sets second associated color
  15896. */
  15897. color2?: Color4;
  15898. /**
  15899. * Will get a color picked randomly between color1 and color2.
  15900. * If color2 is undefined then color1 will be used
  15901. * @param result defines the target Color4 to store the result in
  15902. */
  15903. getColorToRef(result: Color4): void;
  15904. }
  15905. /** Class used to store color 3 gradient */
  15906. export class Color3Gradient implements IValueGradient {
  15907. /**
  15908. * Gets or sets the gradient value (between 0 and 1)
  15909. */
  15910. gradient: number;
  15911. /**
  15912. * Gets or sets the associated color
  15913. */
  15914. color: Color3;
  15915. }
  15916. /** Class used to store factor gradient */
  15917. export class FactorGradient implements IValueGradient {
  15918. /**
  15919. * Gets or sets the gradient value (between 0 and 1)
  15920. */
  15921. gradient: number;
  15922. /**
  15923. * Gets or sets first associated factor
  15924. */
  15925. factor1: number;
  15926. /**
  15927. * Gets or sets second associated factor
  15928. */
  15929. factor2?: number;
  15930. /**
  15931. * Will get a number picked randomly between factor1 and factor2.
  15932. * If factor2 is undefined then factor1 will be used
  15933. * @returns the picked number
  15934. */
  15935. getFactor(): number;
  15936. }
  15937. /**
  15938. * Helper used to simplify some generic gradient tasks
  15939. */
  15940. export class GradientHelper {
  15941. /**
  15942. * Gets the current gradient from an array of IValueGradient
  15943. * @param ratio defines the current ratio to get
  15944. * @param gradients defines the array of IValueGradient
  15945. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15946. */
  15947. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15948. }
  15949. }
  15950. declare module BABYLON {
  15951. interface AbstractScene {
  15952. /**
  15953. * The list of procedural textures added to the scene
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15955. */
  15956. proceduralTextures: Array<ProceduralTexture>;
  15957. }
  15958. /**
  15959. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15960. * in a given scene.
  15961. */
  15962. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15963. /**
  15964. * The component name helpfull to identify the component in the list of scene components.
  15965. */
  15966. readonly name: string;
  15967. /**
  15968. * The scene the component belongs to.
  15969. */
  15970. scene: Scene;
  15971. /**
  15972. * Creates a new instance of the component for the given scene
  15973. * @param scene Defines the scene to register the component in
  15974. */
  15975. constructor(scene: Scene);
  15976. /**
  15977. * Registers the component in a given scene
  15978. */
  15979. register(): void;
  15980. /**
  15981. * Rebuilds the elements related to this component in case of
  15982. * context lost for instance.
  15983. */
  15984. rebuild(): void;
  15985. /**
  15986. * Disposes the component and the associated ressources.
  15987. */
  15988. dispose(): void;
  15989. private _beforeClear;
  15990. }
  15991. }
  15992. declare module BABYLON {
  15993. interface Engine {
  15994. /**
  15995. * Creates a new render target cube texture
  15996. * @param size defines the size of the texture
  15997. * @param options defines the options used to create the texture
  15998. * @returns a new render target cube texture stored in an InternalTexture
  15999. */
  16000. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16001. }
  16002. }
  16003. declare module BABYLON {
  16004. /** @hidden */
  16005. export var proceduralVertexShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * 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.
  16013. * This is the base class of any Procedural texture and contains most of the shareable code.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16015. */
  16016. export class ProceduralTexture extends Texture {
  16017. isCube: boolean;
  16018. /**
  16019. * Define if the texture is enabled or not (disabled texture will not render)
  16020. */
  16021. isEnabled: boolean;
  16022. /**
  16023. * Define if the texture must be cleared before rendering (default is true)
  16024. */
  16025. autoClear: boolean;
  16026. /**
  16027. * Callback called when the texture is generated
  16028. */
  16029. onGenerated: () => void;
  16030. /**
  16031. * Event raised when the texture is generated
  16032. */
  16033. onGeneratedObservable: Observable<ProceduralTexture>;
  16034. /** @hidden */
  16035. _generateMipMaps: boolean;
  16036. /** @hidden **/
  16037. _effect: Effect;
  16038. /** @hidden */
  16039. _textures: {
  16040. [key: string]: Texture;
  16041. };
  16042. private _size;
  16043. private _currentRefreshId;
  16044. private _refreshRate;
  16045. private _vertexBuffers;
  16046. private _indexBuffer;
  16047. private _uniforms;
  16048. private _samplers;
  16049. private _fragment;
  16050. private _floats;
  16051. private _ints;
  16052. private _floatsArrays;
  16053. private _colors3;
  16054. private _colors4;
  16055. private _vectors2;
  16056. private _vectors3;
  16057. private _matrices;
  16058. private _fallbackTexture;
  16059. private _fallbackTextureUsed;
  16060. private _engine;
  16061. private _cachedDefines;
  16062. private _contentUpdateId;
  16063. private _contentData;
  16064. /**
  16065. * Instantiates a new procedural texture.
  16066. * 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.
  16067. * This is the base class of any Procedural texture and contains most of the shareable code.
  16068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16069. * @param name Define the name of the texture
  16070. * @param size Define the size of the texture to create
  16071. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16072. * @param scene Define the scene the texture belongs to
  16073. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16074. * @param generateMipMaps Define if the texture should creates mip maps or not
  16075. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16076. */
  16077. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16078. /**
  16079. * The effect that is created when initializing the post process.
  16080. * @returns The created effect corresponding the the postprocess.
  16081. */
  16082. getEffect(): Effect;
  16083. /**
  16084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16086. */
  16087. getContent(): Nullable<ArrayBufferView>;
  16088. private _createIndexBuffer;
  16089. /** @hidden */
  16090. _rebuild(): void;
  16091. /**
  16092. * Resets the texture in order to recreate its associated resources.
  16093. * This can be called in case of context loss
  16094. */
  16095. reset(): void;
  16096. protected _getDefines(): string;
  16097. /**
  16098. * Is the texture ready to be used ? (rendered at least once)
  16099. * @returns true if ready, otherwise, false.
  16100. */
  16101. isReady(): boolean;
  16102. /**
  16103. * Resets the refresh counter of the texture and start bak from scratch.
  16104. * Could be useful to regenerate the texture if it is setup to render only once.
  16105. */
  16106. resetRefreshCounter(): void;
  16107. /**
  16108. * Set the fragment shader to use in order to render the texture.
  16109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16110. */
  16111. setFragment(fragment: any): void;
  16112. /**
  16113. * Define the refresh rate of the texture or the rendering frequency.
  16114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16115. */
  16116. refreshRate: number;
  16117. /** @hidden */
  16118. _shouldRender(): boolean;
  16119. /**
  16120. * Get the size the texture is rendering at.
  16121. * @returns the size (texture is always squared)
  16122. */
  16123. getRenderSize(): number;
  16124. /**
  16125. * Resize the texture to new value.
  16126. * @param size Define the new size the texture should have
  16127. * @param generateMipMaps Define whether the new texture should create mip maps
  16128. */
  16129. resize(size: number, generateMipMaps: boolean): void;
  16130. private _checkUniform;
  16131. /**
  16132. * Set a texture in the shader program used to render.
  16133. * @param name Define the name of the uniform samplers as defined in the shader
  16134. * @param texture Define the texture to bind to this sampler
  16135. * @return the texture itself allowing "fluent" like uniform updates
  16136. */
  16137. setTexture(name: string, texture: Texture): ProceduralTexture;
  16138. /**
  16139. * Set a float in the shader.
  16140. * @param name Define the name of the uniform as defined in the shader
  16141. * @param value Define the value to give to the uniform
  16142. * @return the texture itself allowing "fluent" like uniform updates
  16143. */
  16144. setFloat(name: string, value: number): ProceduralTexture;
  16145. /**
  16146. * Set a int in the shader.
  16147. * @param name Define the name of the uniform as defined in the shader
  16148. * @param value Define the value to give to the uniform
  16149. * @return the texture itself allowing "fluent" like uniform updates
  16150. */
  16151. setInt(name: string, value: number): ProceduralTexture;
  16152. /**
  16153. * Set an array of floats in the shader.
  16154. * @param name Define the name of the uniform as defined in the shader
  16155. * @param value Define the value to give to the uniform
  16156. * @return the texture itself allowing "fluent" like uniform updates
  16157. */
  16158. setFloats(name: string, value: number[]): ProceduralTexture;
  16159. /**
  16160. * Set a vec3 in the shader from a Color3.
  16161. * @param name Define the name of the uniform as defined in the shader
  16162. * @param value Define the value to give to the uniform
  16163. * @return the texture itself allowing "fluent" like uniform updates
  16164. */
  16165. setColor3(name: string, value: Color3): ProceduralTexture;
  16166. /**
  16167. * Set a vec4 in the shader from a Color4.
  16168. * @param name Define the name of the uniform as defined in the shader
  16169. * @param value Define the value to give to the uniform
  16170. * @return the texture itself allowing "fluent" like uniform updates
  16171. */
  16172. setColor4(name: string, value: Color4): ProceduralTexture;
  16173. /**
  16174. * Set a vec2 in the shader from a Vector2.
  16175. * @param name Define the name of the uniform as defined in the shader
  16176. * @param value Define the value to give to the uniform
  16177. * @return the texture itself allowing "fluent" like uniform updates
  16178. */
  16179. setVector2(name: string, value: Vector2): ProceduralTexture;
  16180. /**
  16181. * Set a vec3 in the shader from a Vector3.
  16182. * @param name Define the name of the uniform as defined in the shader
  16183. * @param value Define the value to give to the uniform
  16184. * @return the texture itself allowing "fluent" like uniform updates
  16185. */
  16186. setVector3(name: string, value: Vector3): ProceduralTexture;
  16187. /**
  16188. * Set a mat4 in the shader from a MAtrix.
  16189. * @param name Define the name of the uniform as defined in the shader
  16190. * @param value Define the value to give to the uniform
  16191. * @return the texture itself allowing "fluent" like uniform updates
  16192. */
  16193. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16194. /**
  16195. * Render the texture to its associated render target.
  16196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16197. */
  16198. render(useCameraPostProcess?: boolean): void;
  16199. /**
  16200. * Clone the texture.
  16201. * @returns the cloned texture
  16202. */
  16203. clone(): ProceduralTexture;
  16204. /**
  16205. * Dispose the texture and release its asoociated resources.
  16206. */
  16207. dispose(): void;
  16208. }
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * This represents the base class for particle system in Babylon.
  16213. * 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.
  16214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16215. * @example https://doc.babylonjs.com/babylon101/particles
  16216. */
  16217. export class BaseParticleSystem {
  16218. /**
  16219. * Source color is added to the destination color without alpha affecting the result
  16220. */
  16221. static BLENDMODE_ONEONE: number;
  16222. /**
  16223. * Blend current color and particle color using particle’s alpha
  16224. */
  16225. static BLENDMODE_STANDARD: number;
  16226. /**
  16227. * Add current color and particle color multiplied by particle’s alpha
  16228. */
  16229. static BLENDMODE_ADD: number;
  16230. /**
  16231. * Multiply current color with particle color
  16232. */
  16233. static BLENDMODE_MULTIPLY: number;
  16234. /**
  16235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16236. */
  16237. static BLENDMODE_MULTIPLYADD: number;
  16238. /**
  16239. * List of animations used by the particle system.
  16240. */
  16241. animations: Animation[];
  16242. /**
  16243. * The id of the Particle system.
  16244. */
  16245. id: string;
  16246. /**
  16247. * The friendly name of the Particle system.
  16248. */
  16249. name: string;
  16250. /**
  16251. * The rendering group used by the Particle system to chose when to render.
  16252. */
  16253. renderingGroupId: number;
  16254. /**
  16255. * The emitter represents the Mesh or position we are attaching the particle system to.
  16256. */
  16257. emitter: Nullable<AbstractMesh | Vector3>;
  16258. /**
  16259. * The maximum number of particles to emit per frame
  16260. */
  16261. emitRate: number;
  16262. /**
  16263. * If you want to launch only a few particles at once, that can be done, as well.
  16264. */
  16265. manualEmitCount: number;
  16266. /**
  16267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16268. */
  16269. updateSpeed: number;
  16270. /**
  16271. * The amount of time the particle system is running (depends of the overall update speed).
  16272. */
  16273. targetStopDuration: number;
  16274. /**
  16275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16276. */
  16277. disposeOnStop: boolean;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum life time of emitting particles.
  16288. */
  16289. minLifeTime: number;
  16290. /**
  16291. * Maximum life time of emitting particles.
  16292. */
  16293. maxLifeTime: number;
  16294. /**
  16295. * Minimum Size of emitting particles.
  16296. */
  16297. minSize: number;
  16298. /**
  16299. * Maximum Size of emitting particles.
  16300. */
  16301. maxSize: number;
  16302. /**
  16303. * Minimum scale of emitting particles on X axis.
  16304. */
  16305. minScaleX: number;
  16306. /**
  16307. * Maximum scale of emitting particles on X axis.
  16308. */
  16309. maxScaleX: number;
  16310. /**
  16311. * Minimum scale of emitting particles on Y axis.
  16312. */
  16313. minScaleY: number;
  16314. /**
  16315. * Maximum scale of emitting particles on Y axis.
  16316. */
  16317. maxScaleY: number;
  16318. /**
  16319. * Gets or sets the minimal initial rotation in radians.
  16320. */
  16321. minInitialRotation: number;
  16322. /**
  16323. * Gets or sets the maximal initial rotation in radians.
  16324. */
  16325. maxInitialRotation: number;
  16326. /**
  16327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16328. */
  16329. minAngularSpeed: number;
  16330. /**
  16331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16332. */
  16333. maxAngularSpeed: number;
  16334. /**
  16335. * The texture used to render each particle. (this can be a spritesheet)
  16336. */
  16337. particleTexture: Nullable<Texture>;
  16338. /**
  16339. * The layer mask we are rendering the particles through.
  16340. */
  16341. layerMask: number;
  16342. /**
  16343. * This can help using your own shader to render the particle system.
  16344. * The according effect will be created
  16345. */
  16346. customShader: any;
  16347. /**
  16348. * By default particle system starts as soon as they are created. This prevents the
  16349. * automatic start to happen and let you decide when to start emitting particles.
  16350. */
  16351. preventAutoStart: boolean;
  16352. private _noiseTexture;
  16353. /**
  16354. * Gets or sets a texture used to add random noise to particle positions
  16355. */
  16356. noiseTexture: Nullable<ProceduralTexture>;
  16357. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16358. noiseStrength: Vector3;
  16359. /**
  16360. * Callback triggered when the particle animation is ending.
  16361. */
  16362. onAnimationEnd: Nullable<() => void>;
  16363. /**
  16364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16365. */
  16366. blendMode: number;
  16367. /**
  16368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16369. * to override the particles.
  16370. */
  16371. forceDepthWrite: boolean;
  16372. /** 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 */
  16373. preWarmCycles: number;
  16374. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16375. preWarmStepOffset: number;
  16376. /**
  16377. * 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)
  16378. */
  16379. spriteCellChangeSpeed: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16382. */
  16383. startSpriteCellID: number;
  16384. /**
  16385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16386. */
  16387. endSpriteCellID: number;
  16388. /**
  16389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16390. */
  16391. spriteCellWidth: number;
  16392. /**
  16393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16394. */
  16395. spriteCellHeight: number;
  16396. /**
  16397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16398. */
  16399. spriteRandomStartCell: boolean;
  16400. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16401. translationPivot: Vector2;
  16402. /** @hidden */
  16403. protected _isAnimationSheetEnabled: boolean;
  16404. /**
  16405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16406. */
  16407. beginAnimationOnStart: boolean;
  16408. /**
  16409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16410. */
  16411. beginAnimationFrom: number;
  16412. /**
  16413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16414. */
  16415. beginAnimationTo: number;
  16416. /**
  16417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16418. */
  16419. beginAnimationLoop: boolean;
  16420. /**
  16421. * Gets or sets a world offset applied to all particles
  16422. */
  16423. worldOffset: Vector3;
  16424. /**
  16425. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16426. */
  16427. isAnimationSheetEnabled: boolean;
  16428. /**
  16429. * Get hosting scene
  16430. * @returns the scene
  16431. */
  16432. getScene(): Scene;
  16433. /**
  16434. * You can use gravity if you want to give an orientation to your particles.
  16435. */
  16436. gravity: Vector3;
  16437. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16438. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16439. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16440. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16441. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16442. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16443. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16444. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16445. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16446. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16447. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16448. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16449. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16450. /**
  16451. * Defines the delay in milliseconds before starting the system (0 by default)
  16452. */
  16453. startDelay: number;
  16454. /**
  16455. * Gets the current list of drag gradients.
  16456. * You must use addDragGradient and removeDragGradient to udpate this list
  16457. * @returns the list of drag gradients
  16458. */
  16459. getDragGradients(): Nullable<Array<FactorGradient>>;
  16460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16461. limitVelocityDamping: number;
  16462. /**
  16463. * Gets the current list of limit velocity gradients.
  16464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16465. * @returns the list of limit velocity gradients
  16466. */
  16467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of color remap gradients.
  16482. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16483. * @returns the list of color remap gradients
  16484. */
  16485. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of alpha remap gradients.
  16488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16489. * @returns the list of alpha remap gradients
  16490. */
  16491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of life time gradients.
  16494. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16495. * @returns the list of life time gradients
  16496. */
  16497. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of angular speed gradients.
  16500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16501. * @returns the list of angular speed gradients
  16502. */
  16503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of velocity gradients.
  16506. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16507. * @returns the list of velocity gradients
  16508. */
  16509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16510. /**
  16511. * Gets the current list of start size gradients.
  16512. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16513. * @returns the list of start size gradients
  16514. */
  16515. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16516. /**
  16517. * Gets the current list of emit rate gradients.
  16518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16519. * @returns the list of emit rate gradients
  16520. */
  16521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16522. /**
  16523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16525. */
  16526. direction1: Vector3;
  16527. /**
  16528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16530. */
  16531. direction2: Vector3;
  16532. /**
  16533. * 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.
  16534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16535. */
  16536. minEmitBox: Vector3;
  16537. /**
  16538. * 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.
  16539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16540. */
  16541. maxEmitBox: Vector3;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16544. */
  16545. color1: Color4;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16548. */
  16549. color2: Color4;
  16550. /**
  16551. * Color the particle will have at the end of its lifetime
  16552. */
  16553. colorDead: Color4;
  16554. /**
  16555. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16556. */
  16557. textureMask: Color4;
  16558. /**
  16559. * The particle emitter type defines the emitter used by the particle system.
  16560. * It can be for example box, sphere, or cone...
  16561. */
  16562. particleEmitterType: IParticleEmitterType;
  16563. /** @hidden */
  16564. _isSubEmitter: boolean;
  16565. /**
  16566. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16567. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16568. */
  16569. billboardMode: number;
  16570. protected _isBillboardBased: boolean;
  16571. /**
  16572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16573. */
  16574. isBillboardBased: boolean;
  16575. /**
  16576. * The scene the particle system belongs to.
  16577. */
  16578. protected _scene: Scene;
  16579. /**
  16580. * Local cache of defines for image processing.
  16581. */
  16582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16583. /**
  16584. * Default configuration related to image processing available in the standard Material.
  16585. */
  16586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16587. /**
  16588. * Gets the image processing configuration used either in this material.
  16589. */
  16590. /**
  16591. * Sets the Default image processing configuration used either in the this material.
  16592. *
  16593. * If sets to null, the scene one is in use.
  16594. */
  16595. imageProcessingConfiguration: ImageProcessingConfiguration;
  16596. /**
  16597. * Attaches a new image processing configuration to the Standard Material.
  16598. * @param configuration
  16599. */
  16600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16601. /** @hidden */
  16602. protected _reset(): void;
  16603. /** @hidden */
  16604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16605. /**
  16606. * Instantiates a particle system.
  16607. * 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.
  16608. * @param name The name of the particle system
  16609. */
  16610. constructor(name: string);
  16611. /**
  16612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16615. * @returns the emitter
  16616. */
  16617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16618. /**
  16619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16620. * @param radius The radius of the hemisphere to emit from
  16621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16622. * @returns the emitter
  16623. */
  16624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16625. /**
  16626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16627. * @param radius The radius of the sphere to emit from
  16628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16629. * @returns the emitter
  16630. */
  16631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16632. /**
  16633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16634. * @param radius The radius of the sphere to emit from
  16635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16637. * @returns the emitter
  16638. */
  16639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16640. /**
  16641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16642. * @param radius The radius of the emission cylinder
  16643. * @param height The height of the emission cylinder
  16644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16646. * @returns the emitter
  16647. */
  16648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16649. /**
  16650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16651. * @param radius The radius of the cylinder to emit from
  16652. * @param height The height of the emission cylinder
  16653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16656. * @returns the emitter
  16657. */
  16658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16659. /**
  16660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16661. * @param radius The radius of the cone to emit from
  16662. * @param angle The base angle of the cone
  16663. * @returns the emitter
  16664. */
  16665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16666. /**
  16667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16672. * @returns the emitter
  16673. */
  16674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16675. }
  16676. }
  16677. declare module BABYLON {
  16678. /**
  16679. * Type of sub emitter
  16680. */
  16681. export enum SubEmitterType {
  16682. /**
  16683. * Attached to the particle over it's lifetime
  16684. */
  16685. ATTACHED = 0,
  16686. /**
  16687. * Created when the particle dies
  16688. */
  16689. END = 1
  16690. }
  16691. /**
  16692. * Sub emitter class used to emit particles from an existing particle
  16693. */
  16694. export class SubEmitter {
  16695. /**
  16696. * the particle system to be used by the sub emitter
  16697. */
  16698. particleSystem: ParticleSystem;
  16699. /**
  16700. * Type of the submitter (Default: END)
  16701. */
  16702. type: SubEmitterType;
  16703. /**
  16704. * 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)
  16705. * Note: This only is supported when using an emitter of type Mesh
  16706. */
  16707. inheritDirection: boolean;
  16708. /**
  16709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16710. */
  16711. inheritedVelocityAmount: number;
  16712. /**
  16713. * Creates a sub emitter
  16714. * @param particleSystem the particle system to be used by the sub emitter
  16715. */
  16716. constructor(
  16717. /**
  16718. * the particle system to be used by the sub emitter
  16719. */
  16720. particleSystem: ParticleSystem);
  16721. /**
  16722. * Clones the sub emitter
  16723. * @returns the cloned sub emitter
  16724. */
  16725. clone(): SubEmitter;
  16726. /**
  16727. * Serialize current object to a JSON object
  16728. * @returns the serialized object
  16729. */
  16730. serialize(): any;
  16731. /** @hidden */
  16732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16733. /**
  16734. * Creates a new SubEmitter from a serialized JSON version
  16735. * @param serializationObject defines the JSON object to read from
  16736. * @param scene defines the hosting scene
  16737. * @param rootUrl defines the rootUrl for data loading
  16738. * @returns a new SubEmitter
  16739. */
  16740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16741. /** Release associated resources */
  16742. dispose(): void;
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. /** @hidden */
  16747. export var clipPlaneFragmentDeclaration: {
  16748. name: string;
  16749. shader: string;
  16750. };
  16751. }
  16752. declare module BABYLON {
  16753. /** @hidden */
  16754. export var imageProcessingDeclaration: {
  16755. name: string;
  16756. shader: string;
  16757. };
  16758. }
  16759. declare module BABYLON {
  16760. /** @hidden */
  16761. export var imageProcessingFunctions: {
  16762. name: string;
  16763. shader: string;
  16764. };
  16765. }
  16766. declare module BABYLON {
  16767. /** @hidden */
  16768. export var clipPlaneFragment: {
  16769. name: string;
  16770. shader: string;
  16771. };
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var particlesPixelShader: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var clipPlaneVertexDeclaration: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. /** @hidden */
  16789. export var clipPlaneVertex: {
  16790. name: string;
  16791. shader: string;
  16792. };
  16793. }
  16794. declare module BABYLON {
  16795. /** @hidden */
  16796. export var particlesVertexShader: {
  16797. name: string;
  16798. shader: string;
  16799. };
  16800. }
  16801. declare module BABYLON {
  16802. /**
  16803. * This represents a particle system in Babylon.
  16804. * 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.
  16805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16806. * @example https://doc.babylonjs.com/babylon101/particles
  16807. */
  16808. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16809. /**
  16810. * Billboard mode will only apply to Y axis
  16811. */
  16812. static readonly BILLBOARDMODE_Y: number;
  16813. /**
  16814. * Billboard mode will apply to all axes
  16815. */
  16816. static readonly BILLBOARDMODE_ALL: number;
  16817. /**
  16818. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16819. */
  16820. static readonly BILLBOARDMODE_STRETCHED: number;
  16821. /**
  16822. * This function can be defined to provide custom update for active particles.
  16823. * This function will be called instead of regular update (age, position, color, etc.).
  16824. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16825. */
  16826. updateFunction: (particles: Particle[]) => void;
  16827. private _emitterWorldMatrix;
  16828. /**
  16829. * This function can be defined to specify initial direction for every new particle.
  16830. * It by default use the emitterType defined function
  16831. */
  16832. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16833. /**
  16834. * This function can be defined to specify initial position for every new particle.
  16835. * It by default use the emitterType defined function
  16836. */
  16837. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16838. /**
  16839. * @hidden
  16840. */
  16841. _inheritedVelocityOffset: Vector3;
  16842. /**
  16843. * An event triggered when the system is disposed
  16844. */
  16845. onDisposeObservable: Observable<ParticleSystem>;
  16846. private _onDisposeObserver;
  16847. /**
  16848. * Sets a callback that will be triggered when the system is disposed
  16849. */
  16850. onDispose: () => void;
  16851. private _particles;
  16852. private _epsilon;
  16853. private _capacity;
  16854. private _stockParticles;
  16855. private _newPartsExcess;
  16856. private _vertexData;
  16857. private _vertexBuffer;
  16858. private _vertexBuffers;
  16859. private _spriteBuffer;
  16860. private _indexBuffer;
  16861. private _effect;
  16862. private _customEffect;
  16863. private _cachedDefines;
  16864. private _scaledColorStep;
  16865. private _colorDiff;
  16866. private _scaledDirection;
  16867. private _scaledGravity;
  16868. private _currentRenderId;
  16869. private _alive;
  16870. private _useInstancing;
  16871. private _started;
  16872. private _stopped;
  16873. private _actualFrame;
  16874. private _scaledUpdateSpeed;
  16875. private _vertexBufferSize;
  16876. /** @hidden */
  16877. _currentEmitRateGradient: Nullable<FactorGradient>;
  16878. /** @hidden */
  16879. _currentEmitRate1: number;
  16880. /** @hidden */
  16881. _currentEmitRate2: number;
  16882. /** @hidden */
  16883. _currentStartSizeGradient: Nullable<FactorGradient>;
  16884. /** @hidden */
  16885. _currentStartSize1: number;
  16886. /** @hidden */
  16887. _currentStartSize2: number;
  16888. private readonly _rawTextureWidth;
  16889. private _rampGradientsTexture;
  16890. private _useRampGradients;
  16891. /** Gets or sets a boolean indicating that ramp gradients must be used
  16892. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16893. */
  16894. useRampGradients: boolean;
  16895. /**
  16896. * 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.
  16897. * 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: [])
  16898. */
  16899. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16900. private _subEmitters;
  16901. /**
  16902. * @hidden
  16903. * If the particle systems emitter should be disposed when the particle system is disposed
  16904. */
  16905. _disposeEmitterOnDispose: boolean;
  16906. /**
  16907. * The current active Sub-systems, this property is used by the root particle system only.
  16908. */
  16909. activeSubSystems: Array<ParticleSystem>;
  16910. private _rootParticleSystem;
  16911. /**
  16912. * Gets the current list of active particles
  16913. */
  16914. readonly particles: Particle[];
  16915. /**
  16916. * Returns the string "ParticleSystem"
  16917. * @returns a string containing the class name
  16918. */
  16919. getClassName(): string;
  16920. /**
  16921. * Instantiates a particle system.
  16922. * 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.
  16923. * @param name The name of the particle system
  16924. * @param capacity The max number of particles alive at the same time
  16925. * @param scene The scene the particle system belongs to
  16926. * @param customEffect a custom effect used to change the way particles are rendered by default
  16927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16928. * @param epsilon Offset used to render the particles
  16929. */
  16930. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16931. private _addFactorGradient;
  16932. private _removeFactorGradient;
  16933. /**
  16934. * Adds a new life time gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific life time gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new size gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific size gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeSizeGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Adds a new color remap gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param min defines the color remap minimal range
  16965. * @param max defines the color remap maximal range
  16966. * @returns the current particle system
  16967. */
  16968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16969. /**
  16970. * Remove a specific color remap gradient
  16971. * @param gradient defines the gradient to remove
  16972. * @returns the current particle system
  16973. */
  16974. removeColorRemapGradient(gradient: number): IParticleSystem;
  16975. /**
  16976. * Adds a new alpha remap gradient
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param min defines the alpha remap minimal range
  16979. * @param max defines the alpha remap maximal range
  16980. * @returns the current particle system
  16981. */
  16982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16983. /**
  16984. * Remove a specific alpha remap gradient
  16985. * @param gradient defines the gradient to remove
  16986. * @returns the current particle system
  16987. */
  16988. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16989. /**
  16990. * Adds a new angular speed gradient
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific angular speed gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Adds a new velocity gradient
  17005. * @param gradient defines the gradient to use (between 0 and 1)
  17006. * @param factor defines the velocity to affect to the specified gradient
  17007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17008. * @returns the current particle system
  17009. */
  17010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17011. /**
  17012. * Remove a specific velocity gradient
  17013. * @param gradient defines the gradient to remove
  17014. * @returns the current particle system
  17015. */
  17016. removeVelocityGradient(gradient: number): IParticleSystem;
  17017. /**
  17018. * Adds a new limit velocity gradient
  17019. * @param gradient defines the gradient to use (between 0 and 1)
  17020. * @param factor defines the limit velocity value to affect to the specified gradient
  17021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17022. * @returns the current particle system
  17023. */
  17024. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17025. /**
  17026. * Remove a specific limit velocity gradient
  17027. * @param gradient defines the gradient to remove
  17028. * @returns the current particle system
  17029. */
  17030. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17031. /**
  17032. * Adds a new drag gradient
  17033. * @param gradient defines the gradient to use (between 0 and 1)
  17034. * @param factor defines the drag value to affect to the specified gradient
  17035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17036. * @returns the current particle system
  17037. */
  17038. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17039. /**
  17040. * Remove a specific drag gradient
  17041. * @param gradient defines the gradient to remove
  17042. * @returns the current particle system
  17043. */
  17044. removeDragGradient(gradient: number): IParticleSystem;
  17045. /**
  17046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17047. * @param gradient defines the gradient to use (between 0 and 1)
  17048. * @param factor defines the emit rate value to affect to the specified gradient
  17049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17050. * @returns the current particle system
  17051. */
  17052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17053. /**
  17054. * Remove a specific emit rate gradient
  17055. * @param gradient defines the gradient to remove
  17056. * @returns the current particle system
  17057. */
  17058. removeEmitRateGradient(gradient: number): IParticleSystem;
  17059. /**
  17060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17061. * @param gradient defines the gradient to use (between 0 and 1)
  17062. * @param factor defines the start size value to affect to the specified gradient
  17063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17064. * @returns the current particle system
  17065. */
  17066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17067. /**
  17068. * Remove a specific start size gradient
  17069. * @param gradient defines the gradient to remove
  17070. * @returns the current particle system
  17071. */
  17072. removeStartSizeGradient(gradient: number): IParticleSystem;
  17073. private _createRampGradientTexture;
  17074. /**
  17075. * Gets the current list of ramp gradients.
  17076. * You must use addRampGradient and removeRampGradient to udpate this list
  17077. * @returns the list of ramp gradients
  17078. */
  17079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17080. /**
  17081. * Adds a new ramp gradient used to remap particle colors
  17082. * @param gradient defines the gradient to use (between 0 and 1)
  17083. * @param color defines the color to affect to the specified gradient
  17084. * @returns the current particle system
  17085. */
  17086. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17087. /**
  17088. * Remove a specific ramp gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns the current particle system
  17091. */
  17092. removeRampGradient(gradient: number): ParticleSystem;
  17093. /**
  17094. * Adds a new color gradient
  17095. * @param gradient defines the gradient to use (between 0 and 1)
  17096. * @param color1 defines the color to affect to the specified gradient
  17097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17098. * @returns this particle system
  17099. */
  17100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17101. /**
  17102. * Remove a specific color gradient
  17103. * @param gradient defines the gradient to remove
  17104. * @returns this particle system
  17105. */
  17106. removeColorGradient(gradient: number): IParticleSystem;
  17107. private _fetchR;
  17108. protected _reset(): void;
  17109. private _resetEffect;
  17110. private _createVertexBuffers;
  17111. private _createIndexBuffer;
  17112. /**
  17113. * Gets the maximum number of particles active at the same time.
  17114. * @returns The max number of active particles.
  17115. */
  17116. getCapacity(): number;
  17117. /**
  17118. * Gets whether there are still active particles in the system.
  17119. * @returns True if it is alive, otherwise false.
  17120. */
  17121. isAlive(): boolean;
  17122. /**
  17123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17124. * @returns True if it has been started, otherwise false.
  17125. */
  17126. isStarted(): boolean;
  17127. private _prepareSubEmitterInternalArray;
  17128. /**
  17129. * Starts the particle system and begins to emit
  17130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17131. */
  17132. start(delay?: number): void;
  17133. /**
  17134. * Stops the particle system.
  17135. * @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.
  17136. */
  17137. stop(stopSubEmitters?: boolean): void;
  17138. /**
  17139. * Remove all active particles
  17140. */
  17141. reset(): void;
  17142. /**
  17143. * @hidden (for internal use only)
  17144. */
  17145. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17146. /**
  17147. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17148. * Its lifetime will start back at 0.
  17149. */
  17150. recycleParticle: (particle: Particle) => void;
  17151. private _stopSubEmitters;
  17152. private _createParticle;
  17153. private _removeFromRoot;
  17154. private _emitFromParticle;
  17155. private _update;
  17156. /** @hidden */
  17157. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17158. /** @hidden */
  17159. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17160. /** @hidden */
  17161. private _getEffect;
  17162. /**
  17163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17164. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17165. */
  17166. animate(preWarmOnly?: boolean): void;
  17167. private _appendParticleVertices;
  17168. /**
  17169. * Rebuilds the particle system.
  17170. */
  17171. rebuild(): void;
  17172. /**
  17173. * Is this system ready to be used/rendered
  17174. * @return true if the system is ready
  17175. */
  17176. isReady(): boolean;
  17177. private _render;
  17178. /**
  17179. * Renders the particle system in its current state.
  17180. * @returns the current number of particles
  17181. */
  17182. render(): number;
  17183. /**
  17184. * Disposes the particle system and free the associated resources
  17185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17186. */
  17187. dispose(disposeTexture?: boolean): void;
  17188. /**
  17189. * Clones the particle system.
  17190. * @param name The name of the cloned object
  17191. * @param newEmitter The new emitter to use
  17192. * @returns the cloned particle system
  17193. */
  17194. clone(name: string, newEmitter: any): ParticleSystem;
  17195. /**
  17196. * Serializes the particle system to a JSON object.
  17197. * @returns the JSON object
  17198. */
  17199. serialize(): any;
  17200. /** @hidden */
  17201. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17202. /** @hidden */
  17203. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17204. /**
  17205. * Parses a JSON object to create a particle system.
  17206. * @param parsedParticleSystem The JSON object to parse
  17207. * @param scene The scene to create the particle system in
  17208. * @param rootUrl The root url to use to load external dependencies like texture
  17209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17210. * @returns the Parsed particle system
  17211. */
  17212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * A particle represents one of the element emitted by a particle system.
  17218. * This is mainly define by its coordinates, direction, velocity and age.
  17219. */
  17220. export class Particle {
  17221. /**
  17222. * The particle system the particle belongs to.
  17223. */
  17224. particleSystem: ParticleSystem;
  17225. private static _Count;
  17226. /**
  17227. * Unique ID of the particle
  17228. */
  17229. id: number;
  17230. /**
  17231. * The world position of the particle in the scene.
  17232. */
  17233. position: Vector3;
  17234. /**
  17235. * The world direction of the particle in the scene.
  17236. */
  17237. direction: Vector3;
  17238. /**
  17239. * The color of the particle.
  17240. */
  17241. color: Color4;
  17242. /**
  17243. * The color change of the particle per step.
  17244. */
  17245. colorStep: Color4;
  17246. /**
  17247. * Defines how long will the life of the particle be.
  17248. */
  17249. lifeTime: number;
  17250. /**
  17251. * The current age of the particle.
  17252. */
  17253. age: number;
  17254. /**
  17255. * The current size of the particle.
  17256. */
  17257. size: number;
  17258. /**
  17259. * The current scale of the particle.
  17260. */
  17261. scale: Vector2;
  17262. /**
  17263. * The current angle of the particle.
  17264. */
  17265. angle: number;
  17266. /**
  17267. * Defines how fast is the angle changing.
  17268. */
  17269. angularSpeed: number;
  17270. /**
  17271. * Defines the cell index used by the particle to be rendered from a sprite.
  17272. */
  17273. cellIndex: number;
  17274. /**
  17275. * The information required to support color remapping
  17276. */
  17277. remapData: Vector4;
  17278. /** @hidden */
  17279. _randomCellOffset?: number;
  17280. /** @hidden */
  17281. _initialDirection: Nullable<Vector3>;
  17282. /** @hidden */
  17283. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17284. /** @hidden */
  17285. _initialStartSpriteCellID: number;
  17286. /** @hidden */
  17287. _initialEndSpriteCellID: number;
  17288. /** @hidden */
  17289. _currentColorGradient: Nullable<ColorGradient>;
  17290. /** @hidden */
  17291. _currentColor1: Color4;
  17292. /** @hidden */
  17293. _currentColor2: Color4;
  17294. /** @hidden */
  17295. _currentSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentSize1: number;
  17298. /** @hidden */
  17299. _currentSize2: number;
  17300. /** @hidden */
  17301. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17302. /** @hidden */
  17303. _currentAngularSpeed1: number;
  17304. /** @hidden */
  17305. _currentAngularSpeed2: number;
  17306. /** @hidden */
  17307. _currentVelocityGradient: Nullable<FactorGradient>;
  17308. /** @hidden */
  17309. _currentVelocity1: number;
  17310. /** @hidden */
  17311. _currentVelocity2: number;
  17312. /** @hidden */
  17313. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17314. /** @hidden */
  17315. _currentLimitVelocity1: number;
  17316. /** @hidden */
  17317. _currentLimitVelocity2: number;
  17318. /** @hidden */
  17319. _currentDragGradient: Nullable<FactorGradient>;
  17320. /** @hidden */
  17321. _currentDrag1: number;
  17322. /** @hidden */
  17323. _currentDrag2: number;
  17324. /** @hidden */
  17325. _randomNoiseCoordinates1: Vector3;
  17326. /** @hidden */
  17327. _randomNoiseCoordinates2: Vector3;
  17328. /**
  17329. * Creates a new instance Particle
  17330. * @param particleSystem the particle system the particle belongs to
  17331. */
  17332. constructor(
  17333. /**
  17334. * The particle system the particle belongs to.
  17335. */
  17336. particleSystem: ParticleSystem);
  17337. private updateCellInfoFromSystem;
  17338. /**
  17339. * Defines how the sprite cell index is updated for the particle
  17340. */
  17341. updateCellIndex(): void;
  17342. /** @hidden */
  17343. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17344. /** @hidden */
  17345. _inheritParticleInfoToSubEmitters(): void;
  17346. /** @hidden */
  17347. _reset(): void;
  17348. /**
  17349. * Copy the properties of particle to another one.
  17350. * @param other the particle to copy the information to.
  17351. */
  17352. copyTo(other: Particle): void;
  17353. }
  17354. }
  17355. declare module BABYLON {
  17356. /**
  17357. * Particle emitter represents a volume emitting particles.
  17358. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17359. */
  17360. export interface IParticleEmitterType {
  17361. /**
  17362. * Called by the particle System when the direction is computed for the created particle.
  17363. * @param worldMatrix is the world matrix of the particle system
  17364. * @param directionToUpdate is the direction vector to update with the result
  17365. * @param particle is the particle we are computed the direction for
  17366. */
  17367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17368. /**
  17369. * Called by the particle System when the position is computed for the created particle.
  17370. * @param worldMatrix is the world matrix of the particle system
  17371. * @param positionToUpdate is the position vector to update with the result
  17372. * @param particle is the particle we are computed the position for
  17373. */
  17374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17375. /**
  17376. * Clones the current emitter and returns a copy of it
  17377. * @returns the new emitter
  17378. */
  17379. clone(): IParticleEmitterType;
  17380. /**
  17381. * Called by the GPUParticleSystem to setup the update shader
  17382. * @param effect defines the update shader
  17383. */
  17384. applyToShader(effect: Effect): void;
  17385. /**
  17386. * Returns a string to use to update the GPU particles update shader
  17387. * @returns the effect defines string
  17388. */
  17389. getEffectDefines(): string;
  17390. /**
  17391. * Returns a string representing the class name
  17392. * @returns a string containing the class name
  17393. */
  17394. getClassName(): string;
  17395. /**
  17396. * Serializes the particle system to a JSON object.
  17397. * @returns the JSON object
  17398. */
  17399. serialize(): any;
  17400. /**
  17401. * Parse properties from a JSON object
  17402. * @param serializationObject defines the JSON object
  17403. */
  17404. parse(serializationObject: any): void;
  17405. }
  17406. }
  17407. declare module BABYLON {
  17408. /**
  17409. * Particle emitter emitting particles from the inside of a box.
  17410. * It emits the particles randomly between 2 given directions.
  17411. */
  17412. export class BoxParticleEmitter implements IParticleEmitterType {
  17413. /**
  17414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17415. */
  17416. direction1: Vector3;
  17417. /**
  17418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17419. */
  17420. direction2: Vector3;
  17421. /**
  17422. * 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.
  17423. */
  17424. minEmitBox: Vector3;
  17425. /**
  17426. * 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.
  17427. */
  17428. maxEmitBox: Vector3;
  17429. /**
  17430. * Creates a new instance BoxParticleEmitter
  17431. */
  17432. constructor();
  17433. /**
  17434. * Called by the particle System when the direction is computed for the created particle.
  17435. * @param worldMatrix is the world matrix of the particle system
  17436. * @param directionToUpdate is the direction vector to update with the result
  17437. * @param particle is the particle we are computed the direction for
  17438. */
  17439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17440. /**
  17441. * Called by the particle System when the position is computed for the created particle.
  17442. * @param worldMatrix is the world matrix of the particle system
  17443. * @param positionToUpdate is the position vector to update with the result
  17444. * @param particle is the particle we are computed the position for
  17445. */
  17446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17447. /**
  17448. * Clones the current emitter and returns a copy of it
  17449. * @returns the new emitter
  17450. */
  17451. clone(): BoxParticleEmitter;
  17452. /**
  17453. * Called by the GPUParticleSystem to setup the update shader
  17454. * @param effect defines the update shader
  17455. */
  17456. applyToShader(effect: Effect): void;
  17457. /**
  17458. * Returns a string to use to update the GPU particles update shader
  17459. * @returns a string containng the defines string
  17460. */
  17461. getEffectDefines(): string;
  17462. /**
  17463. * Returns the string "BoxParticleEmitter"
  17464. * @returns a string containing the class name
  17465. */
  17466. getClassName(): string;
  17467. /**
  17468. * Serializes the particle system to a JSON object.
  17469. * @returns the JSON object
  17470. */
  17471. serialize(): any;
  17472. /**
  17473. * Parse properties from a JSON object
  17474. * @param serializationObject defines the JSON object
  17475. */
  17476. parse(serializationObject: any): void;
  17477. }
  17478. }
  17479. declare module BABYLON {
  17480. /**
  17481. * Particle emitter emitting particles from the inside of a cone.
  17482. * It emits the particles alongside the cone volume from the base to the particle.
  17483. * The emission direction might be randomized.
  17484. */
  17485. export class ConeParticleEmitter implements IParticleEmitterType {
  17486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17487. directionRandomizer: number;
  17488. private _radius;
  17489. private _angle;
  17490. private _height;
  17491. /**
  17492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17493. */
  17494. radiusRange: number;
  17495. /**
  17496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17497. */
  17498. heightRange: number;
  17499. /**
  17500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17501. */
  17502. emitFromSpawnPointOnly: boolean;
  17503. /**
  17504. * Gets or sets the radius of the emission cone
  17505. */
  17506. radius: number;
  17507. /**
  17508. * Gets or sets the angle of the emission cone
  17509. */
  17510. angle: number;
  17511. private _buildHeight;
  17512. /**
  17513. * Creates a new instance ConeParticleEmitter
  17514. * @param radius the radius of the emission cone (1 by default)
  17515. * @param angle the cone base angle (PI by default)
  17516. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17517. */
  17518. constructor(radius?: number, angle?: number,
  17519. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17520. directionRandomizer?: number);
  17521. /**
  17522. * Called by the particle System when the direction is computed for the created particle.
  17523. * @param worldMatrix is the world matrix of the particle system
  17524. * @param directionToUpdate is the direction vector to update with the result
  17525. * @param particle is the particle we are computed the direction for
  17526. */
  17527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17528. /**
  17529. * Called by the particle System when the position is computed for the created particle.
  17530. * @param worldMatrix is the world matrix of the particle system
  17531. * @param positionToUpdate is the position vector to update with the result
  17532. * @param particle is the particle we are computed the position for
  17533. */
  17534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17535. /**
  17536. * Clones the current emitter and returns a copy of it
  17537. * @returns the new emitter
  17538. */
  17539. clone(): ConeParticleEmitter;
  17540. /**
  17541. * Called by the GPUParticleSystem to setup the update shader
  17542. * @param effect defines the update shader
  17543. */
  17544. applyToShader(effect: Effect): void;
  17545. /**
  17546. * Returns a string to use to update the GPU particles update shader
  17547. * @returns a string containng the defines string
  17548. */
  17549. getEffectDefines(): string;
  17550. /**
  17551. * Returns the string "ConeParticleEmitter"
  17552. * @returns a string containing the class name
  17553. */
  17554. getClassName(): string;
  17555. /**
  17556. * Serializes the particle system to a JSON object.
  17557. * @returns the JSON object
  17558. */
  17559. serialize(): any;
  17560. /**
  17561. * Parse properties from a JSON object
  17562. * @param serializationObject defines the JSON object
  17563. */
  17564. parse(serializationObject: any): void;
  17565. }
  17566. }
  17567. declare module BABYLON {
  17568. /**
  17569. * Particle emitter emitting particles from the inside of a cylinder.
  17570. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17571. */
  17572. export class CylinderParticleEmitter implements IParticleEmitterType {
  17573. /**
  17574. * The radius of the emission cylinder.
  17575. */
  17576. radius: number;
  17577. /**
  17578. * The height of the emission cylinder.
  17579. */
  17580. height: number;
  17581. /**
  17582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17583. */
  17584. radiusRange: number;
  17585. /**
  17586. * How much to randomize the particle direction [0-1].
  17587. */
  17588. directionRandomizer: number;
  17589. /**
  17590. * Creates a new instance CylinderParticleEmitter
  17591. * @param radius the radius of the emission cylinder (1 by default)
  17592. * @param height the height of the emission cylinder (1 by default)
  17593. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17595. */
  17596. constructor(
  17597. /**
  17598. * The radius of the emission cylinder.
  17599. */
  17600. radius?: number,
  17601. /**
  17602. * The height of the emission cylinder.
  17603. */
  17604. height?: number,
  17605. /**
  17606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17607. */
  17608. radiusRange?: number,
  17609. /**
  17610. * How much to randomize the particle direction [0-1].
  17611. */
  17612. directionRandomizer?: number);
  17613. /**
  17614. * Called by the particle System when the direction is computed for the created particle.
  17615. * @param worldMatrix is the world matrix of the particle system
  17616. * @param directionToUpdate is the direction vector to update with the result
  17617. * @param particle is the particle we are computed the direction for
  17618. */
  17619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17620. /**
  17621. * Called by the particle System when the position is computed for the created particle.
  17622. * @param worldMatrix is the world matrix of the particle system
  17623. * @param positionToUpdate is the position vector to update with the result
  17624. * @param particle is the particle we are computed the position for
  17625. */
  17626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17627. /**
  17628. * Clones the current emitter and returns a copy of it
  17629. * @returns the new emitter
  17630. */
  17631. clone(): CylinderParticleEmitter;
  17632. /**
  17633. * Called by the GPUParticleSystem to setup the update shader
  17634. * @param effect defines the update shader
  17635. */
  17636. applyToShader(effect: Effect): void;
  17637. /**
  17638. * Returns a string to use to update the GPU particles update shader
  17639. * @returns a string containng the defines string
  17640. */
  17641. getEffectDefines(): string;
  17642. /**
  17643. * Returns the string "CylinderParticleEmitter"
  17644. * @returns a string containing the class name
  17645. */
  17646. getClassName(): string;
  17647. /**
  17648. * Serializes the particle system to a JSON object.
  17649. * @returns the JSON object
  17650. */
  17651. serialize(): any;
  17652. /**
  17653. * Parse properties from a JSON object
  17654. * @param serializationObject defines the JSON object
  17655. */
  17656. parse(serializationObject: any): void;
  17657. }
  17658. /**
  17659. * Particle emitter emitting particles from the inside of a cylinder.
  17660. * It emits the particles randomly between two vectors.
  17661. */
  17662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17663. /**
  17664. * The min limit of the emission direction.
  17665. */
  17666. direction1: Vector3;
  17667. /**
  17668. * The max limit of the emission direction.
  17669. */
  17670. direction2: Vector3;
  17671. /**
  17672. * Creates a new instance CylinderDirectedParticleEmitter
  17673. * @param radius the radius of the emission cylinder (1 by default)
  17674. * @param height the height of the emission cylinder (1 by default)
  17675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17676. * @param direction1 the min limit of the emission direction (up vector by default)
  17677. * @param direction2 the max limit of the emission direction (up vector by default)
  17678. */
  17679. constructor(radius?: number, height?: number, radiusRange?: number,
  17680. /**
  17681. * The min limit of the emission direction.
  17682. */
  17683. direction1?: Vector3,
  17684. /**
  17685. * The max limit of the emission direction.
  17686. */
  17687. direction2?: Vector3);
  17688. /**
  17689. * Called by the particle System when the direction is computed for the created particle.
  17690. * @param worldMatrix is the world matrix of the particle system
  17691. * @param directionToUpdate is the direction vector to update with the result
  17692. * @param particle is the particle we are computed the direction for
  17693. */
  17694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17695. /**
  17696. * Clones the current emitter and returns a copy of it
  17697. * @returns the new emitter
  17698. */
  17699. clone(): CylinderDirectedParticleEmitter;
  17700. /**
  17701. * Called by the GPUParticleSystem to setup the update shader
  17702. * @param effect defines the update shader
  17703. */
  17704. applyToShader(effect: Effect): void;
  17705. /**
  17706. * Returns a string to use to update the GPU particles update shader
  17707. * @returns a string containng the defines string
  17708. */
  17709. getEffectDefines(): string;
  17710. /**
  17711. * Returns the string "CylinderDirectedParticleEmitter"
  17712. * @returns a string containing the class name
  17713. */
  17714. getClassName(): string;
  17715. /**
  17716. * Serializes the particle system to a JSON object.
  17717. * @returns the JSON object
  17718. */
  17719. serialize(): any;
  17720. /**
  17721. * Parse properties from a JSON object
  17722. * @param serializationObject defines the JSON object
  17723. */
  17724. parse(serializationObject: any): void;
  17725. }
  17726. }
  17727. declare module BABYLON {
  17728. /**
  17729. * Particle emitter emitting particles from the inside of a hemisphere.
  17730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17731. */
  17732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17733. /**
  17734. * The radius of the emission hemisphere.
  17735. */
  17736. radius: number;
  17737. /**
  17738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17739. */
  17740. radiusRange: number;
  17741. /**
  17742. * How much to randomize the particle direction [0-1].
  17743. */
  17744. directionRandomizer: number;
  17745. /**
  17746. * Creates a new instance HemisphericParticleEmitter
  17747. * @param radius the radius of the emission hemisphere (1 by default)
  17748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17750. */
  17751. constructor(
  17752. /**
  17753. * The radius of the emission hemisphere.
  17754. */
  17755. radius?: number,
  17756. /**
  17757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17758. */
  17759. radiusRange?: number,
  17760. /**
  17761. * How much to randomize the particle direction [0-1].
  17762. */
  17763. directionRandomizer?: number);
  17764. /**
  17765. * Called by the particle System when the direction is computed for the created particle.
  17766. * @param worldMatrix is the world matrix of the particle system
  17767. * @param directionToUpdate is the direction vector to update with the result
  17768. * @param particle is the particle we are computed the direction for
  17769. */
  17770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17771. /**
  17772. * Called by the particle System when the position is computed for the created particle.
  17773. * @param worldMatrix is the world matrix of the particle system
  17774. * @param positionToUpdate is the position vector to update with the result
  17775. * @param particle is the particle we are computed the position for
  17776. */
  17777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17778. /**
  17779. * Clones the current emitter and returns a copy of it
  17780. * @returns the new emitter
  17781. */
  17782. clone(): HemisphericParticleEmitter;
  17783. /**
  17784. * Called by the GPUParticleSystem to setup the update shader
  17785. * @param effect defines the update shader
  17786. */
  17787. applyToShader(effect: Effect): void;
  17788. /**
  17789. * Returns a string to use to update the GPU particles update shader
  17790. * @returns a string containng the defines string
  17791. */
  17792. getEffectDefines(): string;
  17793. /**
  17794. * Returns the string "HemisphericParticleEmitter"
  17795. * @returns a string containing the class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Serializes the particle system to a JSON object.
  17800. * @returns the JSON object
  17801. */
  17802. serialize(): any;
  17803. /**
  17804. * Parse properties from a JSON object
  17805. * @param serializationObject defines the JSON object
  17806. */
  17807. parse(serializationObject: any): void;
  17808. }
  17809. }
  17810. declare module BABYLON {
  17811. /**
  17812. * Particle emitter emitting particles from a point.
  17813. * It emits the particles randomly between 2 given directions.
  17814. */
  17815. export class PointParticleEmitter implements IParticleEmitterType {
  17816. /**
  17817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17818. */
  17819. direction1: Vector3;
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction2: Vector3;
  17824. /**
  17825. * Creates a new instance PointParticleEmitter
  17826. */
  17827. constructor();
  17828. /**
  17829. * Called by the particle System when the direction is computed for the created particle.
  17830. * @param worldMatrix is the world matrix of the particle system
  17831. * @param directionToUpdate is the direction vector to update with the result
  17832. * @param particle is the particle we are computed the direction for
  17833. */
  17834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17835. /**
  17836. * Called by the particle System when the position is computed for the created particle.
  17837. * @param worldMatrix is the world matrix of the particle system
  17838. * @param positionToUpdate is the position vector to update with the result
  17839. * @param particle is the particle we are computed the position for
  17840. */
  17841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17842. /**
  17843. * Clones the current emitter and returns a copy of it
  17844. * @returns the new emitter
  17845. */
  17846. clone(): PointParticleEmitter;
  17847. /**
  17848. * Called by the GPUParticleSystem to setup the update shader
  17849. * @param effect defines the update shader
  17850. */
  17851. applyToShader(effect: Effect): void;
  17852. /**
  17853. * Returns a string to use to update the GPU particles update shader
  17854. * @returns a string containng the defines string
  17855. */
  17856. getEffectDefines(): string;
  17857. /**
  17858. * Returns the string "PointParticleEmitter"
  17859. * @returns a string containing the class name
  17860. */
  17861. getClassName(): string;
  17862. /**
  17863. * Serializes the particle system to a JSON object.
  17864. * @returns the JSON object
  17865. */
  17866. serialize(): any;
  17867. /**
  17868. * Parse properties from a JSON object
  17869. * @param serializationObject defines the JSON object
  17870. */
  17871. parse(serializationObject: any): void;
  17872. }
  17873. }
  17874. declare module BABYLON {
  17875. /**
  17876. * Particle emitter emitting particles from the inside of a sphere.
  17877. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17878. */
  17879. export class SphereParticleEmitter implements IParticleEmitterType {
  17880. /**
  17881. * The radius of the emission sphere.
  17882. */
  17883. radius: number;
  17884. /**
  17885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17886. */
  17887. radiusRange: number;
  17888. /**
  17889. * How much to randomize the particle direction [0-1].
  17890. */
  17891. directionRandomizer: number;
  17892. /**
  17893. * Creates a new instance SphereParticleEmitter
  17894. * @param radius the radius of the emission sphere (1 by default)
  17895. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17897. */
  17898. constructor(
  17899. /**
  17900. * The radius of the emission sphere.
  17901. */
  17902. radius?: number,
  17903. /**
  17904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17905. */
  17906. radiusRange?: number,
  17907. /**
  17908. * How much to randomize the particle direction [0-1].
  17909. */
  17910. directionRandomizer?: number);
  17911. /**
  17912. * Called by the particle System when the direction is computed for the created particle.
  17913. * @param worldMatrix is the world matrix of the particle system
  17914. * @param directionToUpdate is the direction vector to update with the result
  17915. * @param particle is the particle we are computed the direction for
  17916. */
  17917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17918. /**
  17919. * Called by the particle System when the position is computed for the created particle.
  17920. * @param worldMatrix is the world matrix of the particle system
  17921. * @param positionToUpdate is the position vector to update with the result
  17922. * @param particle is the particle we are computed the position for
  17923. */
  17924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17925. /**
  17926. * Clones the current emitter and returns a copy of it
  17927. * @returns the new emitter
  17928. */
  17929. clone(): SphereParticleEmitter;
  17930. /**
  17931. * Called by the GPUParticleSystem to setup the update shader
  17932. * @param effect defines the update shader
  17933. */
  17934. applyToShader(effect: Effect): void;
  17935. /**
  17936. * Returns a string to use to update the GPU particles update shader
  17937. * @returns a string containng the defines string
  17938. */
  17939. getEffectDefines(): string;
  17940. /**
  17941. * Returns the string "SphereParticleEmitter"
  17942. * @returns a string containing the class name
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Serializes the particle system to a JSON object.
  17947. * @returns the JSON object
  17948. */
  17949. serialize(): any;
  17950. /**
  17951. * Parse properties from a JSON object
  17952. * @param serializationObject defines the JSON object
  17953. */
  17954. parse(serializationObject: any): void;
  17955. }
  17956. /**
  17957. * Particle emitter emitting particles from the inside of a sphere.
  17958. * It emits the particles randomly between two vectors.
  17959. */
  17960. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17961. /**
  17962. * The min limit of the emission direction.
  17963. */
  17964. direction1: Vector3;
  17965. /**
  17966. * The max limit of the emission direction.
  17967. */
  17968. direction2: Vector3;
  17969. /**
  17970. * Creates a new instance SphereDirectedParticleEmitter
  17971. * @param radius the radius of the emission sphere (1 by default)
  17972. * @param direction1 the min limit of the emission direction (up vector by default)
  17973. * @param direction2 the max limit of the emission direction (up vector by default)
  17974. */
  17975. constructor(radius?: number,
  17976. /**
  17977. * The min limit of the emission direction.
  17978. */
  17979. direction1?: Vector3,
  17980. /**
  17981. * The max limit of the emission direction.
  17982. */
  17983. direction2?: Vector3);
  17984. /**
  17985. * Called by the particle System when the direction is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param directionToUpdate is the direction vector to update with the result
  17988. * @param particle is the particle we are computed the direction for
  17989. */
  17990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Clones the current emitter and returns a copy of it
  17993. * @returns the new emitter
  17994. */
  17995. clone(): SphereDirectedParticleEmitter;
  17996. /**
  17997. * Called by the GPUParticleSystem to setup the update shader
  17998. * @param effect defines the update shader
  17999. */
  18000. applyToShader(effect: Effect): void;
  18001. /**
  18002. * Returns a string to use to update the GPU particles update shader
  18003. * @returns a string containng the defines string
  18004. */
  18005. getEffectDefines(): string;
  18006. /**
  18007. * Returns the string "SphereDirectedParticleEmitter"
  18008. * @returns a string containing the class name
  18009. */
  18010. getClassName(): string;
  18011. /**
  18012. * Serializes the particle system to a JSON object.
  18013. * @returns the JSON object
  18014. */
  18015. serialize(): any;
  18016. /**
  18017. * Parse properties from a JSON object
  18018. * @param serializationObject defines the JSON object
  18019. */
  18020. parse(serializationObject: any): void;
  18021. }
  18022. }
  18023. declare module BABYLON {
  18024. /**
  18025. * Interface representing a particle system in Babylon.js.
  18026. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18027. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18028. */
  18029. export interface IParticleSystem {
  18030. /**
  18031. * List of animations used by the particle system.
  18032. */
  18033. animations: Animation[];
  18034. /**
  18035. * The id of the Particle system.
  18036. */
  18037. id: string;
  18038. /**
  18039. * The name of the Particle system.
  18040. */
  18041. name: string;
  18042. /**
  18043. * The emitter represents the Mesh or position we are attaching the particle system to.
  18044. */
  18045. emitter: Nullable<AbstractMesh | Vector3>;
  18046. /**
  18047. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18048. */
  18049. isBillboardBased: boolean;
  18050. /**
  18051. * The rendering group used by the Particle system to chose when to render.
  18052. */
  18053. renderingGroupId: number;
  18054. /**
  18055. * The layer mask we are rendering the particles through.
  18056. */
  18057. layerMask: number;
  18058. /**
  18059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18060. */
  18061. updateSpeed: number;
  18062. /**
  18063. * The amount of time the particle system is running (depends of the overall update speed).
  18064. */
  18065. targetStopDuration: number;
  18066. /**
  18067. * The texture used to render each particle. (this can be a spritesheet)
  18068. */
  18069. particleTexture: Nullable<Texture>;
  18070. /**
  18071. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18072. */
  18073. blendMode: number;
  18074. /**
  18075. * Minimum life time of emitting particles.
  18076. */
  18077. minLifeTime: number;
  18078. /**
  18079. * Maximum life time of emitting particles.
  18080. */
  18081. maxLifeTime: number;
  18082. /**
  18083. * Minimum Size of emitting particles.
  18084. */
  18085. minSize: number;
  18086. /**
  18087. * Maximum Size of emitting particles.
  18088. */
  18089. maxSize: number;
  18090. /**
  18091. * Minimum scale of emitting particles on X axis.
  18092. */
  18093. minScaleX: number;
  18094. /**
  18095. * Maximum scale of emitting particles on X axis.
  18096. */
  18097. maxScaleX: number;
  18098. /**
  18099. * Minimum scale of emitting particles on Y axis.
  18100. */
  18101. minScaleY: number;
  18102. /**
  18103. * Maximum scale of emitting particles on Y axis.
  18104. */
  18105. maxScaleY: number;
  18106. /**
  18107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18108. */
  18109. color1: Color4;
  18110. /**
  18111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18112. */
  18113. color2: Color4;
  18114. /**
  18115. * Color the particle will have at the end of its lifetime.
  18116. */
  18117. colorDead: Color4;
  18118. /**
  18119. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18120. */
  18121. emitRate: number;
  18122. /**
  18123. * You can use gravity if you want to give an orientation to your particles.
  18124. */
  18125. gravity: Vector3;
  18126. /**
  18127. * Minimum power of emitting particles.
  18128. */
  18129. minEmitPower: number;
  18130. /**
  18131. * Maximum power of emitting particles.
  18132. */
  18133. maxEmitPower: number;
  18134. /**
  18135. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18136. */
  18137. minAngularSpeed: number;
  18138. /**
  18139. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18140. */
  18141. maxAngularSpeed: number;
  18142. /**
  18143. * Gets or sets the minimal initial rotation in radians.
  18144. */
  18145. minInitialRotation: number;
  18146. /**
  18147. * Gets or sets the maximal initial rotation in radians.
  18148. */
  18149. maxInitialRotation: number;
  18150. /**
  18151. * The particle emitter type defines the emitter used by the particle system.
  18152. * It can be for example box, sphere, or cone...
  18153. */
  18154. particleEmitterType: Nullable<IParticleEmitterType>;
  18155. /**
  18156. * Defines the delay in milliseconds before starting the system (0 by default)
  18157. */
  18158. startDelay: number;
  18159. /**
  18160. * 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
  18161. */
  18162. preWarmCycles: number;
  18163. /**
  18164. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18165. */
  18166. preWarmStepOffset: number;
  18167. /**
  18168. * 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)
  18169. */
  18170. spriteCellChangeSpeed: number;
  18171. /**
  18172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18173. */
  18174. startSpriteCellID: number;
  18175. /**
  18176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18177. */
  18178. endSpriteCellID: number;
  18179. /**
  18180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18181. */
  18182. spriteCellWidth: number;
  18183. /**
  18184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18185. */
  18186. spriteCellHeight: number;
  18187. /**
  18188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18189. */
  18190. spriteRandomStartCell: boolean;
  18191. /**
  18192. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18193. */
  18194. isAnimationSheetEnabled: boolean;
  18195. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18196. translationPivot: Vector2;
  18197. /**
  18198. * Gets or sets a texture used to add random noise to particle positions
  18199. */
  18200. noiseTexture: Nullable<BaseTexture>;
  18201. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18202. noiseStrength: Vector3;
  18203. /**
  18204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18206. */
  18207. billboardMode: number;
  18208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18209. limitVelocityDamping: number;
  18210. /**
  18211. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18212. */
  18213. beginAnimationOnStart: boolean;
  18214. /**
  18215. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18216. */
  18217. beginAnimationFrom: number;
  18218. /**
  18219. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18220. */
  18221. beginAnimationTo: number;
  18222. /**
  18223. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18224. */
  18225. beginAnimationLoop: boolean;
  18226. /**
  18227. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18228. */
  18229. disposeOnStop: boolean;
  18230. /**
  18231. * Gets the maximum number of particles active at the same time.
  18232. * @returns The max number of active particles.
  18233. */
  18234. getCapacity(): number;
  18235. /**
  18236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18237. * @returns True if it has been started, otherwise false.
  18238. */
  18239. isStarted(): boolean;
  18240. /**
  18241. * Animates the particle system for this frame.
  18242. */
  18243. animate(): void;
  18244. /**
  18245. * Renders the particle system in its current state.
  18246. * @returns the current number of particles
  18247. */
  18248. render(): number;
  18249. /**
  18250. * Dispose the particle system and frees its associated resources.
  18251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18252. */
  18253. dispose(disposeTexture?: boolean): void;
  18254. /**
  18255. * Clones the particle system.
  18256. * @param name The name of the cloned object
  18257. * @param newEmitter The new emitter to use
  18258. * @returns the cloned particle system
  18259. */
  18260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Rebuild the particle system
  18268. */
  18269. rebuild(): void;
  18270. /**
  18271. * Starts the particle system and begins to emit
  18272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18273. */
  18274. start(delay?: number): void;
  18275. /**
  18276. * Stops the particle system.
  18277. */
  18278. stop(): void;
  18279. /**
  18280. * Remove all active particles
  18281. */
  18282. reset(): void;
  18283. /**
  18284. * Is this system ready to be used/rendered
  18285. * @return true if the system is ready
  18286. */
  18287. isReady(): boolean;
  18288. /**
  18289. * Adds a new color gradient
  18290. * @param gradient defines the gradient to use (between 0 and 1)
  18291. * @param color1 defines the color to affect to the specified gradient
  18292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18293. * @returns the current particle system
  18294. */
  18295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18296. /**
  18297. * Remove a specific color gradient
  18298. * @param gradient defines the gradient to remove
  18299. * @returns the current particle system
  18300. */
  18301. removeColorGradient(gradient: number): IParticleSystem;
  18302. /**
  18303. * Adds a new size gradient
  18304. * @param gradient defines the gradient to use (between 0 and 1)
  18305. * @param factor defines the size factor to affect to the specified gradient
  18306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18307. * @returns the current particle system
  18308. */
  18309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18310. /**
  18311. * Remove a specific size gradient
  18312. * @param gradient defines the gradient to remove
  18313. * @returns the current particle system
  18314. */
  18315. removeSizeGradient(gradient: number): IParticleSystem;
  18316. /**
  18317. * Gets the current list of color gradients.
  18318. * You must use addColorGradient and removeColorGradient to udpate this list
  18319. * @returns the list of color gradients
  18320. */
  18321. getColorGradients(): Nullable<Array<ColorGradient>>;
  18322. /**
  18323. * Gets the current list of size gradients.
  18324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18325. * @returns the list of size gradients
  18326. */
  18327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18328. /**
  18329. * Gets the current list of angular speed gradients.
  18330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18331. * @returns the list of angular speed gradients
  18332. */
  18333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18334. /**
  18335. * Adds a new angular speed gradient
  18336. * @param gradient defines the gradient to use (between 0 and 1)
  18337. * @param factor defines the angular speed to affect to the specified gradient
  18338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18339. * @returns the current particle system
  18340. */
  18341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18342. /**
  18343. * Remove a specific angular speed gradient
  18344. * @param gradient defines the gradient to remove
  18345. * @returns the current particle system
  18346. */
  18347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18348. /**
  18349. * Gets the current list of velocity gradients.
  18350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18351. * @returns the list of velocity gradients
  18352. */
  18353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18354. /**
  18355. * Adds a new velocity gradient
  18356. * @param gradient defines the gradient to use (between 0 and 1)
  18357. * @param factor defines the velocity to affect to the specified gradient
  18358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18359. * @returns the current particle system
  18360. */
  18361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18362. /**
  18363. * Remove a specific velocity gradient
  18364. * @param gradient defines the gradient to remove
  18365. * @returns the current particle system
  18366. */
  18367. removeVelocityGradient(gradient: number): IParticleSystem;
  18368. /**
  18369. * Gets the current list of limit velocity gradients.
  18370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18371. * @returns the list of limit velocity gradients
  18372. */
  18373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18374. /**
  18375. * Adds a new limit velocity gradient
  18376. * @param gradient defines the gradient to use (between 0 and 1)
  18377. * @param factor defines the limit velocity to affect to the specified gradient
  18378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18379. * @returns the current particle system
  18380. */
  18381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18382. /**
  18383. * Remove a specific limit velocity gradient
  18384. * @param gradient defines the gradient to remove
  18385. * @returns the current particle system
  18386. */
  18387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18388. /**
  18389. * Adds a new drag gradient
  18390. * @param gradient defines the gradient to use (between 0 and 1)
  18391. * @param factor defines the drag to affect to the specified gradient
  18392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18393. * @returns the current particle system
  18394. */
  18395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18396. /**
  18397. * Remove a specific drag gradient
  18398. * @param gradient defines the gradient to remove
  18399. * @returns the current particle system
  18400. */
  18401. removeDragGradient(gradient: number): IParticleSystem;
  18402. /**
  18403. * Gets the current list of drag gradients.
  18404. * You must use addDragGradient and removeDragGradient to udpate this list
  18405. * @returns the list of drag gradients
  18406. */
  18407. getDragGradients(): Nullable<Array<FactorGradient>>;
  18408. /**
  18409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param factor defines the emit rate to affect to the specified gradient
  18412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18413. * @returns the current particle system
  18414. */
  18415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18416. /**
  18417. * Remove a specific emit rate gradient
  18418. * @param gradient defines the gradient to remove
  18419. * @returns the current particle system
  18420. */
  18421. removeEmitRateGradient(gradient: number): IParticleSystem;
  18422. /**
  18423. * Gets the current list of emit rate gradients.
  18424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18425. * @returns the list of emit rate gradients
  18426. */
  18427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18428. /**
  18429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18430. * @param gradient defines the gradient to use (between 0 and 1)
  18431. * @param factor defines the start size to affect to the specified gradient
  18432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18433. * @returns the current particle system
  18434. */
  18435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18436. /**
  18437. * Remove a specific start size gradient
  18438. * @param gradient defines the gradient to remove
  18439. * @returns the current particle system
  18440. */
  18441. removeStartSizeGradient(gradient: number): IParticleSystem;
  18442. /**
  18443. * Gets the current list of start size gradients.
  18444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18445. * @returns the list of start size gradients
  18446. */
  18447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18448. /**
  18449. * Adds a new life time gradient
  18450. * @param gradient defines the gradient to use (between 0 and 1)
  18451. * @param factor defines the life time factor to affect to the specified gradient
  18452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18453. * @returns the current particle system
  18454. */
  18455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18456. /**
  18457. * Remove a specific life time gradient
  18458. * @param gradient defines the gradient to remove
  18459. * @returns the current particle system
  18460. */
  18461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18462. /**
  18463. * Gets the current list of life time gradients.
  18464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18465. * @returns the list of life time gradients
  18466. */
  18467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18468. /**
  18469. * Gets the current list of color gradients.
  18470. * You must use addColorGradient and removeColorGradient to udpate this list
  18471. * @returns the list of color gradients
  18472. */
  18473. getColorGradients(): Nullable<Array<ColorGradient>>;
  18474. /**
  18475. * Adds a new ramp gradient used to remap particle colors
  18476. * @param gradient defines the gradient to use (between 0 and 1)
  18477. * @param color defines the color to affect to the specified gradient
  18478. * @returns the current particle system
  18479. */
  18480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18481. /**
  18482. * Gets the current list of ramp gradients.
  18483. * You must use addRampGradient and removeRampGradient to udpate this list
  18484. * @returns the list of ramp gradients
  18485. */
  18486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18487. /** Gets or sets a boolean indicating that ramp gradients must be used
  18488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18489. */
  18490. useRampGradients: boolean;
  18491. /**
  18492. * Adds a new color remap gradient
  18493. * @param gradient defines the gradient to use (between 0 and 1)
  18494. * @param min defines the color remap minimal range
  18495. * @param max defines the color remap maximal range
  18496. * @returns the current particle system
  18497. */
  18498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18499. /**
  18500. * Gets the current list of color remap gradients.
  18501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18502. * @returns the list of color remap gradients
  18503. */
  18504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18505. /**
  18506. * Adds a new alpha remap gradient
  18507. * @param gradient defines the gradient to use (between 0 and 1)
  18508. * @param min defines the alpha remap minimal range
  18509. * @param max defines the alpha remap maximal range
  18510. * @returns the current particle system
  18511. */
  18512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18513. /**
  18514. * Gets the current list of alpha remap gradients.
  18515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18516. * @returns the list of alpha remap gradients
  18517. */
  18518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18519. /**
  18520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18523. * @returns the emitter
  18524. */
  18525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18526. /**
  18527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18528. * @param radius The radius of the hemisphere to emit from
  18529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18530. * @returns the emitter
  18531. */
  18532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18533. /**
  18534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18535. * @param radius The radius of the sphere to emit from
  18536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18537. * @returns the emitter
  18538. */
  18539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18540. /**
  18541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18542. * @param radius The radius of the sphere to emit from
  18543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18545. * @returns the emitter
  18546. */
  18547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18548. /**
  18549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18550. * @param radius The radius of the emission cylinder
  18551. * @param height The height of the emission cylinder
  18552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18554. * @returns the emitter
  18555. */
  18556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18557. /**
  18558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18559. * @param radius The radius of the cylinder to emit from
  18560. * @param height The height of the emission cylinder
  18561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18564. * @returns the emitter
  18565. */
  18566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18567. /**
  18568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18569. * @param radius The radius of the cone to emit from
  18570. * @param angle The base angle of the cone
  18571. * @returns the emitter
  18572. */
  18573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18574. /**
  18575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18580. * @returns the emitter
  18581. */
  18582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18583. /**
  18584. * Get hosting scene
  18585. * @returns the scene
  18586. */
  18587. getScene(): Scene;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * Creates an instance based on a source mesh.
  18593. */
  18594. export class InstancedMesh extends AbstractMesh {
  18595. private _sourceMesh;
  18596. private _currentLOD;
  18597. /** @hidden */
  18598. _indexInSourceMeshInstanceArray: number;
  18599. constructor(name: string, source: Mesh);
  18600. /**
  18601. * Returns the string "InstancedMesh".
  18602. */
  18603. getClassName(): string;
  18604. /** Gets the list of lights affecting that mesh */
  18605. readonly lightSources: Light[];
  18606. _resyncLightSources(): void;
  18607. _resyncLighSource(light: Light): void;
  18608. _removeLightSource(light: Light, dispose: boolean): void;
  18609. /**
  18610. * If the source mesh receives shadows
  18611. */
  18612. readonly receiveShadows: boolean;
  18613. /**
  18614. * The material of the source mesh
  18615. */
  18616. readonly material: Nullable<Material>;
  18617. /**
  18618. * Visibility of the source mesh
  18619. */
  18620. readonly visibility: number;
  18621. /**
  18622. * Skeleton of the source mesh
  18623. */
  18624. readonly skeleton: Nullable<Skeleton>;
  18625. /**
  18626. * Rendering ground id of the source mesh
  18627. */
  18628. renderingGroupId: number;
  18629. /**
  18630. * Returns the total number of vertices (integer).
  18631. */
  18632. getTotalVertices(): number;
  18633. /**
  18634. * Returns a positive integer : the total number of indices in this mesh geometry.
  18635. * @returns the numner of indices or zero if the mesh has no geometry.
  18636. */
  18637. getTotalIndices(): number;
  18638. /**
  18639. * The source mesh of the instance
  18640. */
  18641. readonly sourceMesh: Mesh;
  18642. /**
  18643. * Is this node ready to be used/rendered
  18644. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18645. * @return {boolean} is it ready
  18646. */
  18647. isReady(completeCheck?: boolean): boolean;
  18648. /**
  18649. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18650. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18651. * @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.
  18652. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18653. */
  18654. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18655. /**
  18656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18658. * The `data` are either a numeric array either a Float32Array.
  18659. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18660. * 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).
  18661. * Note that a new underlying VertexBuffer object is created each call.
  18662. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18663. *
  18664. * Possible `kind` values :
  18665. * - VertexBuffer.PositionKind
  18666. * - VertexBuffer.UVKind
  18667. * - VertexBuffer.UV2Kind
  18668. * - VertexBuffer.UV3Kind
  18669. * - VertexBuffer.UV4Kind
  18670. * - VertexBuffer.UV5Kind
  18671. * - VertexBuffer.UV6Kind
  18672. * - VertexBuffer.ColorKind
  18673. * - VertexBuffer.MatricesIndicesKind
  18674. * - VertexBuffer.MatricesIndicesExtraKind
  18675. * - VertexBuffer.MatricesWeightsKind
  18676. * - VertexBuffer.MatricesWeightsExtraKind
  18677. *
  18678. * Returns the Mesh.
  18679. */
  18680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18681. /**
  18682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18683. * If the mesh has no geometry, it is simply returned as it is.
  18684. * The `data` are either a numeric array either a Float32Array.
  18685. * No new underlying VertexBuffer object is created.
  18686. * 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.
  18687. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18688. *
  18689. * Possible `kind` values :
  18690. * - VertexBuffer.PositionKind
  18691. * - VertexBuffer.UVKind
  18692. * - VertexBuffer.UV2Kind
  18693. * - VertexBuffer.UV3Kind
  18694. * - VertexBuffer.UV4Kind
  18695. * - VertexBuffer.UV5Kind
  18696. * - VertexBuffer.UV6Kind
  18697. * - VertexBuffer.ColorKind
  18698. * - VertexBuffer.MatricesIndicesKind
  18699. * - VertexBuffer.MatricesIndicesExtraKind
  18700. * - VertexBuffer.MatricesWeightsKind
  18701. * - VertexBuffer.MatricesWeightsExtraKind
  18702. *
  18703. * Returns the Mesh.
  18704. */
  18705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18706. /**
  18707. * Sets the mesh indices.
  18708. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18710. * This method creates a new index buffer each call.
  18711. * Returns the Mesh.
  18712. */
  18713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18714. /**
  18715. * Boolean : True if the mesh owns the requested kind of data.
  18716. */
  18717. isVerticesDataPresent(kind: string): boolean;
  18718. /**
  18719. * Returns an array of indices (IndicesArray).
  18720. */
  18721. getIndices(): Nullable<IndicesArray>;
  18722. readonly _positions: Nullable<Vector3[]>;
  18723. /**
  18724. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18725. * This means the mesh underlying bounding box and sphere are recomputed.
  18726. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18727. * @returns the current mesh
  18728. */
  18729. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18730. /** @hidden */
  18731. _preActivate(): InstancedMesh;
  18732. /** @hidden */
  18733. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18734. /** @hidden */
  18735. _postActivate(): void;
  18736. getWorldMatrix(): Matrix;
  18737. readonly isAnInstance: boolean;
  18738. /**
  18739. * Returns the current associated LOD AbstractMesh.
  18740. */
  18741. getLOD(camera: Camera): AbstractMesh;
  18742. /** @hidden */
  18743. _syncSubMeshes(): InstancedMesh;
  18744. /** @hidden */
  18745. _generatePointsArray(): boolean;
  18746. /**
  18747. * Creates a new InstancedMesh from the current mesh.
  18748. * - name (string) : the cloned mesh name
  18749. * - newParent (optional Node) : the optional Node to parent the clone to.
  18750. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18751. *
  18752. * Returns the clone.
  18753. */
  18754. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18755. /**
  18756. * Disposes the InstancedMesh.
  18757. * Returns nothing.
  18758. */
  18759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18760. }
  18761. }
  18762. declare module BABYLON {
  18763. /**
  18764. * Defines the options associated with the creation of a shader material.
  18765. */
  18766. export interface IShaderMaterialOptions {
  18767. /**
  18768. * Does the material work in alpha blend mode
  18769. */
  18770. needAlphaBlending: boolean;
  18771. /**
  18772. * Does the material work in alpha test mode
  18773. */
  18774. needAlphaTesting: boolean;
  18775. /**
  18776. * The list of attribute names used in the shader
  18777. */
  18778. attributes: string[];
  18779. /**
  18780. * The list of unifrom names used in the shader
  18781. */
  18782. uniforms: string[];
  18783. /**
  18784. * The list of UBO names used in the shader
  18785. */
  18786. uniformBuffers: string[];
  18787. /**
  18788. * The list of sampler names used in the shader
  18789. */
  18790. samplers: string[];
  18791. /**
  18792. * The list of defines used in the shader
  18793. */
  18794. defines: string[];
  18795. }
  18796. /**
  18797. * 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.
  18798. *
  18799. * This returned material effects how the mesh will look based on the code in the shaders.
  18800. *
  18801. * @see http://doc.babylonjs.com/how_to/shader_material
  18802. */
  18803. export class ShaderMaterial extends Material {
  18804. private _shaderPath;
  18805. private _options;
  18806. private _textures;
  18807. private _textureArrays;
  18808. private _floats;
  18809. private _ints;
  18810. private _floatsArrays;
  18811. private _colors3;
  18812. private _colors3Arrays;
  18813. private _colors4;
  18814. private _colors4Arrays;
  18815. private _vectors2;
  18816. private _vectors3;
  18817. private _vectors4;
  18818. private _matrices;
  18819. private _matrices3x3;
  18820. private _matrices2x2;
  18821. private _vectors2Arrays;
  18822. private _vectors3Arrays;
  18823. private _vectors4Arrays;
  18824. private _cachedWorldViewMatrix;
  18825. private _cachedWorldViewProjectionMatrix;
  18826. private _renderId;
  18827. /**
  18828. * Instantiate a new shader material.
  18829. * 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.
  18830. * This returned material effects how the mesh will look based on the code in the shaders.
  18831. * @see http://doc.babylonjs.com/how_to/shader_material
  18832. * @param name Define the name of the material in the scene
  18833. * @param scene Define the scene the material belongs to
  18834. * @param shaderPath Defines the route to the shader code in one of three ways:
  18835. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18836. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18837. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18838. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18839. * @param options Define the options used to create the shader
  18840. */
  18841. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18842. /**
  18843. * Gets the options used to compile the shader.
  18844. * They can be modified to trigger a new compilation
  18845. */
  18846. readonly options: IShaderMaterialOptions;
  18847. /**
  18848. * Gets the current class name of the material e.g. "ShaderMaterial"
  18849. * Mainly use in serialization.
  18850. * @returns the class name
  18851. */
  18852. getClassName(): string;
  18853. /**
  18854. * Specifies if the material will require alpha blending
  18855. * @returns a boolean specifying if alpha blending is needed
  18856. */
  18857. needAlphaBlending(): boolean;
  18858. /**
  18859. * Specifies if this material should be rendered in alpha test mode
  18860. * @returns a boolean specifying if an alpha test is needed.
  18861. */
  18862. needAlphaTesting(): boolean;
  18863. private _checkUniform;
  18864. /**
  18865. * Set a texture in the shader.
  18866. * @param name Define the name of the uniform samplers as defined in the shader
  18867. * @param texture Define the texture to bind to this sampler
  18868. * @return the material itself allowing "fluent" like uniform updates
  18869. */
  18870. setTexture(name: string, texture: Texture): ShaderMaterial;
  18871. /**
  18872. * Set a texture array in the shader.
  18873. * @param name Define the name of the uniform sampler array as defined in the shader
  18874. * @param textures Define the list of textures to bind to this sampler
  18875. * @return the material itself allowing "fluent" like uniform updates
  18876. */
  18877. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18878. /**
  18879. * Set a float in the shader.
  18880. * @param name Define the name of the uniform as defined in the shader
  18881. * @param value Define the value to give to the uniform
  18882. * @return the material itself allowing "fluent" like uniform updates
  18883. */
  18884. setFloat(name: string, value: number): ShaderMaterial;
  18885. /**
  18886. * Set a int in the shader.
  18887. * @param name Define the name of the uniform as defined in the shader
  18888. * @param value Define the value to give to the uniform
  18889. * @return the material itself allowing "fluent" like uniform updates
  18890. */
  18891. setInt(name: string, value: number): ShaderMaterial;
  18892. /**
  18893. * Set an array of floats in the shader.
  18894. * @param name Define the name of the uniform as defined in the shader
  18895. * @param value Define the value to give to the uniform
  18896. * @return the material itself allowing "fluent" like uniform updates
  18897. */
  18898. setFloats(name: string, value: number[]): ShaderMaterial;
  18899. /**
  18900. * Set a vec3 in the shader from a Color3.
  18901. * @param name Define the name of the uniform as defined in the shader
  18902. * @param value Define the value to give to the uniform
  18903. * @return the material itself allowing "fluent" like uniform updates
  18904. */
  18905. setColor3(name: string, value: Color3): ShaderMaterial;
  18906. /**
  18907. * Set a vec3 array in the shader from a Color3 array.
  18908. * @param name Define the name of the uniform as defined in the shader
  18909. * @param value Define the value to give to the uniform
  18910. * @return the material itself allowing "fluent" like uniform updates
  18911. */
  18912. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18913. /**
  18914. * Set a vec4 in the shader from a Color4.
  18915. * @param name Define the name of the uniform as defined in the shader
  18916. * @param value Define the value to give to the uniform
  18917. * @return the material itself allowing "fluent" like uniform updates
  18918. */
  18919. setColor4(name: string, value: Color4): ShaderMaterial;
  18920. /**
  18921. * Set a vec4 array in the shader from a Color4 array.
  18922. * @param name Define the name of the uniform as defined in the shader
  18923. * @param value Define the value to give to the uniform
  18924. * @return the material itself allowing "fluent" like uniform updates
  18925. */
  18926. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18927. /**
  18928. * Set a vec2 in the shader from a Vector2.
  18929. * @param name Define the name of the uniform as defined in the shader
  18930. * @param value Define the value to give to the uniform
  18931. * @return the material itself allowing "fluent" like uniform updates
  18932. */
  18933. setVector2(name: string, value: Vector2): ShaderMaterial;
  18934. /**
  18935. * Set a vec3 in the shader from a Vector3.
  18936. * @param name Define the name of the uniform as defined in the shader
  18937. * @param value Define the value to give to the uniform
  18938. * @return the material itself allowing "fluent" like uniform updates
  18939. */
  18940. setVector3(name: string, value: Vector3): ShaderMaterial;
  18941. /**
  18942. * Set a vec4 in the shader from a Vector4.
  18943. * @param name Define the name of the uniform as defined in the shader
  18944. * @param value Define the value to give to the uniform
  18945. * @return the material itself allowing "fluent" like uniform updates
  18946. */
  18947. setVector4(name: string, value: Vector4): ShaderMaterial;
  18948. /**
  18949. * Set a mat4 in the shader from a Matrix.
  18950. * @param name Define the name of the uniform as defined in the shader
  18951. * @param value Define the value to give to the uniform
  18952. * @return the material itself allowing "fluent" like uniform updates
  18953. */
  18954. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18955. /**
  18956. * Set a mat3 in the shader from a Float32Array.
  18957. * @param name Define the name of the uniform as defined in the shader
  18958. * @param value Define the value to give to the uniform
  18959. * @return the material itself allowing "fluent" like uniform updates
  18960. */
  18961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18962. /**
  18963. * Set a mat2 in the shader from a Float32Array.
  18964. * @param name Define the name of the uniform as defined in the shader
  18965. * @param value Define the value to give to the uniform
  18966. * @return the material itself allowing "fluent" like uniform updates
  18967. */
  18968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18969. /**
  18970. * Set a vec2 array in the shader from a number array.
  18971. * @param name Define the name of the uniform as defined in the shader
  18972. * @param value Define the value to give to the uniform
  18973. * @return the material itself allowing "fluent" like uniform updates
  18974. */
  18975. setArray2(name: string, value: number[]): ShaderMaterial;
  18976. /**
  18977. * Set a vec3 array in the shader from a number array.
  18978. * @param name Define the name of the uniform as defined in the shader
  18979. * @param value Define the value to give to the uniform
  18980. * @return the material itself allowing "fluent" like uniform updates
  18981. */
  18982. setArray3(name: string, value: number[]): ShaderMaterial;
  18983. /**
  18984. * Set a vec4 array in the shader from a number array.
  18985. * @param name Define the name of the uniform as defined in the shader
  18986. * @param value Define the value to give to the uniform
  18987. * @return the material itself allowing "fluent" like uniform updates
  18988. */
  18989. setArray4(name: string, value: number[]): ShaderMaterial;
  18990. private _checkCache;
  18991. /**
  18992. * Specifies that the submesh is ready to be used
  18993. * @param mesh defines the mesh to check
  18994. * @param subMesh defines which submesh to check
  18995. * @param useInstances specifies that instances should be used
  18996. * @returns a boolean indicating that the submesh is ready or not
  18997. */
  18998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18999. /**
  19000. * Checks if the material is ready to render the requested mesh
  19001. * @param mesh Define the mesh to render
  19002. * @param useInstances Define whether or not the material is used with instances
  19003. * @returns true if ready, otherwise false
  19004. */
  19005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19006. /**
  19007. * Binds the world matrix to the material
  19008. * @param world defines the world transformation matrix
  19009. */
  19010. bindOnlyWorldMatrix(world: Matrix): void;
  19011. /**
  19012. * Binds the material to the mesh
  19013. * @param world defines the world transformation matrix
  19014. * @param mesh defines the mesh to bind the material to
  19015. */
  19016. bind(world: Matrix, mesh?: Mesh): void;
  19017. /**
  19018. * Gets the active textures from the material
  19019. * @returns an array of textures
  19020. */
  19021. getActiveTextures(): BaseTexture[];
  19022. /**
  19023. * Specifies if the material uses a texture
  19024. * @param texture defines the texture to check against the material
  19025. * @returns a boolean specifying if the material uses the texture
  19026. */
  19027. hasTexture(texture: BaseTexture): boolean;
  19028. /**
  19029. * Makes a duplicate of the material, and gives it a new name
  19030. * @param name defines the new name for the duplicated material
  19031. * @returns the cloned material
  19032. */
  19033. clone(name: string): ShaderMaterial;
  19034. /**
  19035. * Disposes the material
  19036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19039. */
  19040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19041. /**
  19042. * Serializes this material in a JSON representation
  19043. * @returns the serialized material object
  19044. */
  19045. serialize(): any;
  19046. /**
  19047. * Creates a shader material from parsed shader material data
  19048. * @param source defines the JSON represnetation of the material
  19049. * @param scene defines the hosting scene
  19050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19051. * @returns a new material
  19052. */
  19053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19054. }
  19055. }
  19056. declare module BABYLON {
  19057. /** @hidden */
  19058. export var colorPixelShader: {
  19059. name: string;
  19060. shader: string;
  19061. };
  19062. }
  19063. declare module BABYLON {
  19064. /** @hidden */
  19065. export var colorVertexShader: {
  19066. name: string;
  19067. shader: string;
  19068. };
  19069. }
  19070. declare module BABYLON {
  19071. /**
  19072. * Line mesh
  19073. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19074. */
  19075. export class LinesMesh extends Mesh {
  19076. /**
  19077. * If vertex color should be applied to the mesh
  19078. */
  19079. readonly useVertexColor?: boolean | undefined;
  19080. /**
  19081. * If vertex alpha should be applied to the mesh
  19082. */
  19083. readonly useVertexAlpha?: boolean | undefined;
  19084. /**
  19085. * Color of the line (Default: White)
  19086. */
  19087. color: Color3;
  19088. /**
  19089. * Alpha of the line (Default: 1)
  19090. */
  19091. alpha: number;
  19092. /**
  19093. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19094. * This margin is expressed in world space coordinates, so its value may vary.
  19095. * Default value is 0.1
  19096. */
  19097. intersectionThreshold: number;
  19098. private _colorShader;
  19099. private color4;
  19100. /**
  19101. * Creates a new LinesMesh
  19102. * @param name defines the name
  19103. * @param scene defines the hosting scene
  19104. * @param parent defines the parent mesh if any
  19105. * @param source defines the optional source LinesMesh used to clone data from
  19106. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19107. * When false, achieved by calling a clone(), also passing False.
  19108. * This will make creation of children, recursive.
  19109. * @param useVertexColor defines if this LinesMesh supports vertex color
  19110. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19111. */
  19112. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19113. /**
  19114. * If vertex color should be applied to the mesh
  19115. */
  19116. useVertexColor?: boolean | undefined,
  19117. /**
  19118. * If vertex alpha should be applied to the mesh
  19119. */
  19120. useVertexAlpha?: boolean | undefined);
  19121. private _addClipPlaneDefine;
  19122. private _removeClipPlaneDefine;
  19123. isReady(): boolean;
  19124. /**
  19125. * Returns the string "LineMesh"
  19126. */
  19127. getClassName(): string;
  19128. /**
  19129. * @hidden
  19130. */
  19131. /**
  19132. * @hidden
  19133. */
  19134. material: Material;
  19135. /**
  19136. * @hidden
  19137. */
  19138. readonly checkCollisions: boolean;
  19139. /** @hidden */
  19140. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19141. /** @hidden */
  19142. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19143. /**
  19144. * Disposes of the line mesh
  19145. * @param doNotRecurse If children should be disposed
  19146. */
  19147. dispose(doNotRecurse?: boolean): void;
  19148. /**
  19149. * Returns a new LineMesh object cloned from the current one.
  19150. */
  19151. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19152. /**
  19153. * Creates a new InstancedLinesMesh object from the mesh model.
  19154. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19155. * @param name defines the name of the new instance
  19156. * @returns a new InstancedLinesMesh
  19157. */
  19158. createInstance(name: string): InstancedLinesMesh;
  19159. }
  19160. /**
  19161. * Creates an instance based on a source LinesMesh
  19162. */
  19163. export class InstancedLinesMesh extends InstancedMesh {
  19164. /**
  19165. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19166. * This margin is expressed in world space coordinates, so its value may vary.
  19167. * Initilized with the intersectionThreshold value of the source LinesMesh
  19168. */
  19169. intersectionThreshold: number;
  19170. constructor(name: string, source: LinesMesh);
  19171. /**
  19172. * Returns the string "InstancedLinesMesh".
  19173. */
  19174. getClassName(): string;
  19175. }
  19176. }
  19177. declare module BABYLON {
  19178. /** @hidden */
  19179. export var linePixelShader: {
  19180. name: string;
  19181. shader: string;
  19182. };
  19183. }
  19184. declare module BABYLON {
  19185. /** @hidden */
  19186. export var lineVertexShader: {
  19187. name: string;
  19188. shader: string;
  19189. };
  19190. }
  19191. declare module BABYLON {
  19192. interface AbstractMesh {
  19193. /**
  19194. * Gets the edgesRenderer associated with the mesh
  19195. */
  19196. edgesRenderer: Nullable<EdgesRenderer>;
  19197. }
  19198. interface LinesMesh {
  19199. /**
  19200. * Enables the edge rendering mode on the mesh.
  19201. * This mode makes the mesh edges visible
  19202. * @param epsilon defines the maximal distance between two angles to detect a face
  19203. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19204. * @returns the currentAbstractMesh
  19205. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19206. */
  19207. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19208. }
  19209. interface InstancedLinesMesh {
  19210. /**
  19211. * Enables the edge rendering mode on the mesh.
  19212. * This mode makes the mesh edges visible
  19213. * @param epsilon defines the maximal distance between two angles to detect a face
  19214. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19215. * @returns the current InstancedLinesMesh
  19216. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19217. */
  19218. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19219. }
  19220. /**
  19221. * Defines the minimum contract an Edges renderer should follow.
  19222. */
  19223. export interface IEdgesRenderer extends IDisposable {
  19224. /**
  19225. * Gets or sets a boolean indicating if the edgesRenderer is active
  19226. */
  19227. isEnabled: boolean;
  19228. /**
  19229. * Renders the edges of the attached mesh,
  19230. */
  19231. render(): void;
  19232. /**
  19233. * Checks wether or not the edges renderer is ready to render.
  19234. * @return true if ready, otherwise false.
  19235. */
  19236. isReady(): boolean;
  19237. }
  19238. /**
  19239. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19240. */
  19241. export class EdgesRenderer implements IEdgesRenderer {
  19242. /**
  19243. * Define the size of the edges with an orthographic camera
  19244. */
  19245. edgesWidthScalerForOrthographic: number;
  19246. /**
  19247. * Define the size of the edges with a perspective camera
  19248. */
  19249. edgesWidthScalerForPerspective: number;
  19250. protected _source: AbstractMesh;
  19251. protected _linesPositions: number[];
  19252. protected _linesNormals: number[];
  19253. protected _linesIndices: number[];
  19254. protected _epsilon: number;
  19255. protected _indicesCount: number;
  19256. protected _lineShader: ShaderMaterial;
  19257. protected _ib: DataBuffer;
  19258. protected _buffers: {
  19259. [key: string]: Nullable<VertexBuffer>;
  19260. };
  19261. protected _checkVerticesInsteadOfIndices: boolean;
  19262. private _meshRebuildObserver;
  19263. private _meshDisposeObserver;
  19264. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19265. isEnabled: boolean;
  19266. /**
  19267. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19268. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19269. * @param source Mesh used to create edges
  19270. * @param epsilon sum of angles in adjacency to check for edge
  19271. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19272. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19273. */
  19274. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19275. protected _prepareRessources(): void;
  19276. /** @hidden */
  19277. _rebuild(): void;
  19278. /**
  19279. * Releases the required resources for the edges renderer
  19280. */
  19281. dispose(): void;
  19282. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19283. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19284. /**
  19285. * Checks if the pair of p0 and p1 is en edge
  19286. * @param faceIndex
  19287. * @param edge
  19288. * @param faceNormals
  19289. * @param p0
  19290. * @param p1
  19291. * @private
  19292. */
  19293. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19294. /**
  19295. * push line into the position, normal and index buffer
  19296. * @protected
  19297. */
  19298. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19299. /**
  19300. * Generates lines edges from adjacencjes
  19301. * @private
  19302. */
  19303. _generateEdgesLines(): void;
  19304. /**
  19305. * Checks wether or not the edges renderer is ready to render.
  19306. * @return true if ready, otherwise false.
  19307. */
  19308. isReady(): boolean;
  19309. /**
  19310. * Renders the edges of the attached mesh,
  19311. */
  19312. render(): void;
  19313. }
  19314. /**
  19315. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19316. */
  19317. export class LineEdgesRenderer extends EdgesRenderer {
  19318. /**
  19319. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19320. * @param source LineMesh used to generate edges
  19321. * @param epsilon not important (specified angle for edge detection)
  19322. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19323. */
  19324. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19325. /**
  19326. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19327. */
  19328. _generateEdgesLines(): void;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /**
  19333. * This represents the object necessary to create a rendering group.
  19334. * This is exclusively used and created by the rendering manager.
  19335. * To modify the behavior, you use the available helpers in your scene or meshes.
  19336. * @hidden
  19337. */
  19338. export class RenderingGroup {
  19339. index: number;
  19340. private static _zeroVector;
  19341. private _scene;
  19342. private _opaqueSubMeshes;
  19343. private _transparentSubMeshes;
  19344. private _alphaTestSubMeshes;
  19345. private _depthOnlySubMeshes;
  19346. private _particleSystems;
  19347. private _spriteManagers;
  19348. private _opaqueSortCompareFn;
  19349. private _alphaTestSortCompareFn;
  19350. private _transparentSortCompareFn;
  19351. private _renderOpaque;
  19352. private _renderAlphaTest;
  19353. private _renderTransparent;
  19354. /** @hidden */
  19355. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19356. onBeforeTransparentRendering: () => void;
  19357. /**
  19358. * Set the opaque sort comparison function.
  19359. * If null the sub meshes will be render in the order they were created
  19360. */
  19361. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19362. /**
  19363. * Set the alpha test sort comparison function.
  19364. * If null the sub meshes will be render in the order they were created
  19365. */
  19366. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19367. /**
  19368. * Set the transparent sort comparison function.
  19369. * If null the sub meshes will be render in the order they were created
  19370. */
  19371. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19372. /**
  19373. * Creates a new rendering group.
  19374. * @param index The rendering group index
  19375. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19376. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19377. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19378. */
  19379. 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>);
  19380. /**
  19381. * Render all the sub meshes contained in the group.
  19382. * @param customRenderFunction Used to override the default render behaviour of the group.
  19383. * @returns true if rendered some submeshes.
  19384. */
  19385. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19386. /**
  19387. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19388. * @param subMeshes The submeshes to render
  19389. */
  19390. private renderOpaqueSorted;
  19391. /**
  19392. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19393. * @param subMeshes The submeshes to render
  19394. */
  19395. private renderAlphaTestSorted;
  19396. /**
  19397. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19398. * @param subMeshes The submeshes to render
  19399. */
  19400. private renderTransparentSorted;
  19401. /**
  19402. * Renders the submeshes in a specified order.
  19403. * @param subMeshes The submeshes to sort before render
  19404. * @param sortCompareFn The comparison function use to sort
  19405. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19406. * @param transparent Specifies to activate blending if true
  19407. */
  19408. private static renderSorted;
  19409. /**
  19410. * Renders the submeshes in the order they were dispatched (no sort applied).
  19411. * @param subMeshes The submeshes to render
  19412. */
  19413. private static renderUnsorted;
  19414. /**
  19415. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19416. * are rendered back to front if in the same alpha index.
  19417. *
  19418. * @param a The first submesh
  19419. * @param b The second submesh
  19420. * @returns The result of the comparison
  19421. */
  19422. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19423. /**
  19424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19425. * are rendered back to front.
  19426. *
  19427. * @param a The first submesh
  19428. * @param b The second submesh
  19429. * @returns The result of the comparison
  19430. */
  19431. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19432. /**
  19433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19434. * are rendered front to back (prevent overdraw).
  19435. *
  19436. * @param a The first submesh
  19437. * @param b The second submesh
  19438. * @returns The result of the comparison
  19439. */
  19440. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19441. /**
  19442. * Resets the different lists of submeshes to prepare a new frame.
  19443. */
  19444. prepare(): void;
  19445. dispose(): void;
  19446. /**
  19447. * Inserts the submesh in its correct queue depending on its material.
  19448. * @param subMesh The submesh to dispatch
  19449. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19450. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19451. */
  19452. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19453. dispatchSprites(spriteManager: ISpriteManager): void;
  19454. dispatchParticles(particleSystem: IParticleSystem): void;
  19455. private _renderParticles;
  19456. private _renderSprites;
  19457. }
  19458. }
  19459. declare module BABYLON {
  19460. /**
  19461. * Interface describing the different options available in the rendering manager
  19462. * regarding Auto Clear between groups.
  19463. */
  19464. export interface IRenderingManagerAutoClearSetup {
  19465. /**
  19466. * Defines whether or not autoclear is enable.
  19467. */
  19468. autoClear: boolean;
  19469. /**
  19470. * Defines whether or not to autoclear the depth buffer.
  19471. */
  19472. depth: boolean;
  19473. /**
  19474. * Defines whether or not to autoclear the stencil buffer.
  19475. */
  19476. stencil: boolean;
  19477. }
  19478. /**
  19479. * This class is used by the onRenderingGroupObservable
  19480. */
  19481. export class RenderingGroupInfo {
  19482. /**
  19483. * The Scene that being rendered
  19484. */
  19485. scene: Scene;
  19486. /**
  19487. * The camera currently used for the rendering pass
  19488. */
  19489. camera: Nullable<Camera>;
  19490. /**
  19491. * The ID of the renderingGroup being processed
  19492. */
  19493. renderingGroupId: number;
  19494. }
  19495. /**
  19496. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19497. * It is enable to manage the different groups as well as the different necessary sort functions.
  19498. * This should not be used directly aside of the few static configurations
  19499. */
  19500. export class RenderingManager {
  19501. /**
  19502. * The max id used for rendering groups (not included)
  19503. */
  19504. static MAX_RENDERINGGROUPS: number;
  19505. /**
  19506. * The min id used for rendering groups (included)
  19507. */
  19508. static MIN_RENDERINGGROUPS: number;
  19509. /**
  19510. * Used to globally prevent autoclearing scenes.
  19511. */
  19512. static AUTOCLEAR: boolean;
  19513. /**
  19514. * @hidden
  19515. */
  19516. _useSceneAutoClearSetup: boolean;
  19517. private _scene;
  19518. private _renderingGroups;
  19519. private _depthStencilBufferAlreadyCleaned;
  19520. private _autoClearDepthStencil;
  19521. private _customOpaqueSortCompareFn;
  19522. private _customAlphaTestSortCompareFn;
  19523. private _customTransparentSortCompareFn;
  19524. private _renderingGroupInfo;
  19525. /**
  19526. * Instantiates a new rendering group for a particular scene
  19527. * @param scene Defines the scene the groups belongs to
  19528. */
  19529. constructor(scene: Scene);
  19530. private _clearDepthStencilBuffer;
  19531. /**
  19532. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19533. * @hidden
  19534. */
  19535. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19536. /**
  19537. * Resets the different information of the group to prepare a new frame
  19538. * @hidden
  19539. */
  19540. reset(): void;
  19541. /**
  19542. * Dispose and release the group and its associated resources.
  19543. * @hidden
  19544. */
  19545. dispose(): void;
  19546. /**
  19547. * Clear the info related to rendering groups preventing retention points during dispose.
  19548. */
  19549. freeRenderingGroups(): void;
  19550. private _prepareRenderingGroup;
  19551. /**
  19552. * Add a sprite manager to the rendering manager in order to render it this frame.
  19553. * @param spriteManager Define the sprite manager to render
  19554. */
  19555. dispatchSprites(spriteManager: ISpriteManager): void;
  19556. /**
  19557. * Add a particle system to the rendering manager in order to render it this frame.
  19558. * @param particleSystem Define the particle system to render
  19559. */
  19560. dispatchParticles(particleSystem: IParticleSystem): void;
  19561. /**
  19562. * Add a submesh to the manager in order to render it this frame
  19563. * @param subMesh The submesh to dispatch
  19564. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19565. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19566. */
  19567. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19568. /**
  19569. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19570. * This allowed control for front to back rendering or reversly depending of the special needs.
  19571. *
  19572. * @param renderingGroupId The rendering group id corresponding to its index
  19573. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19574. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19575. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19576. */
  19577. 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;
  19578. /**
  19579. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19580. *
  19581. * @param renderingGroupId The rendering group id corresponding to its index
  19582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19583. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19584. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19585. */
  19586. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19587. /**
  19588. * Gets the current auto clear configuration for one rendering group of the rendering
  19589. * manager.
  19590. * @param index the rendering group index to get the information for
  19591. * @returns The auto clear setup for the requested rendering group
  19592. */
  19593. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19594. }
  19595. }
  19596. declare module BABYLON {
  19597. /**
  19598. * This Helps creating a texture that will be created from a camera in your scene.
  19599. * It is basically a dynamic texture that could be used to create special effects for instance.
  19600. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19601. */
  19602. export class RenderTargetTexture extends Texture {
  19603. isCube: boolean;
  19604. /**
  19605. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19606. */
  19607. static readonly REFRESHRATE_RENDER_ONCE: number;
  19608. /**
  19609. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19610. */
  19611. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19612. /**
  19613. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19614. * the central point of your effect and can save a lot of performances.
  19615. */
  19616. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19617. /**
  19618. * Use this predicate to dynamically define the list of mesh you want to render.
  19619. * If set, the renderList property will be overwritten.
  19620. */
  19621. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19622. private _renderList;
  19623. /**
  19624. * Use this list to define the list of mesh you want to render.
  19625. */
  19626. renderList: Nullable<Array<AbstractMesh>>;
  19627. private _hookArray;
  19628. /**
  19629. * Define if particles should be rendered in your texture.
  19630. */
  19631. renderParticles: boolean;
  19632. /**
  19633. * Define if sprites should be rendered in your texture.
  19634. */
  19635. renderSprites: boolean;
  19636. /**
  19637. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19638. */
  19639. coordinatesMode: number;
  19640. /**
  19641. * Define the camera used to render the texture.
  19642. */
  19643. activeCamera: Nullable<Camera>;
  19644. /**
  19645. * Override the render function of the texture with your own one.
  19646. */
  19647. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19648. /**
  19649. * Define if camera post processes should be use while rendering the texture.
  19650. */
  19651. useCameraPostProcesses: boolean;
  19652. /**
  19653. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19654. */
  19655. ignoreCameraViewport: boolean;
  19656. private _postProcessManager;
  19657. private _postProcesses;
  19658. private _resizeObserver;
  19659. /**
  19660. * An event triggered when the texture is unbind.
  19661. */
  19662. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19663. /**
  19664. * An event triggered when the texture is unbind.
  19665. */
  19666. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19667. private _onAfterUnbindObserver;
  19668. /**
  19669. * Set a after unbind callback in the texture.
  19670. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19671. */
  19672. onAfterUnbind: () => void;
  19673. /**
  19674. * An event triggered before rendering the texture
  19675. */
  19676. onBeforeRenderObservable: Observable<number>;
  19677. private _onBeforeRenderObserver;
  19678. /**
  19679. * Set a before render callback in the texture.
  19680. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19681. */
  19682. onBeforeRender: (faceIndex: number) => void;
  19683. /**
  19684. * An event triggered after rendering the texture
  19685. */
  19686. onAfterRenderObservable: Observable<number>;
  19687. private _onAfterRenderObserver;
  19688. /**
  19689. * Set a after render callback in the texture.
  19690. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19691. */
  19692. onAfterRender: (faceIndex: number) => void;
  19693. /**
  19694. * An event triggered after the texture clear
  19695. */
  19696. onClearObservable: Observable<Engine>;
  19697. private _onClearObserver;
  19698. /**
  19699. * Set a clear callback in the texture.
  19700. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19701. */
  19702. onClear: (Engine: Engine) => void;
  19703. /**
  19704. * An event triggered when the texture is resized.
  19705. */
  19706. onResizeObservable: Observable<RenderTargetTexture>;
  19707. /**
  19708. * Define the clear color of the Render Target if it should be different from the scene.
  19709. */
  19710. clearColor: Color4;
  19711. protected _size: number | {
  19712. width: number;
  19713. height: number;
  19714. };
  19715. protected _initialSizeParameter: number | {
  19716. width: number;
  19717. height: number;
  19718. } | {
  19719. ratio: number;
  19720. };
  19721. protected _sizeRatio: Nullable<number>;
  19722. /** @hidden */
  19723. _generateMipMaps: boolean;
  19724. protected _renderingManager: RenderingManager;
  19725. /** @hidden */
  19726. _waitingRenderList: string[];
  19727. protected _doNotChangeAspectRatio: boolean;
  19728. protected _currentRefreshId: number;
  19729. protected _refreshRate: number;
  19730. protected _textureMatrix: Matrix;
  19731. protected _samples: number;
  19732. protected _renderTargetOptions: RenderTargetCreationOptions;
  19733. /**
  19734. * Gets render target creation options that were used.
  19735. */
  19736. readonly renderTargetOptions: RenderTargetCreationOptions;
  19737. protected _engine: Engine;
  19738. protected _onRatioRescale(): void;
  19739. /**
  19740. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19741. * It must define where the camera used to render the texture is set
  19742. */
  19743. boundingBoxPosition: Vector3;
  19744. private _boundingBoxSize;
  19745. /**
  19746. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19747. * When defined, the cubemap will switch to local mode
  19748. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19749. * @example https://www.babylonjs-playground.com/#RNASML
  19750. */
  19751. boundingBoxSize: Vector3;
  19752. /**
  19753. * In case the RTT has been created with a depth texture, get the associated
  19754. * depth texture.
  19755. * Otherwise, return null.
  19756. */
  19757. depthStencilTexture: Nullable<InternalTexture>;
  19758. /**
  19759. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19760. * or used a shadow, depth texture...
  19761. * @param name The friendly name of the texture
  19762. * @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)
  19763. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19764. * @param generateMipMaps True if mip maps need to be generated after render.
  19765. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19766. * @param type The type of the buffer in the RTT (int, half float, float...)
  19767. * @param isCube True if a cube texture needs to be created
  19768. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19769. * @param generateDepthBuffer True to generate a depth buffer
  19770. * @param generateStencilBuffer True to generate a stencil buffer
  19771. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19772. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19773. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19774. */
  19775. constructor(name: string, size: number | {
  19776. width: number;
  19777. height: number;
  19778. } | {
  19779. ratio: number;
  19780. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19781. /**
  19782. * Creates a depth stencil texture.
  19783. * This is only available in WebGL 2 or with the depth texture extension available.
  19784. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19785. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19786. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19787. */
  19788. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19789. private _processSizeParameter;
  19790. /**
  19791. * Define the number of samples to use in case of MSAA.
  19792. * It defaults to one meaning no MSAA has been enabled.
  19793. */
  19794. samples: number;
  19795. /**
  19796. * Resets the refresh counter of the texture and start bak from scratch.
  19797. * Could be useful to regenerate the texture if it is setup to render only once.
  19798. */
  19799. resetRefreshCounter(): void;
  19800. /**
  19801. * Define the refresh rate of the texture or the rendering frequency.
  19802. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19803. */
  19804. refreshRate: number;
  19805. /**
  19806. * Adds a post process to the render target rendering passes.
  19807. * @param postProcess define the post process to add
  19808. */
  19809. addPostProcess(postProcess: PostProcess): void;
  19810. /**
  19811. * Clear all the post processes attached to the render target
  19812. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19813. */
  19814. clearPostProcesses(dispose?: boolean): void;
  19815. /**
  19816. * Remove one of the post process from the list of attached post processes to the texture
  19817. * @param postProcess define the post process to remove from the list
  19818. */
  19819. removePostProcess(postProcess: PostProcess): void;
  19820. /** @hidden */
  19821. _shouldRender(): boolean;
  19822. /**
  19823. * Gets the actual render size of the texture.
  19824. * @returns the width of the render size
  19825. */
  19826. getRenderSize(): number;
  19827. /**
  19828. * Gets the actual render width of the texture.
  19829. * @returns the width of the render size
  19830. */
  19831. getRenderWidth(): number;
  19832. /**
  19833. * Gets the actual render height of the texture.
  19834. * @returns the height of the render size
  19835. */
  19836. getRenderHeight(): number;
  19837. /**
  19838. * Get if the texture can be rescaled or not.
  19839. */
  19840. readonly canRescale: boolean;
  19841. /**
  19842. * Resize the texture using a ratio.
  19843. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19844. */
  19845. scale(ratio: number): void;
  19846. /**
  19847. * Get the texture reflection matrix used to rotate/transform the reflection.
  19848. * @returns the reflection matrix
  19849. */
  19850. getReflectionTextureMatrix(): Matrix;
  19851. /**
  19852. * Resize the texture to a new desired size.
  19853. * Be carrefull as it will recreate all the data in the new texture.
  19854. * @param size Define the new size. It can be:
  19855. * - a number for squared texture,
  19856. * - an object containing { width: number, height: number }
  19857. * - or an object containing a ratio { ratio: number }
  19858. */
  19859. resize(size: number | {
  19860. width: number;
  19861. height: number;
  19862. } | {
  19863. ratio: number;
  19864. }): void;
  19865. /**
  19866. * Renders all the objects from the render list into the texture.
  19867. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19868. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19869. */
  19870. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19871. private _bestReflectionRenderTargetDimension;
  19872. /**
  19873. * @hidden
  19874. * @param faceIndex face index to bind to if this is a cubetexture
  19875. */
  19876. _bindFrameBuffer(faceIndex?: number): void;
  19877. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19878. private renderToTarget;
  19879. /**
  19880. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19881. * This allowed control for front to back rendering or reversly depending of the special needs.
  19882. *
  19883. * @param renderingGroupId The rendering group id corresponding to its index
  19884. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19885. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19886. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19887. */
  19888. 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;
  19889. /**
  19890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19891. *
  19892. * @param renderingGroupId The rendering group id corresponding to its index
  19893. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19894. */
  19895. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19896. /**
  19897. * Clones the texture.
  19898. * @returns the cloned texture
  19899. */
  19900. clone(): RenderTargetTexture;
  19901. /**
  19902. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19903. * @returns The JSON representation of the texture
  19904. */
  19905. serialize(): any;
  19906. /**
  19907. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19908. */
  19909. disposeFramebufferObjects(): void;
  19910. /**
  19911. * Dispose the texture and release its associated resources.
  19912. */
  19913. dispose(): void;
  19914. /** @hidden */
  19915. _rebuild(): void;
  19916. /**
  19917. * Clear the info related to rendering groups preventing retention point in material dispose.
  19918. */
  19919. freeRenderingGroups(): void;
  19920. /**
  19921. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19922. * @returns the view count
  19923. */
  19924. getViewCount(): number;
  19925. }
  19926. }
  19927. declare module BABYLON {
  19928. /**
  19929. * Base class for the main features of a material in Babylon.js
  19930. */
  19931. export class Material implements IAnimatable {
  19932. /**
  19933. * Returns the triangle fill mode
  19934. */
  19935. static readonly TriangleFillMode: number;
  19936. /**
  19937. * Returns the wireframe mode
  19938. */
  19939. static readonly WireFrameFillMode: number;
  19940. /**
  19941. * Returns the point fill mode
  19942. */
  19943. static readonly PointFillMode: number;
  19944. /**
  19945. * Returns the point list draw mode
  19946. */
  19947. static readonly PointListDrawMode: number;
  19948. /**
  19949. * Returns the line list draw mode
  19950. */
  19951. static readonly LineListDrawMode: number;
  19952. /**
  19953. * Returns the line loop draw mode
  19954. */
  19955. static readonly LineLoopDrawMode: number;
  19956. /**
  19957. * Returns the line strip draw mode
  19958. */
  19959. static readonly LineStripDrawMode: number;
  19960. /**
  19961. * Returns the triangle strip draw mode
  19962. */
  19963. static readonly TriangleStripDrawMode: number;
  19964. /**
  19965. * Returns the triangle fan draw mode
  19966. */
  19967. static readonly TriangleFanDrawMode: number;
  19968. /**
  19969. * Stores the clock-wise side orientation
  19970. */
  19971. static readonly ClockWiseSideOrientation: number;
  19972. /**
  19973. * Stores the counter clock-wise side orientation
  19974. */
  19975. static readonly CounterClockWiseSideOrientation: number;
  19976. /**
  19977. * The dirty texture flag value
  19978. */
  19979. static readonly TextureDirtyFlag: number;
  19980. /**
  19981. * The dirty light flag value
  19982. */
  19983. static readonly LightDirtyFlag: number;
  19984. /**
  19985. * The dirty fresnel flag value
  19986. */
  19987. static readonly FresnelDirtyFlag: number;
  19988. /**
  19989. * The dirty attribute flag value
  19990. */
  19991. static readonly AttributesDirtyFlag: number;
  19992. /**
  19993. * The dirty misc flag value
  19994. */
  19995. static readonly MiscDirtyFlag: number;
  19996. /**
  19997. * The all dirty flag value
  19998. */
  19999. static readonly AllDirtyFlag: number;
  20000. /**
  20001. * The ID of the material
  20002. */
  20003. id: string;
  20004. /**
  20005. * Gets or sets the unique id of the material
  20006. */
  20007. uniqueId: number;
  20008. /**
  20009. * The name of the material
  20010. */
  20011. name: string;
  20012. /**
  20013. * Gets or sets user defined metadata
  20014. */
  20015. metadata: any;
  20016. /**
  20017. * For internal use only. Please do not use.
  20018. */
  20019. reservedDataStore: any;
  20020. /**
  20021. * Specifies if the ready state should be checked on each call
  20022. */
  20023. checkReadyOnEveryCall: boolean;
  20024. /**
  20025. * Specifies if the ready state should be checked once
  20026. */
  20027. checkReadyOnlyOnce: boolean;
  20028. /**
  20029. * The state of the material
  20030. */
  20031. state: string;
  20032. /**
  20033. * The alpha value of the material
  20034. */
  20035. protected _alpha: number;
  20036. /**
  20037. * List of inspectable custom properties (used by the Inspector)
  20038. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20039. */
  20040. inspectableCustomProperties: IInspectable[];
  20041. /**
  20042. * Sets the alpha value of the material
  20043. */
  20044. /**
  20045. * Gets the alpha value of the material
  20046. */
  20047. alpha: number;
  20048. /**
  20049. * Specifies if back face culling is enabled
  20050. */
  20051. protected _backFaceCulling: boolean;
  20052. /**
  20053. * Sets the back-face culling state
  20054. */
  20055. /**
  20056. * Gets the back-face culling state
  20057. */
  20058. backFaceCulling: boolean;
  20059. /**
  20060. * Stores the value for side orientation
  20061. */
  20062. sideOrientation: number;
  20063. /**
  20064. * Callback triggered when the material is compiled
  20065. */
  20066. onCompiled: Nullable<(effect: Effect) => void>;
  20067. /**
  20068. * Callback triggered when an error occurs
  20069. */
  20070. onError: Nullable<(effect: Effect, errors: string) => void>;
  20071. /**
  20072. * Callback triggered to get the render target textures
  20073. */
  20074. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20075. /**
  20076. * Gets a boolean indicating that current material needs to register RTT
  20077. */
  20078. readonly hasRenderTargetTextures: boolean;
  20079. /**
  20080. * Specifies if the material should be serialized
  20081. */
  20082. doNotSerialize: boolean;
  20083. /**
  20084. * @hidden
  20085. */
  20086. _storeEffectOnSubMeshes: boolean;
  20087. /**
  20088. * Stores the animations for the material
  20089. */
  20090. animations: Nullable<Array<Animation>>;
  20091. /**
  20092. * An event triggered when the material is disposed
  20093. */
  20094. onDisposeObservable: Observable<Material>;
  20095. /**
  20096. * An observer which watches for dispose events
  20097. */
  20098. private _onDisposeObserver;
  20099. private _onUnBindObservable;
  20100. /**
  20101. * Called during a dispose event
  20102. */
  20103. onDispose: () => void;
  20104. private _onBindObservable;
  20105. /**
  20106. * An event triggered when the material is bound
  20107. */
  20108. readonly onBindObservable: Observable<AbstractMesh>;
  20109. /**
  20110. * An observer which watches for bind events
  20111. */
  20112. private _onBindObserver;
  20113. /**
  20114. * Called during a bind event
  20115. */
  20116. onBind: (Mesh: AbstractMesh) => void;
  20117. /**
  20118. * An event triggered when the material is unbound
  20119. */
  20120. readonly onUnBindObservable: Observable<Material>;
  20121. /**
  20122. * Stores the value of the alpha mode
  20123. */
  20124. private _alphaMode;
  20125. /**
  20126. * Sets the value of the alpha mode.
  20127. *
  20128. * | Value | Type | Description |
  20129. * | --- | --- | --- |
  20130. * | 0 | ALPHA_DISABLE | |
  20131. * | 1 | ALPHA_ADD | |
  20132. * | 2 | ALPHA_COMBINE | |
  20133. * | 3 | ALPHA_SUBTRACT | |
  20134. * | 4 | ALPHA_MULTIPLY | |
  20135. * | 5 | ALPHA_MAXIMIZED | |
  20136. * | 6 | ALPHA_ONEONE | |
  20137. * | 7 | ALPHA_PREMULTIPLIED | |
  20138. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20139. * | 9 | ALPHA_INTERPOLATE | |
  20140. * | 10 | ALPHA_SCREENMODE | |
  20141. *
  20142. */
  20143. /**
  20144. * Gets the value of the alpha mode
  20145. */
  20146. alphaMode: number;
  20147. /**
  20148. * Stores the state of the need depth pre-pass value
  20149. */
  20150. private _needDepthPrePass;
  20151. /**
  20152. * Sets the need depth pre-pass value
  20153. */
  20154. /**
  20155. * Gets the depth pre-pass value
  20156. */
  20157. needDepthPrePass: boolean;
  20158. /**
  20159. * Specifies if depth writing should be disabled
  20160. */
  20161. disableDepthWrite: boolean;
  20162. /**
  20163. * Specifies if depth writing should be forced
  20164. */
  20165. forceDepthWrite: boolean;
  20166. /**
  20167. * Specifies if there should be a separate pass for culling
  20168. */
  20169. separateCullingPass: boolean;
  20170. /**
  20171. * Stores the state specifing if fog should be enabled
  20172. */
  20173. private _fogEnabled;
  20174. /**
  20175. * Sets the state for enabling fog
  20176. */
  20177. /**
  20178. * Gets the value of the fog enabled state
  20179. */
  20180. fogEnabled: boolean;
  20181. /**
  20182. * Stores the size of points
  20183. */
  20184. pointSize: number;
  20185. /**
  20186. * Stores the z offset value
  20187. */
  20188. zOffset: number;
  20189. /**
  20190. * Gets a value specifying if wireframe mode is enabled
  20191. */
  20192. /**
  20193. * Sets the state of wireframe mode
  20194. */
  20195. wireframe: boolean;
  20196. /**
  20197. * Gets the value specifying if point clouds are enabled
  20198. */
  20199. /**
  20200. * Sets the state of point cloud mode
  20201. */
  20202. pointsCloud: boolean;
  20203. /**
  20204. * Gets the material fill mode
  20205. */
  20206. /**
  20207. * Sets the material fill mode
  20208. */
  20209. fillMode: number;
  20210. /**
  20211. * @hidden
  20212. * Stores the effects for the material
  20213. */
  20214. _effect: Nullable<Effect>;
  20215. /**
  20216. * @hidden
  20217. * Specifies if the material was previously ready
  20218. */
  20219. _wasPreviouslyReady: boolean;
  20220. /**
  20221. * Specifies if uniform buffers should be used
  20222. */
  20223. private _useUBO;
  20224. /**
  20225. * Stores a reference to the scene
  20226. */
  20227. private _scene;
  20228. /**
  20229. * Stores the fill mode state
  20230. */
  20231. private _fillMode;
  20232. /**
  20233. * Specifies if the depth write state should be cached
  20234. */
  20235. private _cachedDepthWriteState;
  20236. /**
  20237. * Stores the uniform buffer
  20238. */
  20239. protected _uniformBuffer: UniformBuffer;
  20240. /** @hidden */
  20241. _indexInSceneMaterialArray: number;
  20242. /** @hidden */
  20243. meshMap: Nullable<{
  20244. [id: string]: AbstractMesh | undefined;
  20245. }>;
  20246. /**
  20247. * Creates a material instance
  20248. * @param name defines the name of the material
  20249. * @param scene defines the scene to reference
  20250. * @param doNotAdd specifies if the material should be added to the scene
  20251. */
  20252. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20253. /**
  20254. * Returns a string representation of the current material
  20255. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20256. * @returns a string with material information
  20257. */
  20258. toString(fullDetails?: boolean): string;
  20259. /**
  20260. * Gets the class name of the material
  20261. * @returns a string with the class name of the material
  20262. */
  20263. getClassName(): string;
  20264. /**
  20265. * Specifies if updates for the material been locked
  20266. */
  20267. readonly isFrozen: boolean;
  20268. /**
  20269. * Locks updates for the material
  20270. */
  20271. freeze(): void;
  20272. /**
  20273. * Unlocks updates for the material
  20274. */
  20275. unfreeze(): void;
  20276. /**
  20277. * Specifies if the material is ready to be used
  20278. * @param mesh defines the mesh to check
  20279. * @param useInstances specifies if instances should be used
  20280. * @returns a boolean indicating if the material is ready to be used
  20281. */
  20282. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20283. /**
  20284. * Specifies that the submesh is ready to be used
  20285. * @param mesh defines the mesh to check
  20286. * @param subMesh defines which submesh to check
  20287. * @param useInstances specifies that instances should be used
  20288. * @returns a boolean indicating that the submesh is ready or not
  20289. */
  20290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20291. /**
  20292. * Returns the material effect
  20293. * @returns the effect associated with the material
  20294. */
  20295. getEffect(): Nullable<Effect>;
  20296. /**
  20297. * Returns the current scene
  20298. * @returns a Scene
  20299. */
  20300. getScene(): Scene;
  20301. /**
  20302. * Specifies if the material will require alpha blending
  20303. * @returns a boolean specifying if alpha blending is needed
  20304. */
  20305. needAlphaBlending(): boolean;
  20306. /**
  20307. * Specifies if the mesh will require alpha blending
  20308. * @param mesh defines the mesh to check
  20309. * @returns a boolean specifying if alpha blending is needed for the mesh
  20310. */
  20311. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20312. /**
  20313. * Specifies if this material should be rendered in alpha test mode
  20314. * @returns a boolean specifying if an alpha test is needed.
  20315. */
  20316. needAlphaTesting(): boolean;
  20317. /**
  20318. * Gets the texture used for the alpha test
  20319. * @returns the texture to use for alpha testing
  20320. */
  20321. getAlphaTestTexture(): Nullable<BaseTexture>;
  20322. /**
  20323. * Marks the material to indicate that it needs to be re-calculated
  20324. */
  20325. markDirty(): void;
  20326. /** @hidden */
  20327. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20328. /**
  20329. * Binds the material to the mesh
  20330. * @param world defines the world transformation matrix
  20331. * @param mesh defines the mesh to bind the material to
  20332. */
  20333. bind(world: Matrix, mesh?: Mesh): void;
  20334. /**
  20335. * Binds the submesh to the material
  20336. * @param world defines the world transformation matrix
  20337. * @param mesh defines the mesh containing the submesh
  20338. * @param subMesh defines the submesh to bind the material to
  20339. */
  20340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20341. /**
  20342. * Binds the world matrix to the material
  20343. * @param world defines the world transformation matrix
  20344. */
  20345. bindOnlyWorldMatrix(world: Matrix): void;
  20346. /**
  20347. * Binds the scene's uniform buffer to the effect.
  20348. * @param effect defines the effect to bind to the scene uniform buffer
  20349. * @param sceneUbo defines the uniform buffer storing scene data
  20350. */
  20351. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20352. /**
  20353. * Binds the view matrix to the effect
  20354. * @param effect defines the effect to bind the view matrix to
  20355. */
  20356. bindView(effect: Effect): void;
  20357. /**
  20358. * Binds the view projection matrix to the effect
  20359. * @param effect defines the effect to bind the view projection matrix to
  20360. */
  20361. bindViewProjection(effect: Effect): void;
  20362. /**
  20363. * Specifies if material alpha testing should be turned on for the mesh
  20364. * @param mesh defines the mesh to check
  20365. */
  20366. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20367. /**
  20368. * Processes to execute after binding the material to a mesh
  20369. * @param mesh defines the rendered mesh
  20370. */
  20371. protected _afterBind(mesh?: Mesh): void;
  20372. /**
  20373. * Unbinds the material from the mesh
  20374. */
  20375. unbind(): void;
  20376. /**
  20377. * Gets the active textures from the material
  20378. * @returns an array of textures
  20379. */
  20380. getActiveTextures(): BaseTexture[];
  20381. /**
  20382. * Specifies if the material uses a texture
  20383. * @param texture defines the texture to check against the material
  20384. * @returns a boolean specifying if the material uses the texture
  20385. */
  20386. hasTexture(texture: BaseTexture): boolean;
  20387. /**
  20388. * Makes a duplicate of the material, and gives it a new name
  20389. * @param name defines the new name for the duplicated material
  20390. * @returns the cloned material
  20391. */
  20392. clone(name: string): Nullable<Material>;
  20393. /**
  20394. * Gets the meshes bound to the material
  20395. * @returns an array of meshes bound to the material
  20396. */
  20397. getBindedMeshes(): AbstractMesh[];
  20398. /**
  20399. * Force shader compilation
  20400. * @param mesh defines the mesh associated with this material
  20401. * @param onCompiled defines a function to execute once the material is compiled
  20402. * @param options defines the options to configure the compilation
  20403. */
  20404. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20405. clipPlane: boolean;
  20406. }>): void;
  20407. /**
  20408. * Force shader compilation
  20409. * @param mesh defines the mesh that will use this material
  20410. * @param options defines additional options for compiling the shaders
  20411. * @returns a promise that resolves when the compilation completes
  20412. */
  20413. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20414. clipPlane: boolean;
  20415. }>): Promise<void>;
  20416. private static readonly _AllDirtyCallBack;
  20417. private static readonly _ImageProcessingDirtyCallBack;
  20418. private static readonly _TextureDirtyCallBack;
  20419. private static readonly _FresnelDirtyCallBack;
  20420. private static readonly _MiscDirtyCallBack;
  20421. private static readonly _LightsDirtyCallBack;
  20422. private static readonly _AttributeDirtyCallBack;
  20423. private static _FresnelAndMiscDirtyCallBack;
  20424. private static _TextureAndMiscDirtyCallBack;
  20425. private static readonly _DirtyCallbackArray;
  20426. private static readonly _RunDirtyCallBacks;
  20427. /**
  20428. * Marks a define in the material to indicate that it needs to be re-computed
  20429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20430. */
  20431. markAsDirty(flag: number): void;
  20432. /**
  20433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20434. * @param func defines a function which checks material defines against the submeshes
  20435. */
  20436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20437. /**
  20438. * Indicates that we need to re-calculated for all submeshes
  20439. */
  20440. protected _markAllSubMeshesAsAllDirty(): void;
  20441. /**
  20442. * Indicates that image processing needs to be re-calculated for all submeshes
  20443. */
  20444. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20445. /**
  20446. * Indicates that textures need to be re-calculated for all submeshes
  20447. */
  20448. protected _markAllSubMeshesAsTexturesDirty(): void;
  20449. /**
  20450. * Indicates that fresnel needs to be re-calculated for all submeshes
  20451. */
  20452. protected _markAllSubMeshesAsFresnelDirty(): void;
  20453. /**
  20454. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20455. */
  20456. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20457. /**
  20458. * Indicates that lights need to be re-calculated for all submeshes
  20459. */
  20460. protected _markAllSubMeshesAsLightsDirty(): void;
  20461. /**
  20462. * Indicates that attributes need to be re-calculated for all submeshes
  20463. */
  20464. protected _markAllSubMeshesAsAttributesDirty(): void;
  20465. /**
  20466. * Indicates that misc needs to be re-calculated for all submeshes
  20467. */
  20468. protected _markAllSubMeshesAsMiscDirty(): void;
  20469. /**
  20470. * Indicates that textures and misc need to be re-calculated for all submeshes
  20471. */
  20472. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20473. /**
  20474. * Disposes the material
  20475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20478. */
  20479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20480. /** @hidden */
  20481. private releaseVertexArrayObject;
  20482. /**
  20483. * Serializes this material
  20484. * @returns the serialized material object
  20485. */
  20486. serialize(): any;
  20487. /**
  20488. * Creates a material from parsed material data
  20489. * @param parsedMaterial defines parsed material data
  20490. * @param scene defines the hosting scene
  20491. * @param rootUrl defines the root URL to use to load textures
  20492. * @returns a new material
  20493. */
  20494. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20495. }
  20496. }
  20497. declare module BABYLON {
  20498. /**
  20499. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20500. * separate meshes. This can be use to improve performances.
  20501. * @see http://doc.babylonjs.com/how_to/multi_materials
  20502. */
  20503. export class MultiMaterial extends Material {
  20504. private _subMaterials;
  20505. /**
  20506. * Gets or Sets the list of Materials used within the multi material.
  20507. * They need to be ordered according to the submeshes order in the associated mesh
  20508. */
  20509. subMaterials: Nullable<Material>[];
  20510. /**
  20511. * Function used to align with Node.getChildren()
  20512. * @returns the list of Materials used within the multi material
  20513. */
  20514. getChildren(): Nullable<Material>[];
  20515. /**
  20516. * Instantiates a new Multi Material
  20517. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20518. * separate meshes. This can be use to improve performances.
  20519. * @see http://doc.babylonjs.com/how_to/multi_materials
  20520. * @param name Define the name in the scene
  20521. * @param scene Define the scene the material belongs to
  20522. */
  20523. constructor(name: string, scene: Scene);
  20524. private _hookArray;
  20525. /**
  20526. * Get one of the submaterial by its index in the submaterials array
  20527. * @param index The index to look the sub material at
  20528. * @returns The Material if the index has been defined
  20529. */
  20530. getSubMaterial(index: number): Nullable<Material>;
  20531. /**
  20532. * Get the list of active textures for the whole sub materials list.
  20533. * @returns All the textures that will be used during the rendering
  20534. */
  20535. getActiveTextures(): BaseTexture[];
  20536. /**
  20537. * Gets the current class name of the material e.g. "MultiMaterial"
  20538. * Mainly use in serialization.
  20539. * @returns the class name
  20540. */
  20541. getClassName(): string;
  20542. /**
  20543. * Checks if the material is ready to render the requested sub mesh
  20544. * @param mesh Define the mesh the submesh belongs to
  20545. * @param subMesh Define the sub mesh to look readyness for
  20546. * @param useInstances Define whether or not the material is used with instances
  20547. * @returns true if ready, otherwise false
  20548. */
  20549. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20550. /**
  20551. * Clones the current material and its related sub materials
  20552. * @param name Define the name of the newly cloned material
  20553. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20554. * @returns the cloned material
  20555. */
  20556. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20557. /**
  20558. * Serializes the materials into a JSON representation.
  20559. * @returns the JSON representation
  20560. */
  20561. serialize(): any;
  20562. /**
  20563. * Dispose the material and release its associated resources
  20564. * @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)
  20565. * @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)
  20566. * @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)
  20567. */
  20568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20569. /**
  20570. * Creates a MultiMaterial from parsed MultiMaterial data.
  20571. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20572. * @param scene defines the hosting scene
  20573. * @returns a new MultiMaterial
  20574. */
  20575. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20576. }
  20577. }
  20578. declare module BABYLON {
  20579. /**
  20580. * Base class for submeshes
  20581. */
  20582. export class BaseSubMesh {
  20583. /** @hidden */
  20584. _materialDefines: Nullable<MaterialDefines>;
  20585. /** @hidden */
  20586. _materialEffect: Nullable<Effect>;
  20587. /**
  20588. * Gets associated effect
  20589. */
  20590. readonly effect: Nullable<Effect>;
  20591. /**
  20592. * Sets associated effect (effect used to render this submesh)
  20593. * @param effect defines the effect to associate with
  20594. * @param defines defines the set of defines used to compile this effect
  20595. */
  20596. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20597. }
  20598. /**
  20599. * Defines a subdivision inside a mesh
  20600. */
  20601. export class SubMesh extends BaseSubMesh implements ICullable {
  20602. /** the material index to use */
  20603. materialIndex: number;
  20604. /** vertex index start */
  20605. verticesStart: number;
  20606. /** vertices count */
  20607. verticesCount: number;
  20608. /** index start */
  20609. indexStart: number;
  20610. /** indices count */
  20611. indexCount: number;
  20612. /** @hidden */
  20613. _linesIndexCount: number;
  20614. private _mesh;
  20615. private _renderingMesh;
  20616. private _boundingInfo;
  20617. private _linesIndexBuffer;
  20618. /** @hidden */
  20619. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20620. /** @hidden */
  20621. _trianglePlanes: Plane[];
  20622. /** @hidden */
  20623. _lastColliderTransformMatrix: Nullable<Matrix>;
  20624. /** @hidden */
  20625. _renderId: number;
  20626. /** @hidden */
  20627. _alphaIndex: number;
  20628. /** @hidden */
  20629. _distanceToCamera: number;
  20630. /** @hidden */
  20631. _id: number;
  20632. private _currentMaterial;
  20633. /**
  20634. * Add a new submesh to a mesh
  20635. * @param materialIndex defines the material index to use
  20636. * @param verticesStart defines vertex index start
  20637. * @param verticesCount defines vertices count
  20638. * @param indexStart defines index start
  20639. * @param indexCount defines indices count
  20640. * @param mesh defines the parent mesh
  20641. * @param renderingMesh defines an optional rendering mesh
  20642. * @param createBoundingBox defines if bounding box should be created for this submesh
  20643. * @returns the new submesh
  20644. */
  20645. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20646. /**
  20647. * Creates a new submesh
  20648. * @param materialIndex defines the material index to use
  20649. * @param verticesStart defines vertex index start
  20650. * @param verticesCount defines vertices count
  20651. * @param indexStart defines index start
  20652. * @param indexCount defines indices count
  20653. * @param mesh defines the parent mesh
  20654. * @param renderingMesh defines an optional rendering mesh
  20655. * @param createBoundingBox defines if bounding box should be created for this submesh
  20656. */
  20657. constructor(
  20658. /** the material index to use */
  20659. materialIndex: number,
  20660. /** vertex index start */
  20661. verticesStart: number,
  20662. /** vertices count */
  20663. verticesCount: number,
  20664. /** index start */
  20665. indexStart: number,
  20666. /** indices count */
  20667. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20668. /**
  20669. * Returns true if this submesh covers the entire parent mesh
  20670. * @ignorenaming
  20671. */
  20672. readonly IsGlobal: boolean;
  20673. /**
  20674. * Returns the submesh BoudingInfo object
  20675. * @returns current bounding info (or mesh's one if the submesh is global)
  20676. */
  20677. getBoundingInfo(): BoundingInfo;
  20678. /**
  20679. * Sets the submesh BoundingInfo
  20680. * @param boundingInfo defines the new bounding info to use
  20681. * @returns the SubMesh
  20682. */
  20683. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20684. /**
  20685. * Returns the mesh of the current submesh
  20686. * @return the parent mesh
  20687. */
  20688. getMesh(): AbstractMesh;
  20689. /**
  20690. * Returns the rendering mesh of the submesh
  20691. * @returns the rendering mesh (could be different from parent mesh)
  20692. */
  20693. getRenderingMesh(): Mesh;
  20694. /**
  20695. * Returns the submesh material
  20696. * @returns null or the current material
  20697. */
  20698. getMaterial(): Nullable<Material>;
  20699. /**
  20700. * Sets a new updated BoundingInfo object to the submesh
  20701. * @param data defines an optional position array to use to determine the bounding info
  20702. * @returns the SubMesh
  20703. */
  20704. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20705. /** @hidden */
  20706. _checkCollision(collider: Collider): boolean;
  20707. /**
  20708. * Updates the submesh BoundingInfo
  20709. * @param world defines the world matrix to use to update the bounding info
  20710. * @returns the submesh
  20711. */
  20712. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20713. /**
  20714. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20715. * @param frustumPlanes defines the frustum planes
  20716. * @returns true if the submesh is intersecting with the frustum
  20717. */
  20718. isInFrustum(frustumPlanes: Plane[]): boolean;
  20719. /**
  20720. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20721. * @param frustumPlanes defines the frustum planes
  20722. * @returns true if the submesh is inside the frustum
  20723. */
  20724. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20725. /**
  20726. * Renders the submesh
  20727. * @param enableAlphaMode defines if alpha needs to be used
  20728. * @returns the submesh
  20729. */
  20730. render(enableAlphaMode: boolean): SubMesh;
  20731. /**
  20732. * @hidden
  20733. */
  20734. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20735. /**
  20736. * Checks if the submesh intersects with a ray
  20737. * @param ray defines the ray to test
  20738. * @returns true is the passed ray intersects the submesh bounding box
  20739. */
  20740. canIntersects(ray: Ray): boolean;
  20741. /**
  20742. * Intersects current submesh with a ray
  20743. * @param ray defines the ray to test
  20744. * @param positions defines mesh's positions array
  20745. * @param indices defines mesh's indices array
  20746. * @param fastCheck defines if only bounding info should be used
  20747. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20748. * @returns intersection info or null if no intersection
  20749. */
  20750. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20751. /** @hidden */
  20752. private _intersectLines;
  20753. /** @hidden */
  20754. private _intersectUnIndexedLines;
  20755. /** @hidden */
  20756. private _intersectTriangles;
  20757. /** @hidden */
  20758. private _intersectUnIndexedTriangles;
  20759. /** @hidden */
  20760. _rebuild(): void;
  20761. /**
  20762. * Creates a new submesh from the passed mesh
  20763. * @param newMesh defines the new hosting mesh
  20764. * @param newRenderingMesh defines an optional rendering mesh
  20765. * @returns the new submesh
  20766. */
  20767. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20768. /**
  20769. * Release associated resources
  20770. */
  20771. dispose(): void;
  20772. /**
  20773. * Gets the class name
  20774. * @returns the string "SubMesh".
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Creates a new submesh from indices data
  20779. * @param materialIndex the index of the main mesh material
  20780. * @param startIndex the index where to start the copy in the mesh indices array
  20781. * @param indexCount the number of indices to copy then from the startIndex
  20782. * @param mesh the main mesh to create the submesh from
  20783. * @param renderingMesh the optional rendering mesh
  20784. * @returns a new submesh
  20785. */
  20786. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20787. }
  20788. }
  20789. declare module BABYLON {
  20790. /**
  20791. * Class used to represent data loading progression
  20792. */
  20793. export class SceneLoaderFlags {
  20794. private static _ForceFullSceneLoadingForIncremental;
  20795. private static _ShowLoadingScreen;
  20796. private static _CleanBoneMatrixWeights;
  20797. private static _loggingLevel;
  20798. /**
  20799. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20800. */
  20801. static ForceFullSceneLoadingForIncremental: boolean;
  20802. /**
  20803. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20804. */
  20805. static ShowLoadingScreen: boolean;
  20806. /**
  20807. * Defines the current logging level (while loading the scene)
  20808. * @ignorenaming
  20809. */
  20810. static loggingLevel: number;
  20811. /**
  20812. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20813. */
  20814. static CleanBoneMatrixWeights: boolean;
  20815. }
  20816. }
  20817. declare module BABYLON {
  20818. /**
  20819. * Class used to store geometry data (vertex buffers + index buffer)
  20820. */
  20821. export class Geometry implements IGetSetVerticesData {
  20822. /**
  20823. * Gets or sets the ID of the geometry
  20824. */
  20825. id: string;
  20826. /**
  20827. * Gets or sets the unique ID of the geometry
  20828. */
  20829. uniqueId: number;
  20830. /**
  20831. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20832. */
  20833. delayLoadState: number;
  20834. /**
  20835. * Gets the file containing the data to load when running in delay load state
  20836. */
  20837. delayLoadingFile: Nullable<string>;
  20838. /**
  20839. * Callback called when the geometry is updated
  20840. */
  20841. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20842. private _scene;
  20843. private _engine;
  20844. private _meshes;
  20845. private _totalVertices;
  20846. /** @hidden */
  20847. _indices: IndicesArray;
  20848. /** @hidden */
  20849. _vertexBuffers: {
  20850. [key: string]: VertexBuffer;
  20851. };
  20852. private _isDisposed;
  20853. private _extend;
  20854. private _boundingBias;
  20855. /** @hidden */
  20856. _delayInfo: Array<string>;
  20857. private _indexBuffer;
  20858. private _indexBufferIsUpdatable;
  20859. /** @hidden */
  20860. _boundingInfo: Nullable<BoundingInfo>;
  20861. /** @hidden */
  20862. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20863. /** @hidden */
  20864. _softwareSkinningFrameId: number;
  20865. private _vertexArrayObjects;
  20866. private _updatable;
  20867. /** @hidden */
  20868. _positions: Nullable<Vector3[]>;
  20869. /**
  20870. * 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
  20871. */
  20872. /**
  20873. * 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
  20874. */
  20875. boundingBias: Vector2;
  20876. /**
  20877. * Static function used to attach a new empty geometry to a mesh
  20878. * @param mesh defines the mesh to attach the geometry to
  20879. * @returns the new Geometry
  20880. */
  20881. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20882. /**
  20883. * Creates a new geometry
  20884. * @param id defines the unique ID
  20885. * @param scene defines the hosting scene
  20886. * @param vertexData defines the VertexData used to get geometry data
  20887. * @param updatable defines if geometry must be updatable (false by default)
  20888. * @param mesh defines the mesh that will be associated with the geometry
  20889. */
  20890. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20891. /**
  20892. * Gets the current extend of the geometry
  20893. */
  20894. readonly extend: {
  20895. minimum: Vector3;
  20896. maximum: Vector3;
  20897. };
  20898. /**
  20899. * Gets the hosting scene
  20900. * @returns the hosting Scene
  20901. */
  20902. getScene(): Scene;
  20903. /**
  20904. * Gets the hosting engine
  20905. * @returns the hosting Engine
  20906. */
  20907. getEngine(): Engine;
  20908. /**
  20909. * Defines if the geometry is ready to use
  20910. * @returns true if the geometry is ready to be used
  20911. */
  20912. isReady(): boolean;
  20913. /**
  20914. * Gets a value indicating that the geometry should not be serialized
  20915. */
  20916. readonly doNotSerialize: boolean;
  20917. /** @hidden */
  20918. _rebuild(): void;
  20919. /**
  20920. * Affects all geometry data in one call
  20921. * @param vertexData defines the geometry data
  20922. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20923. */
  20924. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20925. /**
  20926. * Set specific vertex data
  20927. * @param kind defines the data kind (Position, normal, etc...)
  20928. * @param data defines the vertex data to use
  20929. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20930. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20931. */
  20932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20933. /**
  20934. * Removes a specific vertex data
  20935. * @param kind defines the data kind (Position, normal, etc...)
  20936. */
  20937. removeVerticesData(kind: string): void;
  20938. /**
  20939. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20940. * @param buffer defines the vertex buffer to use
  20941. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20942. */
  20943. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20944. /**
  20945. * Update a specific vertex buffer
  20946. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20947. * It will do nothing if the buffer is not updatable
  20948. * @param kind defines the data kind (Position, normal, etc...)
  20949. * @param data defines the data to use
  20950. * @param offset defines the offset in the target buffer where to store the data
  20951. * @param useBytes set to true if the offset is in bytes
  20952. */
  20953. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20954. /**
  20955. * Update a specific vertex buffer
  20956. * This function will create a new buffer if the current one is not updatable
  20957. * @param kind defines the data kind (Position, normal, etc...)
  20958. * @param data defines the data to use
  20959. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20960. */
  20961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20962. private _updateBoundingInfo;
  20963. /** @hidden */
  20964. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20965. /**
  20966. * Gets total number of vertices
  20967. * @returns the total number of vertices
  20968. */
  20969. getTotalVertices(): number;
  20970. /**
  20971. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20972. * @param kind defines the data kind (Position, normal, etc...)
  20973. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20975. * @returns a float array containing vertex data
  20976. */
  20977. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20978. /**
  20979. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20980. * @param kind defines the data kind (Position, normal, etc...)
  20981. * @returns true if the vertex buffer with the specified kind is updatable
  20982. */
  20983. isVertexBufferUpdatable(kind: string): boolean;
  20984. /**
  20985. * Gets a specific vertex buffer
  20986. * @param kind defines the data kind (Position, normal, etc...)
  20987. * @returns a VertexBuffer
  20988. */
  20989. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20990. /**
  20991. * Returns all vertex buffers
  20992. * @return an object holding all vertex buffers indexed by kind
  20993. */
  20994. getVertexBuffers(): Nullable<{
  20995. [key: string]: VertexBuffer;
  20996. }>;
  20997. /**
  20998. * Gets a boolean indicating if specific vertex buffer is present
  20999. * @param kind defines the data kind (Position, normal, etc...)
  21000. * @returns true if data is present
  21001. */
  21002. isVerticesDataPresent(kind: string): boolean;
  21003. /**
  21004. * Gets a list of all attached data kinds (Position, normal, etc...)
  21005. * @returns a list of string containing all kinds
  21006. */
  21007. getVerticesDataKinds(): string[];
  21008. /**
  21009. * Update index buffer
  21010. * @param indices defines the indices to store in the index buffer
  21011. * @param offset defines the offset in the target buffer where to store the data
  21012. * @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)
  21013. */
  21014. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21015. /**
  21016. * Creates a new index buffer
  21017. * @param indices defines the indices to store in the index buffer
  21018. * @param totalVertices defines the total number of vertices (could be null)
  21019. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21020. */
  21021. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21022. /**
  21023. * Return the total number of indices
  21024. * @returns the total number of indices
  21025. */
  21026. getTotalIndices(): number;
  21027. /**
  21028. * Gets the index buffer array
  21029. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21030. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21031. * @returns the index buffer array
  21032. */
  21033. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21034. /**
  21035. * Gets the index buffer
  21036. * @return the index buffer
  21037. */
  21038. getIndexBuffer(): Nullable<DataBuffer>;
  21039. /** @hidden */
  21040. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21041. /**
  21042. * Release the associated resources for a specific mesh
  21043. * @param mesh defines the source mesh
  21044. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21045. */
  21046. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21047. /**
  21048. * Apply current geometry to a given mesh
  21049. * @param mesh defines the mesh to apply geometry to
  21050. */
  21051. applyToMesh(mesh: Mesh): void;
  21052. private _updateExtend;
  21053. private _applyToMesh;
  21054. private notifyUpdate;
  21055. /**
  21056. * Load the geometry if it was flagged as delay loaded
  21057. * @param scene defines the hosting scene
  21058. * @param onLoaded defines a callback called when the geometry is loaded
  21059. */
  21060. load(scene: Scene, onLoaded?: () => void): void;
  21061. private _queueLoad;
  21062. /**
  21063. * Invert the geometry to move from a right handed system to a left handed one.
  21064. */
  21065. toLeftHanded(): void;
  21066. /** @hidden */
  21067. _resetPointsArrayCache(): void;
  21068. /** @hidden */
  21069. _generatePointsArray(): boolean;
  21070. /**
  21071. * Gets a value indicating if the geometry is disposed
  21072. * @returns true if the geometry was disposed
  21073. */
  21074. isDisposed(): boolean;
  21075. private _disposeVertexArrayObjects;
  21076. /**
  21077. * Free all associated resources
  21078. */
  21079. dispose(): void;
  21080. /**
  21081. * Clone the current geometry into a new geometry
  21082. * @param id defines the unique ID of the new geometry
  21083. * @returns a new geometry object
  21084. */
  21085. copy(id: string): Geometry;
  21086. /**
  21087. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21088. * @return a JSON representation of the current geometry data (without the vertices data)
  21089. */
  21090. serialize(): any;
  21091. private toNumberArray;
  21092. /**
  21093. * Serialize all vertices data into a JSON oject
  21094. * @returns a JSON representation of the current geometry data
  21095. */
  21096. serializeVerticeData(): any;
  21097. /**
  21098. * Extracts a clone of a mesh geometry
  21099. * @param mesh defines the source mesh
  21100. * @param id defines the unique ID of the new geometry object
  21101. * @returns the new geometry object
  21102. */
  21103. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21104. /**
  21105. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21106. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21107. * Be aware Math.random() could cause collisions, but:
  21108. * "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"
  21109. * @returns a string containing a new GUID
  21110. */
  21111. static RandomId(): string;
  21112. /** @hidden */
  21113. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21114. private static _CleanMatricesWeights;
  21115. /**
  21116. * Create a new geometry from persisted data (Using .babylon file format)
  21117. * @param parsedVertexData defines the persisted data
  21118. * @param scene defines the hosting scene
  21119. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21120. * @returns the new geometry object
  21121. */
  21122. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21123. }
  21124. }
  21125. declare module BABYLON {
  21126. /**
  21127. * Define an interface for all classes that will get and set the data on vertices
  21128. */
  21129. export interface IGetSetVerticesData {
  21130. /**
  21131. * Gets a boolean indicating if specific vertex data is present
  21132. * @param kind defines the vertex data kind to use
  21133. * @returns true is data kind is present
  21134. */
  21135. isVerticesDataPresent(kind: string): boolean;
  21136. /**
  21137. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21138. * @param kind defines the data kind (Position, normal, etc...)
  21139. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21141. * @returns a float array containing vertex data
  21142. */
  21143. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21144. /**
  21145. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21146. * @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.
  21147. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21148. * @returns the indices array or an empty array if the mesh has no geometry
  21149. */
  21150. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21151. /**
  21152. * Set specific vertex data
  21153. * @param kind defines the data kind (Position, normal, etc...)
  21154. * @param data defines the vertex data to use
  21155. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21156. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21157. */
  21158. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21159. /**
  21160. * Update a specific associated vertex buffer
  21161. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21162. * - VertexBuffer.PositionKind
  21163. * - VertexBuffer.UVKind
  21164. * - VertexBuffer.UV2Kind
  21165. * - VertexBuffer.UV3Kind
  21166. * - VertexBuffer.UV4Kind
  21167. * - VertexBuffer.UV5Kind
  21168. * - VertexBuffer.UV6Kind
  21169. * - VertexBuffer.ColorKind
  21170. * - VertexBuffer.MatricesIndicesKind
  21171. * - VertexBuffer.MatricesIndicesExtraKind
  21172. * - VertexBuffer.MatricesWeightsKind
  21173. * - VertexBuffer.MatricesWeightsExtraKind
  21174. * @param data defines the data source
  21175. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21176. * @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)
  21177. */
  21178. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21179. /**
  21180. * Creates a new index buffer
  21181. * @param indices defines the indices to store in the index buffer
  21182. * @param totalVertices defines the total number of vertices (could be null)
  21183. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21184. */
  21185. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21186. }
  21187. /**
  21188. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21189. */
  21190. export class VertexData {
  21191. /**
  21192. * Mesh side orientation : usually the external or front surface
  21193. */
  21194. static readonly FRONTSIDE: number;
  21195. /**
  21196. * Mesh side orientation : usually the internal or back surface
  21197. */
  21198. static readonly BACKSIDE: number;
  21199. /**
  21200. * Mesh side orientation : both internal and external or front and back surfaces
  21201. */
  21202. static readonly DOUBLESIDE: number;
  21203. /**
  21204. * Mesh side orientation : by default, `FRONTSIDE`
  21205. */
  21206. static readonly DEFAULTSIDE: number;
  21207. /**
  21208. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21209. */
  21210. positions: Nullable<FloatArray>;
  21211. /**
  21212. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21213. */
  21214. normals: Nullable<FloatArray>;
  21215. /**
  21216. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21217. */
  21218. tangents: Nullable<FloatArray>;
  21219. /**
  21220. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21221. */
  21222. uvs: Nullable<FloatArray>;
  21223. /**
  21224. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21225. */
  21226. uvs2: Nullable<FloatArray>;
  21227. /**
  21228. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21229. */
  21230. uvs3: Nullable<FloatArray>;
  21231. /**
  21232. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21233. */
  21234. uvs4: Nullable<FloatArray>;
  21235. /**
  21236. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21237. */
  21238. uvs5: Nullable<FloatArray>;
  21239. /**
  21240. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21241. */
  21242. uvs6: Nullable<FloatArray>;
  21243. /**
  21244. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21245. */
  21246. colors: Nullable<FloatArray>;
  21247. /**
  21248. * 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).
  21249. */
  21250. matricesIndices: Nullable<FloatArray>;
  21251. /**
  21252. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21253. */
  21254. matricesWeights: Nullable<FloatArray>;
  21255. /**
  21256. * An array extending the number of possible indices
  21257. */
  21258. matricesIndicesExtra: Nullable<FloatArray>;
  21259. /**
  21260. * An array extending the number of possible weights when the number of indices is extended
  21261. */
  21262. matricesWeightsExtra: Nullable<FloatArray>;
  21263. /**
  21264. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21265. */
  21266. indices: Nullable<IndicesArray>;
  21267. /**
  21268. * Uses the passed data array to set the set the values for the specified kind of data
  21269. * @param data a linear array of floating numbers
  21270. * @param kind the type of data that is being set, eg positions, colors etc
  21271. */
  21272. set(data: FloatArray, kind: string): void;
  21273. /**
  21274. * Associates the vertexData to the passed Mesh.
  21275. * Sets it as updatable or not (default `false`)
  21276. * @param mesh the mesh the vertexData is applied to
  21277. * @param updatable when used and having the value true allows new data to update the vertexData
  21278. * @returns the VertexData
  21279. */
  21280. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21281. /**
  21282. * Associates the vertexData to the passed Geometry.
  21283. * Sets it as updatable or not (default `false`)
  21284. * @param geometry the geometry the vertexData is applied to
  21285. * @param updatable when used and having the value true allows new data to update the vertexData
  21286. * @returns VertexData
  21287. */
  21288. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21289. /**
  21290. * Updates the associated mesh
  21291. * @param mesh the mesh to be updated
  21292. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21293. * @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
  21294. * @returns VertexData
  21295. */
  21296. updateMesh(mesh: Mesh): VertexData;
  21297. /**
  21298. * Updates the associated geometry
  21299. * @param geometry the geometry to be updated
  21300. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21301. * @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
  21302. * @returns VertexData.
  21303. */
  21304. updateGeometry(geometry: Geometry): VertexData;
  21305. private _applyTo;
  21306. private _update;
  21307. /**
  21308. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21309. * @param matrix the transforming matrix
  21310. * @returns the VertexData
  21311. */
  21312. transform(matrix: Matrix): VertexData;
  21313. /**
  21314. * Merges the passed VertexData into the current one
  21315. * @param other the VertexData to be merged into the current one
  21316. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21317. * @returns the modified VertexData
  21318. */
  21319. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21320. private _mergeElement;
  21321. private _validate;
  21322. /**
  21323. * Serializes the VertexData
  21324. * @returns a serialized object
  21325. */
  21326. serialize(): any;
  21327. /**
  21328. * Extracts the vertexData from a mesh
  21329. * @param mesh the mesh from which to extract the VertexData
  21330. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21331. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21332. * @returns the object VertexData associated to the passed mesh
  21333. */
  21334. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21335. /**
  21336. * Extracts the vertexData from the geometry
  21337. * @param geometry the geometry from which to extract the VertexData
  21338. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21339. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21340. * @returns the object VertexData associated to the passed mesh
  21341. */
  21342. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21343. private static _ExtractFrom;
  21344. /**
  21345. * Creates the VertexData for a Ribbon
  21346. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21347. * * pathArray array of paths, each of which an array of successive Vector3
  21348. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21349. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21350. * * 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
  21351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21352. * * 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)
  21353. * * 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)
  21354. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21355. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21356. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21357. * @returns the VertexData of the ribbon
  21358. */
  21359. static CreateRibbon(options: {
  21360. pathArray: Vector3[][];
  21361. closeArray?: boolean;
  21362. closePath?: boolean;
  21363. offset?: number;
  21364. sideOrientation?: number;
  21365. frontUVs?: Vector4;
  21366. backUVs?: Vector4;
  21367. invertUV?: boolean;
  21368. uvs?: Vector2[];
  21369. colors?: Color4[];
  21370. }): VertexData;
  21371. /**
  21372. * Creates the VertexData for a box
  21373. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21374. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21375. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21376. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21377. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21378. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21379. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21381. * * 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)
  21382. * * 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)
  21383. * @returns the VertexData of the box
  21384. */
  21385. static CreateBox(options: {
  21386. size?: number;
  21387. width?: number;
  21388. height?: number;
  21389. depth?: number;
  21390. faceUV?: Vector4[];
  21391. faceColors?: Color4[];
  21392. sideOrientation?: number;
  21393. frontUVs?: Vector4;
  21394. backUVs?: Vector4;
  21395. }): VertexData;
  21396. /**
  21397. * Creates the VertexData for a tiled box
  21398. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21399. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21400. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21401. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21403. * @returns the VertexData of the box
  21404. */
  21405. static CreateTiledBox(options: {
  21406. pattern?: number;
  21407. width?: number;
  21408. height?: number;
  21409. depth?: number;
  21410. tileSize?: number;
  21411. tileWidth?: number;
  21412. tileHeight?: number;
  21413. alignHorizontal?: number;
  21414. alignVertical?: number;
  21415. faceUV?: Vector4[];
  21416. faceColors?: Color4[];
  21417. sideOrientation?: number;
  21418. }): VertexData;
  21419. /**
  21420. * Creates the VertexData for a tiled plane
  21421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21422. * * pattern a limited pattern arrangement depending on the number
  21423. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21424. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21425. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21427. * * 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)
  21428. * * 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)
  21429. * @returns the VertexData of the tiled plane
  21430. */
  21431. static CreateTiledPlane(options: {
  21432. pattern?: number;
  21433. tileSize?: number;
  21434. tileWidth?: number;
  21435. tileHeight?: number;
  21436. size?: number;
  21437. width?: number;
  21438. height?: number;
  21439. alignHorizontal?: number;
  21440. alignVertical?: number;
  21441. sideOrientation?: number;
  21442. frontUVs?: Vector4;
  21443. backUVs?: Vector4;
  21444. }): VertexData;
  21445. /**
  21446. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21447. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21448. * * segments sets the number of horizontal strips optional, default 32
  21449. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21450. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21451. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21452. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21453. * * 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
  21454. * * 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
  21455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21456. * * 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)
  21457. * * 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)
  21458. * @returns the VertexData of the ellipsoid
  21459. */
  21460. static CreateSphere(options: {
  21461. segments?: number;
  21462. diameter?: number;
  21463. diameterX?: number;
  21464. diameterY?: number;
  21465. diameterZ?: number;
  21466. arc?: number;
  21467. slice?: number;
  21468. sideOrientation?: number;
  21469. frontUVs?: Vector4;
  21470. backUVs?: Vector4;
  21471. }): VertexData;
  21472. /**
  21473. * Creates the VertexData for a cylinder, cone or prism
  21474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21475. * * height sets the height (y direction) of the cylinder, optional, default 2
  21476. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21477. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21478. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21479. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21480. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21481. * * 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
  21482. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21484. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21485. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21487. * * 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)
  21488. * * 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)
  21489. * @returns the VertexData of the cylinder, cone or prism
  21490. */
  21491. static CreateCylinder(options: {
  21492. height?: number;
  21493. diameterTop?: number;
  21494. diameterBottom?: number;
  21495. diameter?: number;
  21496. tessellation?: number;
  21497. subdivisions?: number;
  21498. arc?: number;
  21499. faceColors?: Color4[];
  21500. faceUV?: Vector4[];
  21501. hasRings?: boolean;
  21502. enclose?: boolean;
  21503. sideOrientation?: number;
  21504. frontUVs?: Vector4;
  21505. backUVs?: Vector4;
  21506. }): VertexData;
  21507. /**
  21508. * Creates the VertexData for a torus
  21509. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21510. * * diameter the diameter of the torus, optional default 1
  21511. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21512. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21514. * * 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)
  21515. * * 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)
  21516. * @returns the VertexData of the torus
  21517. */
  21518. static CreateTorus(options: {
  21519. diameter?: number;
  21520. thickness?: number;
  21521. tessellation?: number;
  21522. sideOrientation?: number;
  21523. frontUVs?: Vector4;
  21524. backUVs?: Vector4;
  21525. }): VertexData;
  21526. /**
  21527. * Creates the VertexData of the LineSystem
  21528. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21529. * - lines an array of lines, each line being an array of successive Vector3
  21530. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21531. * @returns the VertexData of the LineSystem
  21532. */
  21533. static CreateLineSystem(options: {
  21534. lines: Vector3[][];
  21535. colors?: Nullable<Color4[][]>;
  21536. }): VertexData;
  21537. /**
  21538. * Create the VertexData for a DashedLines
  21539. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21540. * - points an array successive Vector3
  21541. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21542. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21543. * - dashNb the intended total number of dashes, optional, default 200
  21544. * @returns the VertexData for the DashedLines
  21545. */
  21546. static CreateDashedLines(options: {
  21547. points: Vector3[];
  21548. dashSize?: number;
  21549. gapSize?: number;
  21550. dashNb?: number;
  21551. }): VertexData;
  21552. /**
  21553. * Creates the VertexData for a Ground
  21554. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21555. * - width the width (x direction) of the ground, optional, default 1
  21556. * - height the height (z direction) of the ground, optional, default 1
  21557. * - subdivisions the number of subdivisions per side, optional, default 1
  21558. * @returns the VertexData of the Ground
  21559. */
  21560. static CreateGround(options: {
  21561. width?: number;
  21562. height?: number;
  21563. subdivisions?: number;
  21564. subdivisionsX?: number;
  21565. subdivisionsY?: number;
  21566. }): VertexData;
  21567. /**
  21568. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21569. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21570. * * xmin the ground minimum X coordinate, optional, default -1
  21571. * * zmin the ground minimum Z coordinate, optional, default -1
  21572. * * xmax the ground maximum X coordinate, optional, default 1
  21573. * * zmax the ground maximum Z coordinate, optional, default 1
  21574. * * 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}
  21575. * * 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}
  21576. * @returns the VertexData of the TiledGround
  21577. */
  21578. static CreateTiledGround(options: {
  21579. xmin: number;
  21580. zmin: number;
  21581. xmax: number;
  21582. zmax: number;
  21583. subdivisions?: {
  21584. w: number;
  21585. h: number;
  21586. };
  21587. precision?: {
  21588. w: number;
  21589. h: number;
  21590. };
  21591. }): VertexData;
  21592. /**
  21593. * Creates the VertexData of the Ground designed from a heightmap
  21594. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21595. * * width the width (x direction) of the ground
  21596. * * height the height (z direction) of the ground
  21597. * * subdivisions the number of subdivisions per side
  21598. * * minHeight the minimum altitude on the ground, optional, default 0
  21599. * * maxHeight the maximum altitude on the ground, optional default 1
  21600. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21601. * * buffer the array holding the image color data
  21602. * * bufferWidth the width of image
  21603. * * bufferHeight the height of image
  21604. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21605. * @returns the VertexData of the Ground designed from a heightmap
  21606. */
  21607. static CreateGroundFromHeightMap(options: {
  21608. width: number;
  21609. height: number;
  21610. subdivisions: number;
  21611. minHeight: number;
  21612. maxHeight: number;
  21613. colorFilter: Color3;
  21614. buffer: Uint8Array;
  21615. bufferWidth: number;
  21616. bufferHeight: number;
  21617. alphaFilter: number;
  21618. }): VertexData;
  21619. /**
  21620. * Creates the VertexData for a Plane
  21621. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21622. * * size sets the width and height of the plane to the value of size, optional default 1
  21623. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21624. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21626. * * 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)
  21627. * * 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)
  21628. * @returns the VertexData of the box
  21629. */
  21630. static CreatePlane(options: {
  21631. size?: number;
  21632. width?: number;
  21633. height?: number;
  21634. sideOrientation?: number;
  21635. frontUVs?: Vector4;
  21636. backUVs?: Vector4;
  21637. }): VertexData;
  21638. /**
  21639. * Creates the VertexData of the Disc or regular Polygon
  21640. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21641. * * radius the radius of the disc, optional default 0.5
  21642. * * tessellation the number of polygon sides, optional, default 64
  21643. * * 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
  21644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21645. * * 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)
  21646. * * 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)
  21647. * @returns the VertexData of the box
  21648. */
  21649. static CreateDisc(options: {
  21650. radius?: number;
  21651. tessellation?: number;
  21652. arc?: number;
  21653. sideOrientation?: number;
  21654. frontUVs?: Vector4;
  21655. backUVs?: Vector4;
  21656. }): VertexData;
  21657. /**
  21658. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21659. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21660. * @param polygon a mesh built from polygonTriangulation.build()
  21661. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21662. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21663. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21664. * @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)
  21665. * @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)
  21666. * @returns the VertexData of the Polygon
  21667. */
  21668. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21669. /**
  21670. * Creates the VertexData of the IcoSphere
  21671. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21672. * * radius the radius of the IcoSphere, optional default 1
  21673. * * radiusX allows stretching in the x direction, optional, default radius
  21674. * * radiusY allows stretching in the y direction, optional, default radius
  21675. * * radiusZ allows stretching in the z direction, optional, default radius
  21676. * * flat when true creates a flat shaded mesh, optional, default true
  21677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21679. * * 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)
  21680. * * 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)
  21681. * @returns the VertexData of the IcoSphere
  21682. */
  21683. static CreateIcoSphere(options: {
  21684. radius?: number;
  21685. radiusX?: number;
  21686. radiusY?: number;
  21687. radiusZ?: number;
  21688. flat?: boolean;
  21689. subdivisions?: number;
  21690. sideOrientation?: number;
  21691. frontUVs?: Vector4;
  21692. backUVs?: Vector4;
  21693. }): VertexData;
  21694. /**
  21695. * Creates the VertexData for a Polyhedron
  21696. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21697. * * type provided types are:
  21698. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21699. * * 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)
  21700. * * size the size of the IcoSphere, optional default 1
  21701. * * sizeX allows stretching in the x direction, optional, default size
  21702. * * sizeY allows stretching in the y direction, optional, default size
  21703. * * sizeZ allows stretching in the z direction, optional, default size
  21704. * * 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
  21705. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21706. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21707. * * flat when true creates a flat shaded mesh, optional, default true
  21708. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21710. * * 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)
  21711. * * 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)
  21712. * @returns the VertexData of the Polyhedron
  21713. */
  21714. static CreatePolyhedron(options: {
  21715. type?: number;
  21716. size?: number;
  21717. sizeX?: number;
  21718. sizeY?: number;
  21719. sizeZ?: number;
  21720. custom?: any;
  21721. faceUV?: Vector4[];
  21722. faceColors?: Color4[];
  21723. flat?: boolean;
  21724. sideOrientation?: number;
  21725. frontUVs?: Vector4;
  21726. backUVs?: Vector4;
  21727. }): VertexData;
  21728. /**
  21729. * Creates the VertexData for a TorusKnot
  21730. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21731. * * radius the radius of the torus knot, optional, default 2
  21732. * * tube the thickness of the tube, optional, default 0.5
  21733. * * radialSegments the number of sides on each tube segments, optional, default 32
  21734. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21735. * * p the number of windings around the z axis, optional, default 2
  21736. * * q the number of windings around the x axis, optional, default 3
  21737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21738. * * 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)
  21739. * * 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)
  21740. * @returns the VertexData of the Torus Knot
  21741. */
  21742. static CreateTorusKnot(options: {
  21743. radius?: number;
  21744. tube?: number;
  21745. radialSegments?: number;
  21746. tubularSegments?: number;
  21747. p?: number;
  21748. q?: number;
  21749. sideOrientation?: number;
  21750. frontUVs?: Vector4;
  21751. backUVs?: Vector4;
  21752. }): VertexData;
  21753. /**
  21754. * Compute normals for given positions and indices
  21755. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21756. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21757. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21758. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21759. * * facetNormals : optional array of facet normals (vector3)
  21760. * * facetPositions : optional array of facet positions (vector3)
  21761. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21762. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21763. * * bInfo : optional bounding info, required for facetPartitioning computation
  21764. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21765. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21766. * * useRightHandedSystem: optional boolean to for right handed system computation
  21767. * * depthSort : optional boolean to enable the facet depth sort computation
  21768. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21769. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21770. */
  21771. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21772. facetNormals?: any;
  21773. facetPositions?: any;
  21774. facetPartitioning?: any;
  21775. ratio?: number;
  21776. bInfo?: any;
  21777. bbSize?: Vector3;
  21778. subDiv?: any;
  21779. useRightHandedSystem?: boolean;
  21780. depthSort?: boolean;
  21781. distanceTo?: Vector3;
  21782. depthSortedFacets?: any;
  21783. }): void;
  21784. /** @hidden */
  21785. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21786. /**
  21787. * Applies VertexData created from the imported parameters to the geometry
  21788. * @param parsedVertexData the parsed data from an imported file
  21789. * @param geometry the geometry to apply the VertexData to
  21790. */
  21791. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21792. }
  21793. }
  21794. declare module BABYLON {
  21795. /**
  21796. * Defines a target to use with MorphTargetManager
  21797. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21798. */
  21799. export class MorphTarget implements IAnimatable {
  21800. /** defines the name of the target */
  21801. name: string;
  21802. /**
  21803. * Gets or sets the list of animations
  21804. */
  21805. animations: Animation[];
  21806. private _scene;
  21807. private _positions;
  21808. private _normals;
  21809. private _tangents;
  21810. private _uvs;
  21811. private _influence;
  21812. /**
  21813. * Observable raised when the influence changes
  21814. */
  21815. onInfluenceChanged: Observable<boolean>;
  21816. /** @hidden */
  21817. _onDataLayoutChanged: Observable<void>;
  21818. /**
  21819. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21820. */
  21821. influence: number;
  21822. /**
  21823. * Gets or sets the id of the morph Target
  21824. */
  21825. id: string;
  21826. private _animationPropertiesOverride;
  21827. /**
  21828. * Gets or sets the animation properties override
  21829. */
  21830. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21831. /**
  21832. * Creates a new MorphTarget
  21833. * @param name defines the name of the target
  21834. * @param influence defines the influence to use
  21835. * @param scene defines the scene the morphtarget belongs to
  21836. */
  21837. constructor(
  21838. /** defines the name of the target */
  21839. name: string, influence?: number, scene?: Nullable<Scene>);
  21840. /**
  21841. * Gets a boolean defining if the target contains position data
  21842. */
  21843. readonly hasPositions: boolean;
  21844. /**
  21845. * Gets a boolean defining if the target contains normal data
  21846. */
  21847. readonly hasNormals: boolean;
  21848. /**
  21849. * Gets a boolean defining if the target contains tangent data
  21850. */
  21851. readonly hasTangents: boolean;
  21852. /**
  21853. * Gets a boolean defining if the target contains texture coordinates data
  21854. */
  21855. readonly hasUVs: boolean;
  21856. /**
  21857. * Affects position data to this target
  21858. * @param data defines the position data to use
  21859. */
  21860. setPositions(data: Nullable<FloatArray>): void;
  21861. /**
  21862. * Gets the position data stored in this target
  21863. * @returns a FloatArray containing the position data (or null if not present)
  21864. */
  21865. getPositions(): Nullable<FloatArray>;
  21866. /**
  21867. * Affects normal data to this target
  21868. * @param data defines the normal data to use
  21869. */
  21870. setNormals(data: Nullable<FloatArray>): void;
  21871. /**
  21872. * Gets the normal data stored in this target
  21873. * @returns a FloatArray containing the normal data (or null if not present)
  21874. */
  21875. getNormals(): Nullable<FloatArray>;
  21876. /**
  21877. * Affects tangent data to this target
  21878. * @param data defines the tangent data to use
  21879. */
  21880. setTangents(data: Nullable<FloatArray>): void;
  21881. /**
  21882. * Gets the tangent data stored in this target
  21883. * @returns a FloatArray containing the tangent data (or null if not present)
  21884. */
  21885. getTangents(): Nullable<FloatArray>;
  21886. /**
  21887. * Affects texture coordinates data to this target
  21888. * @param data defines the texture coordinates data to use
  21889. */
  21890. setUVs(data: Nullable<FloatArray>): void;
  21891. /**
  21892. * Gets the texture coordinates data stored in this target
  21893. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21894. */
  21895. getUVs(): Nullable<FloatArray>;
  21896. /**
  21897. * Serializes the current target into a Serialization object
  21898. * @returns the serialized object
  21899. */
  21900. serialize(): any;
  21901. /**
  21902. * Returns the string "MorphTarget"
  21903. * @returns "MorphTarget"
  21904. */
  21905. getClassName(): string;
  21906. /**
  21907. * Creates a new target from serialized data
  21908. * @param serializationObject defines the serialized data to use
  21909. * @returns a new MorphTarget
  21910. */
  21911. static Parse(serializationObject: any): MorphTarget;
  21912. /**
  21913. * Creates a MorphTarget from mesh data
  21914. * @param mesh defines the source mesh
  21915. * @param name defines the name to use for the new target
  21916. * @param influence defines the influence to attach to the target
  21917. * @returns a new MorphTarget
  21918. */
  21919. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21920. }
  21921. }
  21922. declare module BABYLON {
  21923. /**
  21924. * This class is used to deform meshes using morphing between different targets
  21925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21926. */
  21927. export class MorphTargetManager {
  21928. private _targets;
  21929. private _targetInfluenceChangedObservers;
  21930. private _targetDataLayoutChangedObservers;
  21931. private _activeTargets;
  21932. private _scene;
  21933. private _influences;
  21934. private _supportsNormals;
  21935. private _supportsTangents;
  21936. private _supportsUVs;
  21937. private _vertexCount;
  21938. private _uniqueId;
  21939. private _tempInfluences;
  21940. /**
  21941. * Gets or sets a boolean indicating if normals must be morphed
  21942. */
  21943. enableNormalMorphing: boolean;
  21944. /**
  21945. * Gets or sets a boolean indicating if tangents must be morphed
  21946. */
  21947. enableTangentMorphing: boolean;
  21948. /**
  21949. * Gets or sets a boolean indicating if UV must be morphed
  21950. */
  21951. enableUVMorphing: boolean;
  21952. /**
  21953. * Creates a new MorphTargetManager
  21954. * @param scene defines the current scene
  21955. */
  21956. constructor(scene?: Nullable<Scene>);
  21957. /**
  21958. * Gets the unique ID of this manager
  21959. */
  21960. readonly uniqueId: number;
  21961. /**
  21962. * Gets the number of vertices handled by this manager
  21963. */
  21964. readonly vertexCount: number;
  21965. /**
  21966. * Gets a boolean indicating if this manager supports morphing of normals
  21967. */
  21968. readonly supportsNormals: boolean;
  21969. /**
  21970. * Gets a boolean indicating if this manager supports morphing of tangents
  21971. */
  21972. readonly supportsTangents: boolean;
  21973. /**
  21974. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21975. */
  21976. readonly supportsUVs: boolean;
  21977. /**
  21978. * Gets the number of targets stored in this manager
  21979. */
  21980. readonly numTargets: number;
  21981. /**
  21982. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21983. */
  21984. readonly numInfluencers: number;
  21985. /**
  21986. * Gets the list of influences (one per target)
  21987. */
  21988. readonly influences: Float32Array;
  21989. /**
  21990. * Gets the active target at specified index. An active target is a target with an influence > 0
  21991. * @param index defines the index to check
  21992. * @returns the requested target
  21993. */
  21994. getActiveTarget(index: number): MorphTarget;
  21995. /**
  21996. * Gets the target at specified index
  21997. * @param index defines the index to check
  21998. * @returns the requested target
  21999. */
  22000. getTarget(index: number): MorphTarget;
  22001. /**
  22002. * Add a new target to this manager
  22003. * @param target defines the target to add
  22004. */
  22005. addTarget(target: MorphTarget): void;
  22006. /**
  22007. * Removes a target from the manager
  22008. * @param target defines the target to remove
  22009. */
  22010. removeTarget(target: MorphTarget): void;
  22011. /**
  22012. * Serializes the current manager into a Serialization object
  22013. * @returns the serialized object
  22014. */
  22015. serialize(): any;
  22016. private _syncActiveTargets;
  22017. /**
  22018. * Syncrhonize the targets with all the meshes using this morph target manager
  22019. */
  22020. synchronize(): void;
  22021. /**
  22022. * Creates a new MorphTargetManager from serialized data
  22023. * @param serializationObject defines the serialized data
  22024. * @param scene defines the hosting scene
  22025. * @returns the new MorphTargetManager
  22026. */
  22027. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22028. }
  22029. }
  22030. declare module BABYLON {
  22031. /**
  22032. * Class used to represent a specific level of detail of a mesh
  22033. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22034. */
  22035. export class MeshLODLevel {
  22036. /** Defines the distance where this level should star being displayed */
  22037. distance: number;
  22038. /** Defines the mesh to use to render this level */
  22039. mesh: Nullable<Mesh>;
  22040. /**
  22041. * Creates a new LOD level
  22042. * @param distance defines the distance where this level should star being displayed
  22043. * @param mesh defines the mesh to use to render this level
  22044. */
  22045. constructor(
  22046. /** Defines the distance where this level should star being displayed */
  22047. distance: number,
  22048. /** Defines the mesh to use to render this level */
  22049. mesh: Nullable<Mesh>);
  22050. }
  22051. }
  22052. declare module BABYLON {
  22053. /**
  22054. * Mesh representing the gorund
  22055. */
  22056. export class GroundMesh extends Mesh {
  22057. /** If octree should be generated */
  22058. generateOctree: boolean;
  22059. private _heightQuads;
  22060. /** @hidden */
  22061. _subdivisionsX: number;
  22062. /** @hidden */
  22063. _subdivisionsY: number;
  22064. /** @hidden */
  22065. _width: number;
  22066. /** @hidden */
  22067. _height: number;
  22068. /** @hidden */
  22069. _minX: number;
  22070. /** @hidden */
  22071. _maxX: number;
  22072. /** @hidden */
  22073. _minZ: number;
  22074. /** @hidden */
  22075. _maxZ: number;
  22076. constructor(name: string, scene: Scene);
  22077. /**
  22078. * "GroundMesh"
  22079. * @returns "GroundMesh"
  22080. */
  22081. getClassName(): string;
  22082. /**
  22083. * The minimum of x and y subdivisions
  22084. */
  22085. readonly subdivisions: number;
  22086. /**
  22087. * X subdivisions
  22088. */
  22089. readonly subdivisionsX: number;
  22090. /**
  22091. * Y subdivisions
  22092. */
  22093. readonly subdivisionsY: number;
  22094. /**
  22095. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22096. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22097. * @param chunksCount the number of subdivisions for x and y
  22098. * @param octreeBlocksSize (Default: 32)
  22099. */
  22100. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22101. /**
  22102. * Returns a height (y) value in the Worl system :
  22103. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22104. * @param x x coordinate
  22105. * @param z z coordinate
  22106. * @returns the ground y position if (x, z) are outside the ground surface.
  22107. */
  22108. getHeightAtCoordinates(x: number, z: number): number;
  22109. /**
  22110. * Returns a normalized vector (Vector3) orthogonal to the ground
  22111. * at the ground coordinates (x, z) expressed in the World system.
  22112. * @param x x coordinate
  22113. * @param z z coordinate
  22114. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22115. */
  22116. getNormalAtCoordinates(x: number, z: number): Vector3;
  22117. /**
  22118. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22119. * at the ground coordinates (x, z) expressed in the World system.
  22120. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22121. * @param x x coordinate
  22122. * @param z z coordinate
  22123. * @param ref vector to store the result
  22124. * @returns the GroundMesh.
  22125. */
  22126. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22127. /**
  22128. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22129. * if the ground has been updated.
  22130. * This can be used in the render loop.
  22131. * @returns the GroundMesh.
  22132. */
  22133. updateCoordinateHeights(): GroundMesh;
  22134. private _getFacetAt;
  22135. private _initHeightQuads;
  22136. private _computeHeightQuads;
  22137. /**
  22138. * Serializes this ground mesh
  22139. * @param serializationObject object to write serialization to
  22140. */
  22141. serialize(serializationObject: any): void;
  22142. /**
  22143. * Parses a serialized ground mesh
  22144. * @param parsedMesh the serialized mesh
  22145. * @param scene the scene to create the ground mesh in
  22146. * @returns the created ground mesh
  22147. */
  22148. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22149. }
  22150. }
  22151. declare module BABYLON {
  22152. /**
  22153. * Interface for Physics-Joint data
  22154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22155. */
  22156. export interface PhysicsJointData {
  22157. /**
  22158. * The main pivot of the joint
  22159. */
  22160. mainPivot?: Vector3;
  22161. /**
  22162. * The connected pivot of the joint
  22163. */
  22164. connectedPivot?: Vector3;
  22165. /**
  22166. * The main axis of the joint
  22167. */
  22168. mainAxis?: Vector3;
  22169. /**
  22170. * The connected axis of the joint
  22171. */
  22172. connectedAxis?: Vector3;
  22173. /**
  22174. * The collision of the joint
  22175. */
  22176. collision?: boolean;
  22177. /**
  22178. * Native Oimo/Cannon/Energy data
  22179. */
  22180. nativeParams?: any;
  22181. }
  22182. /**
  22183. * This is a holder class for the physics joint created by the physics plugin
  22184. * It holds a set of functions to control the underlying joint
  22185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22186. */
  22187. export class PhysicsJoint {
  22188. /**
  22189. * The type of the physics joint
  22190. */
  22191. type: number;
  22192. /**
  22193. * The data for the physics joint
  22194. */
  22195. jointData: PhysicsJointData;
  22196. private _physicsJoint;
  22197. protected _physicsPlugin: IPhysicsEnginePlugin;
  22198. /**
  22199. * Initializes the physics joint
  22200. * @param type The type of the physics joint
  22201. * @param jointData The data for the physics joint
  22202. */
  22203. constructor(
  22204. /**
  22205. * The type of the physics joint
  22206. */
  22207. type: number,
  22208. /**
  22209. * The data for the physics joint
  22210. */
  22211. jointData: PhysicsJointData);
  22212. /**
  22213. * Gets the physics joint
  22214. */
  22215. /**
  22216. * Sets the physics joint
  22217. */
  22218. physicsJoint: any;
  22219. /**
  22220. * Sets the physics plugin
  22221. */
  22222. physicsPlugin: IPhysicsEnginePlugin;
  22223. /**
  22224. * Execute a function that is physics-plugin specific.
  22225. * @param {Function} func the function that will be executed.
  22226. * It accepts two parameters: the physics world and the physics joint
  22227. */
  22228. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22229. /**
  22230. * Distance-Joint type
  22231. */
  22232. static DistanceJoint: number;
  22233. /**
  22234. * Hinge-Joint type
  22235. */
  22236. static HingeJoint: number;
  22237. /**
  22238. * Ball-and-Socket joint type
  22239. */
  22240. static BallAndSocketJoint: number;
  22241. /**
  22242. * Wheel-Joint type
  22243. */
  22244. static WheelJoint: number;
  22245. /**
  22246. * Slider-Joint type
  22247. */
  22248. static SliderJoint: number;
  22249. /**
  22250. * Prismatic-Joint type
  22251. */
  22252. static PrismaticJoint: number;
  22253. /**
  22254. * Universal-Joint type
  22255. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22256. */
  22257. static UniversalJoint: number;
  22258. /**
  22259. * Hinge-Joint 2 type
  22260. */
  22261. static Hinge2Joint: number;
  22262. /**
  22263. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22264. */
  22265. static PointToPointJoint: number;
  22266. /**
  22267. * Spring-Joint type
  22268. */
  22269. static SpringJoint: number;
  22270. /**
  22271. * Lock-Joint type
  22272. */
  22273. static LockJoint: number;
  22274. }
  22275. /**
  22276. * A class representing a physics distance joint
  22277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22278. */
  22279. export class DistanceJoint extends PhysicsJoint {
  22280. /**
  22281. *
  22282. * @param jointData The data for the Distance-Joint
  22283. */
  22284. constructor(jointData: DistanceJointData);
  22285. /**
  22286. * Update the predefined distance.
  22287. * @param maxDistance The maximum preferred distance
  22288. * @param minDistance The minimum preferred distance
  22289. */
  22290. updateDistance(maxDistance: number, minDistance?: number): void;
  22291. }
  22292. /**
  22293. * Represents a Motor-Enabled Joint
  22294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22295. */
  22296. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22297. /**
  22298. * Initializes the Motor-Enabled Joint
  22299. * @param type The type of the joint
  22300. * @param jointData The physica joint data for the joint
  22301. */
  22302. constructor(type: number, jointData: PhysicsJointData);
  22303. /**
  22304. * Set the motor values.
  22305. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22306. * @param force the force to apply
  22307. * @param maxForce max force for this motor.
  22308. */
  22309. setMotor(force?: number, maxForce?: number): void;
  22310. /**
  22311. * Set the motor's limits.
  22312. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22313. * @param upperLimit The upper limit of the motor
  22314. * @param lowerLimit The lower limit of the motor
  22315. */
  22316. setLimit(upperLimit: number, lowerLimit?: number): void;
  22317. }
  22318. /**
  22319. * This class represents a single physics Hinge-Joint
  22320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22321. */
  22322. export class HingeJoint extends MotorEnabledJoint {
  22323. /**
  22324. * Initializes the Hinge-Joint
  22325. * @param jointData The joint data for the Hinge-Joint
  22326. */
  22327. constructor(jointData: PhysicsJointData);
  22328. /**
  22329. * Set the motor values.
  22330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22331. * @param {number} force the force to apply
  22332. * @param {number} maxForce max force for this motor.
  22333. */
  22334. setMotor(force?: number, maxForce?: number): void;
  22335. /**
  22336. * Set the motor's limits.
  22337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22338. * @param upperLimit The upper limit of the motor
  22339. * @param lowerLimit The lower limit of the motor
  22340. */
  22341. setLimit(upperLimit: number, lowerLimit?: number): void;
  22342. }
  22343. /**
  22344. * This class represents a dual hinge physics joint (same as wheel joint)
  22345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22346. */
  22347. export class Hinge2Joint extends MotorEnabledJoint {
  22348. /**
  22349. * Initializes the Hinge2-Joint
  22350. * @param jointData The joint data for the Hinge2-Joint
  22351. */
  22352. constructor(jointData: PhysicsJointData);
  22353. /**
  22354. * Set the motor values.
  22355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22356. * @param {number} targetSpeed the speed the motor is to reach
  22357. * @param {number} maxForce max force for this motor.
  22358. * @param {motorIndex} the motor's index, 0 or 1.
  22359. */
  22360. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22361. /**
  22362. * Set the motor limits.
  22363. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22364. * @param {number} upperLimit the upper limit
  22365. * @param {number} lowerLimit lower limit
  22366. * @param {motorIndex} the motor's index, 0 or 1.
  22367. */
  22368. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22369. }
  22370. /**
  22371. * Interface for a motor enabled joint
  22372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22373. */
  22374. export interface IMotorEnabledJoint {
  22375. /**
  22376. * Physics joint
  22377. */
  22378. physicsJoint: any;
  22379. /**
  22380. * Sets the motor of the motor-enabled joint
  22381. * @param force The force of the motor
  22382. * @param maxForce The maximum force of the motor
  22383. * @param motorIndex The index of the motor
  22384. */
  22385. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22386. /**
  22387. * Sets the limit of the motor
  22388. * @param upperLimit The upper limit of the motor
  22389. * @param lowerLimit The lower limit of the motor
  22390. * @param motorIndex The index of the motor
  22391. */
  22392. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22393. }
  22394. /**
  22395. * Joint data for a Distance-Joint
  22396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22397. */
  22398. export interface DistanceJointData extends PhysicsJointData {
  22399. /**
  22400. * Max distance the 2 joint objects can be apart
  22401. */
  22402. maxDistance: number;
  22403. }
  22404. /**
  22405. * Joint data from a spring joint
  22406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22407. */
  22408. export interface SpringJointData extends PhysicsJointData {
  22409. /**
  22410. * Length of the spring
  22411. */
  22412. length: number;
  22413. /**
  22414. * Stiffness of the spring
  22415. */
  22416. stiffness: number;
  22417. /**
  22418. * Damping of the spring
  22419. */
  22420. damping: number;
  22421. /** this callback will be called when applying the force to the impostors. */
  22422. forceApplicationCallback: () => void;
  22423. }
  22424. }
  22425. declare module BABYLON {
  22426. /**
  22427. * Holds the data for the raycast result
  22428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22429. */
  22430. export class PhysicsRaycastResult {
  22431. private _hasHit;
  22432. private _hitDistance;
  22433. private _hitNormalWorld;
  22434. private _hitPointWorld;
  22435. private _rayFromWorld;
  22436. private _rayToWorld;
  22437. /**
  22438. * Gets if there was a hit
  22439. */
  22440. readonly hasHit: boolean;
  22441. /**
  22442. * Gets the distance from the hit
  22443. */
  22444. readonly hitDistance: number;
  22445. /**
  22446. * Gets the hit normal/direction in the world
  22447. */
  22448. readonly hitNormalWorld: Vector3;
  22449. /**
  22450. * Gets the hit point in the world
  22451. */
  22452. readonly hitPointWorld: Vector3;
  22453. /**
  22454. * Gets the ray "start point" of the ray in the world
  22455. */
  22456. readonly rayFromWorld: Vector3;
  22457. /**
  22458. * Gets the ray "end point" of the ray in the world
  22459. */
  22460. readonly rayToWorld: Vector3;
  22461. /**
  22462. * Sets the hit data (normal & point in world space)
  22463. * @param hitNormalWorld defines the normal in world space
  22464. * @param hitPointWorld defines the point in world space
  22465. */
  22466. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22467. /**
  22468. * Sets the distance from the start point to the hit point
  22469. * @param distance
  22470. */
  22471. setHitDistance(distance: number): void;
  22472. /**
  22473. * Calculates the distance manually
  22474. */
  22475. calculateHitDistance(): void;
  22476. /**
  22477. * Resets all the values to default
  22478. * @param from The from point on world space
  22479. * @param to The to point on world space
  22480. */
  22481. reset(from?: Vector3, to?: Vector3): void;
  22482. }
  22483. /**
  22484. * Interface for the size containing width and height
  22485. */
  22486. interface IXYZ {
  22487. /**
  22488. * X
  22489. */
  22490. x: number;
  22491. /**
  22492. * Y
  22493. */
  22494. y: number;
  22495. /**
  22496. * Z
  22497. */
  22498. z: number;
  22499. }
  22500. }
  22501. declare module BABYLON {
  22502. /**
  22503. * Interface used to describe a physics joint
  22504. */
  22505. export interface PhysicsImpostorJoint {
  22506. /** Defines the main impostor to which the joint is linked */
  22507. mainImpostor: PhysicsImpostor;
  22508. /** Defines the impostor that is connected to the main impostor using this joint */
  22509. connectedImpostor: PhysicsImpostor;
  22510. /** Defines the joint itself */
  22511. joint: PhysicsJoint;
  22512. }
  22513. /** @hidden */
  22514. export interface IPhysicsEnginePlugin {
  22515. world: any;
  22516. name: string;
  22517. setGravity(gravity: Vector3): void;
  22518. setTimeStep(timeStep: number): void;
  22519. getTimeStep(): number;
  22520. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22522. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22523. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22524. removePhysicsBody(impostor: PhysicsImpostor): void;
  22525. generateJoint(joint: PhysicsImpostorJoint): void;
  22526. removeJoint(joint: PhysicsImpostorJoint): void;
  22527. isSupported(): boolean;
  22528. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22531. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22532. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22533. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22534. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22535. getBodyMass(impostor: PhysicsImpostor): number;
  22536. getBodyFriction(impostor: PhysicsImpostor): number;
  22537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22538. getBodyRestitution(impostor: PhysicsImpostor): number;
  22539. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22540. getBodyPressure?(impostor: PhysicsImpostor): number;
  22541. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22542. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22543. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22544. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22545. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22546. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22547. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22548. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22549. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22550. sleepBody(impostor: PhysicsImpostor): void;
  22551. wakeUpBody(impostor: PhysicsImpostor): void;
  22552. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22554. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22556. getRadius(impostor: PhysicsImpostor): number;
  22557. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22559. dispose(): void;
  22560. }
  22561. /**
  22562. * Interface used to define a physics engine
  22563. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22564. */
  22565. export interface IPhysicsEngine {
  22566. /**
  22567. * Gets the gravity vector used by the simulation
  22568. */
  22569. gravity: Vector3;
  22570. /**
  22571. * Sets the gravity vector used by the simulation
  22572. * @param gravity defines the gravity vector to use
  22573. */
  22574. setGravity(gravity: Vector3): void;
  22575. /**
  22576. * Set the time step of the physics engine.
  22577. * Default is 1/60.
  22578. * To slow it down, enter 1/600 for example.
  22579. * To speed it up, 1/30
  22580. * @param newTimeStep the new timestep to apply to this world.
  22581. */
  22582. setTimeStep(newTimeStep: number): void;
  22583. /**
  22584. * Get the time step of the physics engine.
  22585. * @returns the current time step
  22586. */
  22587. getTimeStep(): number;
  22588. /**
  22589. * Release all resources
  22590. */
  22591. dispose(): void;
  22592. /**
  22593. * Gets the name of the current physics plugin
  22594. * @returns the name of the plugin
  22595. */
  22596. getPhysicsPluginName(): string;
  22597. /**
  22598. * Adding a new impostor for the impostor tracking.
  22599. * This will be done by the impostor itself.
  22600. * @param impostor the impostor to add
  22601. */
  22602. addImpostor(impostor: PhysicsImpostor): void;
  22603. /**
  22604. * Remove an impostor from the engine.
  22605. * This impostor and its mesh will not longer be updated by the physics engine.
  22606. * @param impostor the impostor to remove
  22607. */
  22608. removeImpostor(impostor: PhysicsImpostor): void;
  22609. /**
  22610. * Add a joint to the physics engine
  22611. * @param mainImpostor defines the main impostor to which the joint is added.
  22612. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22613. * @param joint defines the joint that will connect both impostors.
  22614. */
  22615. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22616. /**
  22617. * Removes a joint from the simulation
  22618. * @param mainImpostor defines the impostor used with the joint
  22619. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22620. * @param joint defines the joint to remove
  22621. */
  22622. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22623. /**
  22624. * Gets the current plugin used to run the simulation
  22625. * @returns current plugin
  22626. */
  22627. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22628. /**
  22629. * Gets the list of physic impostors
  22630. * @returns an array of PhysicsImpostor
  22631. */
  22632. getImpostors(): Array<PhysicsImpostor>;
  22633. /**
  22634. * Gets the impostor for a physics enabled object
  22635. * @param object defines the object impersonated by the impostor
  22636. * @returns the PhysicsImpostor or null if not found
  22637. */
  22638. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22639. /**
  22640. * Gets the impostor for a physics body object
  22641. * @param body defines physics body used by the impostor
  22642. * @returns the PhysicsImpostor or null if not found
  22643. */
  22644. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22645. /**
  22646. * Does a raycast in the physics world
  22647. * @param from when should the ray start?
  22648. * @param to when should the ray end?
  22649. * @returns PhysicsRaycastResult
  22650. */
  22651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22652. /**
  22653. * Called by the scene. No need to call it.
  22654. * @param delta defines the timespam between frames
  22655. */
  22656. _step(delta: number): void;
  22657. }
  22658. }
  22659. declare module BABYLON {
  22660. /**
  22661. * The interface for the physics imposter parameters
  22662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22663. */
  22664. export interface PhysicsImpostorParameters {
  22665. /**
  22666. * The mass of the physics imposter
  22667. */
  22668. mass: number;
  22669. /**
  22670. * The friction of the physics imposter
  22671. */
  22672. friction?: number;
  22673. /**
  22674. * The coefficient of restitution of the physics imposter
  22675. */
  22676. restitution?: number;
  22677. /**
  22678. * The native options of the physics imposter
  22679. */
  22680. nativeOptions?: any;
  22681. /**
  22682. * Specifies if the parent should be ignored
  22683. */
  22684. ignoreParent?: boolean;
  22685. /**
  22686. * Specifies if bi-directional transformations should be disabled
  22687. */
  22688. disableBidirectionalTransformation?: boolean;
  22689. /**
  22690. * The pressure inside the physics imposter, soft object only
  22691. */
  22692. pressure?: number;
  22693. /**
  22694. * The stiffness the physics imposter, soft object only
  22695. */
  22696. stiffness?: number;
  22697. /**
  22698. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22699. */
  22700. velocityIterations?: number;
  22701. /**
  22702. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22703. */
  22704. positionIterations?: number;
  22705. /**
  22706. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22707. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22708. * Add to fix multiple points
  22709. */
  22710. fixedPoints?: number;
  22711. /**
  22712. * The collision margin around a soft object
  22713. */
  22714. margin?: number;
  22715. /**
  22716. * The collision margin around a soft object
  22717. */
  22718. damping?: number;
  22719. /**
  22720. * The path for a rope based on an extrusion
  22721. */
  22722. path?: any;
  22723. /**
  22724. * The shape of an extrusion used for a rope based on an extrusion
  22725. */
  22726. shape?: any;
  22727. }
  22728. /**
  22729. * Interface for a physics-enabled object
  22730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22731. */
  22732. export interface IPhysicsEnabledObject {
  22733. /**
  22734. * The position of the physics-enabled object
  22735. */
  22736. position: Vector3;
  22737. /**
  22738. * The rotation of the physics-enabled object
  22739. */
  22740. rotationQuaternion: Nullable<Quaternion>;
  22741. /**
  22742. * The scale of the physics-enabled object
  22743. */
  22744. scaling: Vector3;
  22745. /**
  22746. * The rotation of the physics-enabled object
  22747. */
  22748. rotation?: Vector3;
  22749. /**
  22750. * The parent of the physics-enabled object
  22751. */
  22752. parent?: any;
  22753. /**
  22754. * The bounding info of the physics-enabled object
  22755. * @returns The bounding info of the physics-enabled object
  22756. */
  22757. getBoundingInfo(): BoundingInfo;
  22758. /**
  22759. * Computes the world matrix
  22760. * @param force Specifies if the world matrix should be computed by force
  22761. * @returns A world matrix
  22762. */
  22763. computeWorldMatrix(force: boolean): Matrix;
  22764. /**
  22765. * Gets the world matrix
  22766. * @returns A world matrix
  22767. */
  22768. getWorldMatrix?(): Matrix;
  22769. /**
  22770. * Gets the child meshes
  22771. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22772. * @returns An array of abstract meshes
  22773. */
  22774. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22775. /**
  22776. * Gets the vertex data
  22777. * @param kind The type of vertex data
  22778. * @returns A nullable array of numbers, or a float32 array
  22779. */
  22780. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22781. /**
  22782. * Gets the indices from the mesh
  22783. * @returns A nullable array of index arrays
  22784. */
  22785. getIndices?(): Nullable<IndicesArray>;
  22786. /**
  22787. * Gets the scene from the mesh
  22788. * @returns the indices array or null
  22789. */
  22790. getScene?(): Scene;
  22791. /**
  22792. * Gets the absolute position from the mesh
  22793. * @returns the absolute position
  22794. */
  22795. getAbsolutePosition(): Vector3;
  22796. /**
  22797. * Gets the absolute pivot point from the mesh
  22798. * @returns the absolute pivot point
  22799. */
  22800. getAbsolutePivotPoint(): Vector3;
  22801. /**
  22802. * Rotates the mesh
  22803. * @param axis The axis of rotation
  22804. * @param amount The amount of rotation
  22805. * @param space The space of the rotation
  22806. * @returns The rotation transform node
  22807. */
  22808. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22809. /**
  22810. * Translates the mesh
  22811. * @param axis The axis of translation
  22812. * @param distance The distance of translation
  22813. * @param space The space of the translation
  22814. * @returns The transform node
  22815. */
  22816. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22817. /**
  22818. * Sets the absolute position of the mesh
  22819. * @param absolutePosition The absolute position of the mesh
  22820. * @returns The transform node
  22821. */
  22822. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22823. /**
  22824. * Gets the class name of the mesh
  22825. * @returns The class name
  22826. */
  22827. getClassName(): string;
  22828. }
  22829. /**
  22830. * Represents a physics imposter
  22831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22832. */
  22833. export class PhysicsImpostor {
  22834. /**
  22835. * The physics-enabled object used as the physics imposter
  22836. */
  22837. object: IPhysicsEnabledObject;
  22838. /**
  22839. * The type of the physics imposter
  22840. */
  22841. type: number;
  22842. private _options;
  22843. private _scene?;
  22844. /**
  22845. * The default object size of the imposter
  22846. */
  22847. static DEFAULT_OBJECT_SIZE: Vector3;
  22848. /**
  22849. * The identity quaternion of the imposter
  22850. */
  22851. static IDENTITY_QUATERNION: Quaternion;
  22852. /** @hidden */
  22853. _pluginData: any;
  22854. private _physicsEngine;
  22855. private _physicsBody;
  22856. private _bodyUpdateRequired;
  22857. private _onBeforePhysicsStepCallbacks;
  22858. private _onAfterPhysicsStepCallbacks;
  22859. /** @hidden */
  22860. _onPhysicsCollideCallbacks: Array<{
  22861. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22862. otherImpostors: Array<PhysicsImpostor>;
  22863. }>;
  22864. private _deltaPosition;
  22865. private _deltaRotation;
  22866. private _deltaRotationConjugated;
  22867. /** @hidden */
  22868. _isFromLine: boolean;
  22869. private _parent;
  22870. private _isDisposed;
  22871. private static _tmpVecs;
  22872. private static _tmpQuat;
  22873. /**
  22874. * Specifies if the physics imposter is disposed
  22875. */
  22876. readonly isDisposed: boolean;
  22877. /**
  22878. * Gets the mass of the physics imposter
  22879. */
  22880. mass: number;
  22881. /**
  22882. * Gets the coefficient of friction
  22883. */
  22884. /**
  22885. * Sets the coefficient of friction
  22886. */
  22887. friction: number;
  22888. /**
  22889. * Gets the coefficient of restitution
  22890. */
  22891. /**
  22892. * Sets the coefficient of restitution
  22893. */
  22894. restitution: number;
  22895. /**
  22896. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22897. */
  22898. /**
  22899. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22900. */
  22901. pressure: number;
  22902. /**
  22903. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22904. */
  22905. /**
  22906. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22907. */
  22908. stiffness: number;
  22909. /**
  22910. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22911. */
  22912. /**
  22913. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22914. */
  22915. velocityIterations: number;
  22916. /**
  22917. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22918. */
  22919. /**
  22920. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22921. */
  22922. positionIterations: number;
  22923. /**
  22924. * The unique id of the physics imposter
  22925. * set by the physics engine when adding this impostor to the array
  22926. */
  22927. uniqueId: number;
  22928. /**
  22929. * @hidden
  22930. */
  22931. soft: boolean;
  22932. /**
  22933. * @hidden
  22934. */
  22935. segments: number;
  22936. private _joints;
  22937. /**
  22938. * Initializes the physics imposter
  22939. * @param object The physics-enabled object used as the physics imposter
  22940. * @param type The type of the physics imposter
  22941. * @param _options The options for the physics imposter
  22942. * @param _scene The Babylon scene
  22943. */
  22944. constructor(
  22945. /**
  22946. * The physics-enabled object used as the physics imposter
  22947. */
  22948. object: IPhysicsEnabledObject,
  22949. /**
  22950. * The type of the physics imposter
  22951. */
  22952. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22953. /**
  22954. * This function will completly initialize this impostor.
  22955. * It will create a new body - but only if this mesh has no parent.
  22956. * If it has, this impostor will not be used other than to define the impostor
  22957. * of the child mesh.
  22958. * @hidden
  22959. */
  22960. _init(): void;
  22961. private _getPhysicsParent;
  22962. /**
  22963. * Should a new body be generated.
  22964. * @returns boolean specifying if body initialization is required
  22965. */
  22966. isBodyInitRequired(): boolean;
  22967. /**
  22968. * Sets the updated scaling
  22969. * @param updated Specifies if the scaling is updated
  22970. */
  22971. setScalingUpdated(): void;
  22972. /**
  22973. * Force a regeneration of this or the parent's impostor's body.
  22974. * Use under cautious - This will remove all joints already implemented.
  22975. */
  22976. forceUpdate(): void;
  22977. /**
  22978. * Gets the body that holds this impostor. Either its own, or its parent.
  22979. */
  22980. /**
  22981. * Set the physics body. Used mainly by the physics engine/plugin
  22982. */
  22983. physicsBody: any;
  22984. /**
  22985. * Get the parent of the physics imposter
  22986. * @returns Physics imposter or null
  22987. */
  22988. /**
  22989. * Sets the parent of the physics imposter
  22990. */
  22991. parent: Nullable<PhysicsImpostor>;
  22992. /**
  22993. * Resets the update flags
  22994. */
  22995. resetUpdateFlags(): void;
  22996. /**
  22997. * Gets the object extend size
  22998. * @returns the object extend size
  22999. */
  23000. getObjectExtendSize(): Vector3;
  23001. /**
  23002. * Gets the object center
  23003. * @returns The object center
  23004. */
  23005. getObjectCenter(): Vector3;
  23006. /**
  23007. * Get a specific parametes from the options parameter
  23008. * @param paramName The object parameter name
  23009. * @returns The object parameter
  23010. */
  23011. getParam(paramName: string): any;
  23012. /**
  23013. * Sets a specific parameter in the options given to the physics plugin
  23014. * @param paramName The parameter name
  23015. * @param value The value of the parameter
  23016. */
  23017. setParam(paramName: string, value: number): void;
  23018. /**
  23019. * Specifically change the body's mass option. Won't recreate the physics body object
  23020. * @param mass The mass of the physics imposter
  23021. */
  23022. setMass(mass: number): void;
  23023. /**
  23024. * Gets the linear velocity
  23025. * @returns linear velocity or null
  23026. */
  23027. getLinearVelocity(): Nullable<Vector3>;
  23028. /**
  23029. * Sets the linear velocity
  23030. * @param velocity linear velocity or null
  23031. */
  23032. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23033. /**
  23034. * Gets the angular velocity
  23035. * @returns angular velocity or null
  23036. */
  23037. getAngularVelocity(): Nullable<Vector3>;
  23038. /**
  23039. * Sets the angular velocity
  23040. * @param velocity The velocity or null
  23041. */
  23042. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23043. /**
  23044. * Execute a function with the physics plugin native code
  23045. * Provide a function the will have two variables - the world object and the physics body object
  23046. * @param func The function to execute with the physics plugin native code
  23047. */
  23048. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23049. /**
  23050. * Register a function that will be executed before the physics world is stepping forward
  23051. * @param func The function to execute before the physics world is stepped forward
  23052. */
  23053. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23054. /**
  23055. * Unregister a function that will be executed before the physics world is stepping forward
  23056. * @param func The function to execute before the physics world is stepped forward
  23057. */
  23058. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23059. /**
  23060. * Register a function that will be executed after the physics step
  23061. * @param func The function to execute after physics step
  23062. */
  23063. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23064. /**
  23065. * Unregisters a function that will be executed after the physics step
  23066. * @param func The function to execute after physics step
  23067. */
  23068. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23069. /**
  23070. * register a function that will be executed when this impostor collides against a different body
  23071. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23072. * @param func Callback that is executed on collision
  23073. */
  23074. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23075. /**
  23076. * Unregisters the physics imposter on contact
  23077. * @param collideAgainst The physics object to collide against
  23078. * @param func Callback to execute on collision
  23079. */
  23080. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23081. private _tmpQuat;
  23082. private _tmpQuat2;
  23083. /**
  23084. * Get the parent rotation
  23085. * @returns The parent rotation
  23086. */
  23087. getParentsRotation(): Quaternion;
  23088. /**
  23089. * this function is executed by the physics engine.
  23090. */
  23091. beforeStep: () => void;
  23092. /**
  23093. * this function is executed by the physics engine
  23094. */
  23095. afterStep: () => void;
  23096. /**
  23097. * Legacy collision detection event support
  23098. */
  23099. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23100. /**
  23101. * event and body object due to cannon's event-based architecture.
  23102. */
  23103. onCollide: (e: {
  23104. body: any;
  23105. }) => void;
  23106. /**
  23107. * Apply a force
  23108. * @param force The force to apply
  23109. * @param contactPoint The contact point for the force
  23110. * @returns The physics imposter
  23111. */
  23112. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23113. /**
  23114. * Apply an impulse
  23115. * @param force The impulse force
  23116. * @param contactPoint The contact point for the impulse force
  23117. * @returns The physics imposter
  23118. */
  23119. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23120. /**
  23121. * A help function to create a joint
  23122. * @param otherImpostor A physics imposter used to create a joint
  23123. * @param jointType The type of joint
  23124. * @param jointData The data for the joint
  23125. * @returns The physics imposter
  23126. */
  23127. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23128. /**
  23129. * Add a joint to this impostor with a different impostor
  23130. * @param otherImpostor A physics imposter used to add a joint
  23131. * @param joint The joint to add
  23132. * @returns The physics imposter
  23133. */
  23134. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23135. /**
  23136. * Add an anchor to a cloth impostor
  23137. * @param otherImpostor rigid impostor to anchor to
  23138. * @param width ratio across width from 0 to 1
  23139. * @param height ratio up height from 0 to 1
  23140. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23141. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23142. * @returns impostor the soft imposter
  23143. */
  23144. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23145. /**
  23146. * Add a hook to a rope impostor
  23147. * @param otherImpostor rigid impostor to anchor to
  23148. * @param length ratio across rope from 0 to 1
  23149. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23150. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23151. * @returns impostor the rope imposter
  23152. */
  23153. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23154. /**
  23155. * Will keep this body still, in a sleep mode.
  23156. * @returns the physics imposter
  23157. */
  23158. sleep(): PhysicsImpostor;
  23159. /**
  23160. * Wake the body up.
  23161. * @returns The physics imposter
  23162. */
  23163. wakeUp(): PhysicsImpostor;
  23164. /**
  23165. * Clones the physics imposter
  23166. * @param newObject The physics imposter clones to this physics-enabled object
  23167. * @returns A nullable physics imposter
  23168. */
  23169. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23170. /**
  23171. * Disposes the physics imposter
  23172. */
  23173. dispose(): void;
  23174. /**
  23175. * Sets the delta position
  23176. * @param position The delta position amount
  23177. */
  23178. setDeltaPosition(position: Vector3): void;
  23179. /**
  23180. * Sets the delta rotation
  23181. * @param rotation The delta rotation amount
  23182. */
  23183. setDeltaRotation(rotation: Quaternion): void;
  23184. /**
  23185. * Gets the box size of the physics imposter and stores the result in the input parameter
  23186. * @param result Stores the box size
  23187. * @returns The physics imposter
  23188. */
  23189. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23190. /**
  23191. * Gets the radius of the physics imposter
  23192. * @returns Radius of the physics imposter
  23193. */
  23194. getRadius(): number;
  23195. /**
  23196. * Sync a bone with this impostor
  23197. * @param bone The bone to sync to the impostor.
  23198. * @param boneMesh The mesh that the bone is influencing.
  23199. * @param jointPivot The pivot of the joint / bone in local space.
  23200. * @param distToJoint Optional distance from the impostor to the joint.
  23201. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23202. */
  23203. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23204. /**
  23205. * Sync impostor to a bone
  23206. * @param bone The bone that the impostor will be synced to.
  23207. * @param boneMesh The mesh that the bone is influencing.
  23208. * @param jointPivot The pivot of the joint / bone in local space.
  23209. * @param distToJoint Optional distance from the impostor to the joint.
  23210. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23211. * @param boneAxis Optional vector3 axis the bone is aligned with
  23212. */
  23213. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23214. /**
  23215. * No-Imposter type
  23216. */
  23217. static NoImpostor: number;
  23218. /**
  23219. * Sphere-Imposter type
  23220. */
  23221. static SphereImpostor: number;
  23222. /**
  23223. * Box-Imposter type
  23224. */
  23225. static BoxImpostor: number;
  23226. /**
  23227. * Plane-Imposter type
  23228. */
  23229. static PlaneImpostor: number;
  23230. /**
  23231. * Mesh-imposter type
  23232. */
  23233. static MeshImpostor: number;
  23234. /**
  23235. * Capsule-Impostor type (Ammo.js plugin only)
  23236. */
  23237. static CapsuleImpostor: number;
  23238. /**
  23239. * Cylinder-Imposter type
  23240. */
  23241. static CylinderImpostor: number;
  23242. /**
  23243. * Particle-Imposter type
  23244. */
  23245. static ParticleImpostor: number;
  23246. /**
  23247. * Heightmap-Imposter type
  23248. */
  23249. static HeightmapImpostor: number;
  23250. /**
  23251. * ConvexHull-Impostor type (Ammo.js plugin only)
  23252. */
  23253. static ConvexHullImpostor: number;
  23254. /**
  23255. * Rope-Imposter type
  23256. */
  23257. static RopeImpostor: number;
  23258. /**
  23259. * Cloth-Imposter type
  23260. */
  23261. static ClothImpostor: number;
  23262. /**
  23263. * Softbody-Imposter type
  23264. */
  23265. static SoftbodyImpostor: number;
  23266. }
  23267. }
  23268. declare module BABYLON {
  23269. /**
  23270. * @hidden
  23271. **/
  23272. export class _CreationDataStorage {
  23273. closePath?: boolean;
  23274. closeArray?: boolean;
  23275. idx: number[];
  23276. dashSize: number;
  23277. gapSize: number;
  23278. path3D: Path3D;
  23279. pathArray: Vector3[][];
  23280. arc: number;
  23281. radius: number;
  23282. cap: number;
  23283. tessellation: number;
  23284. }
  23285. /**
  23286. * @hidden
  23287. **/
  23288. class _InstanceDataStorage {
  23289. visibleInstances: any;
  23290. batchCache: _InstancesBatch;
  23291. instancesBufferSize: number;
  23292. instancesBuffer: Nullable<Buffer>;
  23293. instancesData: Float32Array;
  23294. overridenInstanceCount: number;
  23295. isFrozen: boolean;
  23296. previousBatch: Nullable<_InstancesBatch>;
  23297. hardwareInstancedRendering: boolean;
  23298. sideOrientation: number;
  23299. }
  23300. /**
  23301. * @hidden
  23302. **/
  23303. export class _InstancesBatch {
  23304. mustReturn: boolean;
  23305. visibleInstances: Nullable<InstancedMesh[]>[];
  23306. renderSelf: boolean[];
  23307. hardwareInstancedRendering: boolean[];
  23308. }
  23309. /**
  23310. * Class used to represent renderable models
  23311. */
  23312. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23313. /**
  23314. * Mesh side orientation : usually the external or front surface
  23315. */
  23316. static readonly FRONTSIDE: number;
  23317. /**
  23318. * Mesh side orientation : usually the internal or back surface
  23319. */
  23320. static readonly BACKSIDE: number;
  23321. /**
  23322. * Mesh side orientation : both internal and external or front and back surfaces
  23323. */
  23324. static readonly DOUBLESIDE: number;
  23325. /**
  23326. * Mesh side orientation : by default, `FRONTSIDE`
  23327. */
  23328. static readonly DEFAULTSIDE: number;
  23329. /**
  23330. * Mesh cap setting : no cap
  23331. */
  23332. static readonly NO_CAP: number;
  23333. /**
  23334. * Mesh cap setting : one cap at the beginning of the mesh
  23335. */
  23336. static readonly CAP_START: number;
  23337. /**
  23338. * Mesh cap setting : one cap at the end of the mesh
  23339. */
  23340. static readonly CAP_END: number;
  23341. /**
  23342. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23343. */
  23344. static readonly CAP_ALL: number;
  23345. /**
  23346. * Mesh pattern setting : no flip or rotate
  23347. */
  23348. static readonly NO_FLIP: number;
  23349. /**
  23350. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23351. */
  23352. static readonly FLIP_TILE: number;
  23353. /**
  23354. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23355. */
  23356. static readonly ROTATE_TILE: number;
  23357. /**
  23358. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23359. */
  23360. static readonly FLIP_ROW: number;
  23361. /**
  23362. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23363. */
  23364. static readonly ROTATE_ROW: number;
  23365. /**
  23366. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23367. */
  23368. static readonly FLIP_N_ROTATE_TILE: number;
  23369. /**
  23370. * Mesh pattern setting : rotate pattern and rotate
  23371. */
  23372. static readonly FLIP_N_ROTATE_ROW: number;
  23373. /**
  23374. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23375. */
  23376. static readonly CENTER: number;
  23377. /**
  23378. * Mesh tile positioning : part tiles on left
  23379. */
  23380. static readonly LEFT: number;
  23381. /**
  23382. * Mesh tile positioning : part tiles on right
  23383. */
  23384. static readonly RIGHT: number;
  23385. /**
  23386. * Mesh tile positioning : part tiles on top
  23387. */
  23388. static readonly TOP: number;
  23389. /**
  23390. * Mesh tile positioning : part tiles on bottom
  23391. */
  23392. static readonly BOTTOM: number;
  23393. /**
  23394. * Gets the default side orientation.
  23395. * @param orientation the orientation to value to attempt to get
  23396. * @returns the default orientation
  23397. * @hidden
  23398. */
  23399. static _GetDefaultSideOrientation(orientation?: number): number;
  23400. private _internalMeshDataInfo;
  23401. /**
  23402. * An event triggered before rendering the mesh
  23403. */
  23404. readonly onBeforeRenderObservable: Observable<Mesh>;
  23405. /**
  23406. * An event triggered before binding the mesh
  23407. */
  23408. readonly onBeforeBindObservable: Observable<Mesh>;
  23409. /**
  23410. * An event triggered after rendering the mesh
  23411. */
  23412. readonly onAfterRenderObservable: Observable<Mesh>;
  23413. /**
  23414. * An event triggered before drawing the mesh
  23415. */
  23416. readonly onBeforeDrawObservable: Observable<Mesh>;
  23417. private _onBeforeDrawObserver;
  23418. /**
  23419. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23420. */
  23421. onBeforeDraw: () => void;
  23422. readonly hasInstances: boolean;
  23423. /**
  23424. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23425. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23426. */
  23427. delayLoadState: number;
  23428. /**
  23429. * Gets the list of instances created from this mesh
  23430. * it is not supposed to be modified manually.
  23431. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23432. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23433. */
  23434. instances: InstancedMesh[];
  23435. /**
  23436. * Gets the file containing delay loading data for this mesh
  23437. */
  23438. delayLoadingFile: string;
  23439. /** @hidden */
  23440. _binaryInfo: any;
  23441. /**
  23442. * User defined function used to change how LOD level selection is done
  23443. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23444. */
  23445. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23446. /**
  23447. * Gets or sets the morph target manager
  23448. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23449. */
  23450. morphTargetManager: Nullable<MorphTargetManager>;
  23451. /** @hidden */
  23452. _creationDataStorage: Nullable<_CreationDataStorage>;
  23453. /** @hidden */
  23454. _geometry: Nullable<Geometry>;
  23455. /** @hidden */
  23456. _delayInfo: Array<string>;
  23457. /** @hidden */
  23458. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23459. /** @hidden */
  23460. _instanceDataStorage: _InstanceDataStorage;
  23461. private _effectiveMaterial;
  23462. /** @hidden */
  23463. _shouldGenerateFlatShading: boolean;
  23464. /** @hidden */
  23465. _originalBuilderSideOrientation: number;
  23466. /**
  23467. * Use this property to change the original side orientation defined at construction time
  23468. */
  23469. overrideMaterialSideOrientation: Nullable<number>;
  23470. /**
  23471. * Gets the source mesh (the one used to clone this one from)
  23472. */
  23473. readonly source: Nullable<Mesh>;
  23474. /**
  23475. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23476. */
  23477. isUnIndexed: boolean;
  23478. /**
  23479. * @constructor
  23480. * @param name The value used by scene.getMeshByName() to do a lookup.
  23481. * @param scene The scene to add this mesh to.
  23482. * @param parent The parent of this mesh, if it has one
  23483. * @param source An optional Mesh from which geometry is shared, cloned.
  23484. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23485. * When false, achieved by calling a clone(), also passing False.
  23486. * This will make creation of children, recursive.
  23487. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23488. */
  23489. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23490. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23491. /**
  23492. * Gets the class name
  23493. * @returns the string "Mesh".
  23494. */
  23495. getClassName(): string;
  23496. /** @hidden */
  23497. readonly _isMesh: boolean;
  23498. /**
  23499. * Returns a description of this mesh
  23500. * @param fullDetails define if full details about this mesh must be used
  23501. * @returns a descriptive string representing this mesh
  23502. */
  23503. toString(fullDetails?: boolean): string;
  23504. /** @hidden */
  23505. _unBindEffect(): void;
  23506. /**
  23507. * Gets a boolean indicating if this mesh has LOD
  23508. */
  23509. readonly hasLODLevels: boolean;
  23510. /**
  23511. * Gets the list of MeshLODLevel associated with the current mesh
  23512. * @returns an array of MeshLODLevel
  23513. */
  23514. getLODLevels(): MeshLODLevel[];
  23515. private _sortLODLevels;
  23516. /**
  23517. * Add a mesh as LOD level triggered at the given distance.
  23518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23519. * @param distance The distance from the center of the object to show this level
  23520. * @param mesh The mesh to be added as LOD level (can be null)
  23521. * @return This mesh (for chaining)
  23522. */
  23523. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23524. /**
  23525. * Returns the LOD level mesh at the passed distance or null if not found.
  23526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23527. * @param distance The distance from the center of the object to show this level
  23528. * @returns a Mesh or `null`
  23529. */
  23530. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23531. /**
  23532. * Remove a mesh from the LOD array
  23533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23534. * @param mesh defines the mesh to be removed
  23535. * @return This mesh (for chaining)
  23536. */
  23537. removeLODLevel(mesh: Mesh): Mesh;
  23538. /**
  23539. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23541. * @param camera defines the camera to use to compute distance
  23542. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23543. * @return This mesh (for chaining)
  23544. */
  23545. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23546. /**
  23547. * Gets the mesh internal Geometry object
  23548. */
  23549. readonly geometry: Nullable<Geometry>;
  23550. /**
  23551. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23552. * @returns the total number of vertices
  23553. */
  23554. getTotalVertices(): number;
  23555. /**
  23556. * Returns the content of an associated vertex buffer
  23557. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23558. * - VertexBuffer.PositionKind
  23559. * - VertexBuffer.UVKind
  23560. * - VertexBuffer.UV2Kind
  23561. * - VertexBuffer.UV3Kind
  23562. * - VertexBuffer.UV4Kind
  23563. * - VertexBuffer.UV5Kind
  23564. * - VertexBuffer.UV6Kind
  23565. * - VertexBuffer.ColorKind
  23566. * - VertexBuffer.MatricesIndicesKind
  23567. * - VertexBuffer.MatricesIndicesExtraKind
  23568. * - VertexBuffer.MatricesWeightsKind
  23569. * - VertexBuffer.MatricesWeightsExtraKind
  23570. * @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
  23571. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23572. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23573. */
  23574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23575. /**
  23576. * Returns the mesh VertexBuffer object from the requested `kind`
  23577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23578. * - VertexBuffer.PositionKind
  23579. * - VertexBuffer.NormalKind
  23580. * - VertexBuffer.UVKind
  23581. * - VertexBuffer.UV2Kind
  23582. * - VertexBuffer.UV3Kind
  23583. * - VertexBuffer.UV4Kind
  23584. * - VertexBuffer.UV5Kind
  23585. * - VertexBuffer.UV6Kind
  23586. * - VertexBuffer.ColorKind
  23587. * - VertexBuffer.MatricesIndicesKind
  23588. * - VertexBuffer.MatricesIndicesExtraKind
  23589. * - VertexBuffer.MatricesWeightsKind
  23590. * - VertexBuffer.MatricesWeightsExtraKind
  23591. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23592. */
  23593. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23594. /**
  23595. * Tests if a specific vertex buffer is associated with this mesh
  23596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23597. * - VertexBuffer.PositionKind
  23598. * - VertexBuffer.NormalKind
  23599. * - VertexBuffer.UVKind
  23600. * - VertexBuffer.UV2Kind
  23601. * - VertexBuffer.UV3Kind
  23602. * - VertexBuffer.UV4Kind
  23603. * - VertexBuffer.UV5Kind
  23604. * - VertexBuffer.UV6Kind
  23605. * - VertexBuffer.ColorKind
  23606. * - VertexBuffer.MatricesIndicesKind
  23607. * - VertexBuffer.MatricesIndicesExtraKind
  23608. * - VertexBuffer.MatricesWeightsKind
  23609. * - VertexBuffer.MatricesWeightsExtraKind
  23610. * @returns a boolean
  23611. */
  23612. isVerticesDataPresent(kind: string): boolean;
  23613. /**
  23614. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23615. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23616. * - VertexBuffer.PositionKind
  23617. * - VertexBuffer.UVKind
  23618. * - VertexBuffer.UV2Kind
  23619. * - VertexBuffer.UV3Kind
  23620. * - VertexBuffer.UV4Kind
  23621. * - VertexBuffer.UV5Kind
  23622. * - VertexBuffer.UV6Kind
  23623. * - VertexBuffer.ColorKind
  23624. * - VertexBuffer.MatricesIndicesKind
  23625. * - VertexBuffer.MatricesIndicesExtraKind
  23626. * - VertexBuffer.MatricesWeightsKind
  23627. * - VertexBuffer.MatricesWeightsExtraKind
  23628. * @returns a boolean
  23629. */
  23630. isVertexBufferUpdatable(kind: string): boolean;
  23631. /**
  23632. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23634. * - VertexBuffer.PositionKind
  23635. * - VertexBuffer.NormalKind
  23636. * - VertexBuffer.UVKind
  23637. * - VertexBuffer.UV2Kind
  23638. * - VertexBuffer.UV3Kind
  23639. * - VertexBuffer.UV4Kind
  23640. * - VertexBuffer.UV5Kind
  23641. * - VertexBuffer.UV6Kind
  23642. * - VertexBuffer.ColorKind
  23643. * - VertexBuffer.MatricesIndicesKind
  23644. * - VertexBuffer.MatricesIndicesExtraKind
  23645. * - VertexBuffer.MatricesWeightsKind
  23646. * - VertexBuffer.MatricesWeightsExtraKind
  23647. * @returns an array of strings
  23648. */
  23649. getVerticesDataKinds(): string[];
  23650. /**
  23651. * Returns a positive integer : the total number of indices in this mesh geometry.
  23652. * @returns the numner of indices or zero if the mesh has no geometry.
  23653. */
  23654. getTotalIndices(): number;
  23655. /**
  23656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23657. * @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.
  23658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23659. * @returns the indices array or an empty array if the mesh has no geometry
  23660. */
  23661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23662. readonly isBlocked: boolean;
  23663. /**
  23664. * Determine if the current mesh is ready to be rendered
  23665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23667. * @returns true if all associated assets are ready (material, textures, shaders)
  23668. */
  23669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23670. /**
  23671. * 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.
  23672. */
  23673. readonly areNormalsFrozen: boolean;
  23674. /**
  23675. * 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.
  23676. * @returns the current mesh
  23677. */
  23678. freezeNormals(): Mesh;
  23679. /**
  23680. * 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
  23681. * @returns the current mesh
  23682. */
  23683. unfreezeNormals(): Mesh;
  23684. /**
  23685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23686. */
  23687. overridenInstanceCount: number;
  23688. /** @hidden */
  23689. _preActivate(): Mesh;
  23690. /** @hidden */
  23691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23692. /** @hidden */
  23693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23694. /**
  23695. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23696. * This means the mesh underlying bounding box and sphere are recomputed.
  23697. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23698. * @returns the current mesh
  23699. */
  23700. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23701. /** @hidden */
  23702. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23703. /**
  23704. * This function will subdivide the mesh into multiple submeshes
  23705. * @param count defines the expected number of submeshes
  23706. */
  23707. subdivide(count: number): void;
  23708. /**
  23709. * Copy a FloatArray into a specific associated vertex buffer
  23710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23711. * - VertexBuffer.PositionKind
  23712. * - VertexBuffer.UVKind
  23713. * - VertexBuffer.UV2Kind
  23714. * - VertexBuffer.UV3Kind
  23715. * - VertexBuffer.UV4Kind
  23716. * - VertexBuffer.UV5Kind
  23717. * - VertexBuffer.UV6Kind
  23718. * - VertexBuffer.ColorKind
  23719. * - VertexBuffer.MatricesIndicesKind
  23720. * - VertexBuffer.MatricesIndicesExtraKind
  23721. * - VertexBuffer.MatricesWeightsKind
  23722. * - VertexBuffer.MatricesWeightsExtraKind
  23723. * @param data defines the data source
  23724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23725. * @param stride defines the data stride size (can be null)
  23726. * @returns the current mesh
  23727. */
  23728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23729. /**
  23730. * Flags an associated vertex buffer as updatable
  23731. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23732. * - VertexBuffer.PositionKind
  23733. * - VertexBuffer.UVKind
  23734. * - VertexBuffer.UV2Kind
  23735. * - VertexBuffer.UV3Kind
  23736. * - VertexBuffer.UV4Kind
  23737. * - VertexBuffer.UV5Kind
  23738. * - VertexBuffer.UV6Kind
  23739. * - VertexBuffer.ColorKind
  23740. * - VertexBuffer.MatricesIndicesKind
  23741. * - VertexBuffer.MatricesIndicesExtraKind
  23742. * - VertexBuffer.MatricesWeightsKind
  23743. * - VertexBuffer.MatricesWeightsExtraKind
  23744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23745. */
  23746. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23747. /**
  23748. * Sets the mesh global Vertex Buffer
  23749. * @param buffer defines the buffer to use
  23750. * @returns the current mesh
  23751. */
  23752. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23753. /**
  23754. * Update a specific associated vertex buffer
  23755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23756. * - VertexBuffer.PositionKind
  23757. * - VertexBuffer.UVKind
  23758. * - VertexBuffer.UV2Kind
  23759. * - VertexBuffer.UV3Kind
  23760. * - VertexBuffer.UV4Kind
  23761. * - VertexBuffer.UV5Kind
  23762. * - VertexBuffer.UV6Kind
  23763. * - VertexBuffer.ColorKind
  23764. * - VertexBuffer.MatricesIndicesKind
  23765. * - VertexBuffer.MatricesIndicesExtraKind
  23766. * - VertexBuffer.MatricesWeightsKind
  23767. * - VertexBuffer.MatricesWeightsExtraKind
  23768. * @param data defines the data source
  23769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23770. * @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)
  23771. * @returns the current mesh
  23772. */
  23773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23774. /**
  23775. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23777. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23778. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23779. * @returns the current mesh
  23780. */
  23781. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23782. /**
  23783. * Creates a un-shared specific occurence of the geometry for the mesh.
  23784. * @returns the current mesh
  23785. */
  23786. makeGeometryUnique(): Mesh;
  23787. /**
  23788. * Set the index buffer of this mesh
  23789. * @param indices defines the source data
  23790. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23791. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23792. * @returns the current mesh
  23793. */
  23794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23795. /**
  23796. * Update the current index buffer
  23797. * @param indices defines the source data
  23798. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23799. * @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)
  23800. * @returns the current mesh
  23801. */
  23802. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23803. /**
  23804. * Invert the geometry to move from a right handed system to a left handed one.
  23805. * @returns the current mesh
  23806. */
  23807. toLeftHanded(): Mesh;
  23808. /** @hidden */
  23809. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23810. /** @hidden */
  23811. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23812. /**
  23813. * Registers for this mesh a javascript function called just before the rendering process
  23814. * @param func defines the function to call before rendering this mesh
  23815. * @returns the current mesh
  23816. */
  23817. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23818. /**
  23819. * Disposes a previously registered javascript function called before the rendering
  23820. * @param func defines the function to remove
  23821. * @returns the current mesh
  23822. */
  23823. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23824. /**
  23825. * Registers for this mesh a javascript function called just after the rendering is complete
  23826. * @param func defines the function to call after rendering this mesh
  23827. * @returns the current mesh
  23828. */
  23829. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23830. /**
  23831. * Disposes a previously registered javascript function called after the rendering.
  23832. * @param func defines the function to remove
  23833. * @returns the current mesh
  23834. */
  23835. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23836. /** @hidden */
  23837. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23838. /** @hidden */
  23839. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23840. /** @hidden */
  23841. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23842. /** @hidden */
  23843. _rebuild(): void;
  23844. /** @hidden */
  23845. _freeze(): void;
  23846. /** @hidden */
  23847. _unFreeze(): void;
  23848. /**
  23849. * 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
  23850. * @param subMesh defines the subMesh to render
  23851. * @param enableAlphaMode defines if alpha mode can be changed
  23852. * @returns the current mesh
  23853. */
  23854. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23855. private _onBeforeDraw;
  23856. /**
  23857. * Renormalize the mesh and patch it up if there are no weights
  23858. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23859. * However in the case of zero weights then we set just a single influence to 1.
  23860. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23861. */
  23862. cleanMatrixWeights(): void;
  23863. private normalizeSkinFourWeights;
  23864. private normalizeSkinWeightsAndExtra;
  23865. /**
  23866. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23867. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23868. * the user know there was an issue with importing the mesh
  23869. * @returns a validation object with skinned, valid and report string
  23870. */
  23871. validateSkinning(): {
  23872. skinned: boolean;
  23873. valid: boolean;
  23874. report: string;
  23875. };
  23876. /** @hidden */
  23877. _checkDelayState(): Mesh;
  23878. private _queueLoad;
  23879. /**
  23880. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23881. * A mesh is in the frustum if its bounding box intersects the frustum
  23882. * @param frustumPlanes defines the frustum to test
  23883. * @returns true if the mesh is in the frustum planes
  23884. */
  23885. isInFrustum(frustumPlanes: Plane[]): boolean;
  23886. /**
  23887. * Sets the mesh material by the material or multiMaterial `id` property
  23888. * @param id is a string identifying the material or the multiMaterial
  23889. * @returns the current mesh
  23890. */
  23891. setMaterialByID(id: string): Mesh;
  23892. /**
  23893. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23894. * @returns an array of IAnimatable
  23895. */
  23896. getAnimatables(): IAnimatable[];
  23897. /**
  23898. * Modifies the mesh geometry according to the passed transformation matrix.
  23899. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23900. * The mesh normals are modified using the same transformation.
  23901. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23902. * @param transform defines the transform matrix to use
  23903. * @see http://doc.babylonjs.com/resources/baking_transformations
  23904. * @returns the current mesh
  23905. */
  23906. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23907. /**
  23908. * Modifies the mesh geometry according to its own current World Matrix.
  23909. * The mesh World Matrix is then reset.
  23910. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23911. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23912. * @see http://doc.babylonjs.com/resources/baking_transformations
  23913. * @returns the current mesh
  23914. */
  23915. bakeCurrentTransformIntoVertices(): Mesh;
  23916. /** @hidden */
  23917. readonly _positions: Nullable<Vector3[]>;
  23918. /** @hidden */
  23919. _resetPointsArrayCache(): Mesh;
  23920. /** @hidden */
  23921. _generatePointsArray(): boolean;
  23922. /**
  23923. * Returns a new Mesh object generated from the current mesh properties.
  23924. * This method must not get confused with createInstance()
  23925. * @param name is a string, the name given to the new mesh
  23926. * @param newParent can be any Node object (default `null`)
  23927. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23928. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23929. * @returns a new mesh
  23930. */
  23931. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23932. /**
  23933. * Releases resources associated with this mesh.
  23934. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23935. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23936. */
  23937. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23938. /**
  23939. * Modifies the mesh geometry according to a displacement map.
  23940. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  23941. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23942. * @param url is a string, the URL from the image file is to be downloaded.
  23943. * @param minHeight is the lower limit of the displacement.
  23944. * @param maxHeight is the upper limit of the displacement.
  23945. * @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.
  23946. * @param uvOffset is an optional vector2 used to offset UV.
  23947. * @param uvScale is an optional vector2 used to scale UV.
  23948. * @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.
  23949. * @returns the Mesh.
  23950. */
  23951. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23952. /**
  23953. * Modifies the mesh geometry according to a displacementMap buffer.
  23954. * 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.
  23955. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23956. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23957. * @param heightMapWidth is the width of the buffer image.
  23958. * @param heightMapHeight is the height of the buffer image.
  23959. * @param minHeight is the lower limit of the displacement.
  23960. * @param maxHeight is the upper limit of the displacement.
  23961. * @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.
  23962. * @param uvOffset is an optional vector2 used to offset UV.
  23963. * @param uvScale is an optional vector2 used to scale UV.
  23964. * @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.
  23965. * @returns the Mesh.
  23966. */
  23967. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23968. /**
  23969. * Modify the mesh to get a flat shading rendering.
  23970. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23971. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23972. * @returns current mesh
  23973. */
  23974. convertToFlatShadedMesh(): Mesh;
  23975. /**
  23976. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23977. * In other words, more vertices, no more indices and a single bigger VBO.
  23978. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23979. * @returns current mesh
  23980. */
  23981. convertToUnIndexedMesh(): Mesh;
  23982. /**
  23983. * Inverses facet orientations.
  23984. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23985. * @param flipNormals will also inverts the normals
  23986. * @returns current mesh
  23987. */
  23988. flipFaces(flipNormals?: boolean): Mesh;
  23989. /**
  23990. * Increase the number of facets and hence vertices in a mesh
  23991. * Vertex normals are interpolated from existing vertex normals
  23992. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23993. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23994. */
  23995. increaseVertices(numberPerEdge: number): void;
  23996. /**
  23997. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23998. * This will undo any application of covertToFlatShadedMesh
  23999. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24000. */
  24001. forceSharedVertices(): void;
  24002. /** @hidden */
  24003. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24004. /** @hidden */
  24005. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24006. /**
  24007. * Creates a new InstancedMesh object from the mesh model.
  24008. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24009. * @param name defines the name of the new instance
  24010. * @returns a new InstancedMesh
  24011. */
  24012. createInstance(name: string): InstancedMesh;
  24013. /**
  24014. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24015. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24016. * @returns the current mesh
  24017. */
  24018. synchronizeInstances(): Mesh;
  24019. /**
  24020. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24021. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24022. * This should be used together with the simplification to avoid disappearing triangles.
  24023. * @param successCallback an optional success callback to be called after the optimization finished.
  24024. * @returns the current mesh
  24025. */
  24026. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24027. /**
  24028. * Serialize current mesh
  24029. * @param serializationObject defines the object which will receive the serialization data
  24030. */
  24031. serialize(serializationObject: any): void;
  24032. /** @hidden */
  24033. _syncGeometryWithMorphTargetManager(): void;
  24034. /** @hidden */
  24035. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24036. /**
  24037. * Returns a new Mesh object parsed from the source provided.
  24038. * @param parsedMesh is the source
  24039. * @param scene defines the hosting scene
  24040. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24041. * @returns a new Mesh
  24042. */
  24043. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24044. /**
  24045. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24046. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24047. * @param name defines the name of the mesh to create
  24048. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24049. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24050. * @param closePath creates a seam between the first and the last points of each path of the path array
  24051. * @param offset is taken in account only if the `pathArray` is containing a single path
  24052. * @param scene defines the hosting scene
  24053. * @param updatable defines if the mesh must be flagged as updatable
  24054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24055. * @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)
  24056. * @returns a new Mesh
  24057. */
  24058. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24059. /**
  24060. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24061. * @param name defines the name of the mesh to create
  24062. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24063. * @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
  24064. * @param scene defines the hosting scene
  24065. * @param updatable defines if the mesh must be flagged as updatable
  24066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24067. * @returns a new Mesh
  24068. */
  24069. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24070. /**
  24071. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24072. * @param name defines the name of the mesh to create
  24073. * @param size sets the size (float) of each box side (default 1)
  24074. * @param scene defines the hosting scene
  24075. * @param updatable defines if the mesh must be flagged as updatable
  24076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24077. * @returns a new Mesh
  24078. */
  24079. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24080. /**
  24081. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24082. * @param name defines the name of the mesh to create
  24083. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24084. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24085. * @param scene defines the hosting scene
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24088. * @returns a new Mesh
  24089. */
  24090. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24091. /**
  24092. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24093. * @param name defines the name of the mesh to create
  24094. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24095. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24096. * @param scene defines the hosting scene
  24097. * @returns a new Mesh
  24098. */
  24099. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24100. /**
  24101. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24102. * @param name defines the name of the mesh to create
  24103. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24104. * @param diameterTop set the top cap diameter (floats, default 1)
  24105. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24106. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24107. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24108. * @param scene defines the hosting scene
  24109. * @param updatable defines if the mesh must be flagged as updatable
  24110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24111. * @returns a new Mesh
  24112. */
  24113. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24114. /**
  24115. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24116. * @param name defines the name of the mesh to create
  24117. * @param diameter sets the diameter size (float) of the torus (default 1)
  24118. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24119. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24120. * @param scene defines the hosting scene
  24121. * @param updatable defines if the mesh must be flagged as updatable
  24122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24123. * @returns a new Mesh
  24124. */
  24125. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24126. /**
  24127. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24128. * @param name defines the name of the mesh to create
  24129. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24130. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24131. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24132. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24133. * @param p the number of windings on X axis (positive integers, default 2)
  24134. * @param q the number of windings on Y axis (positive integers, default 3)
  24135. * @param scene defines the hosting scene
  24136. * @param updatable defines if the mesh must be flagged as updatable
  24137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24138. * @returns a new Mesh
  24139. */
  24140. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24141. /**
  24142. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24143. * @param name defines the name of the mesh to create
  24144. * @param points is an array successive Vector3
  24145. * @param scene defines the hosting scene
  24146. * @param updatable defines if the mesh must be flagged as updatable
  24147. * @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).
  24148. * @returns a new Mesh
  24149. */
  24150. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24151. /**
  24152. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24153. * @param name defines the name of the mesh to create
  24154. * @param points is an array successive Vector3
  24155. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24156. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24157. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24158. * @param scene defines the hosting scene
  24159. * @param updatable defines if the mesh must be flagged as updatable
  24160. * @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)
  24161. * @returns a new Mesh
  24162. */
  24163. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24164. /**
  24165. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24166. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24167. * 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.
  24168. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24169. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24170. * Remember you can only change the shape positions, not their number when updating a polygon.
  24171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24172. * @param name defines the name of the mesh to create
  24173. * @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
  24174. * @param scene defines the hosting scene
  24175. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24176. * @param updatable defines if the mesh must be flagged as updatable
  24177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24178. * @param earcutInjection can be used to inject your own earcut reference
  24179. * @returns a new Mesh
  24180. */
  24181. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24182. /**
  24183. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24185. * @param name defines the name of the mesh to create
  24186. * @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
  24187. * @param depth defines the height of extrusion
  24188. * @param scene defines the hosting scene
  24189. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24190. * @param updatable defines if the mesh must be flagged as updatable
  24191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24192. * @param earcutInjection can be used to inject your own earcut reference
  24193. * @returns a new Mesh
  24194. */
  24195. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24196. /**
  24197. * Creates an extruded shape mesh.
  24198. * 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
  24199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24200. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24201. * @param name defines the name of the mesh to create
  24202. * @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
  24203. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24204. * @param scale is the value to scale the shape
  24205. * @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
  24206. * @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
  24207. * @param scene defines the hosting scene
  24208. * @param updatable defines if the mesh must be flagged as updatable
  24209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24210. * @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)
  24211. * @returns a new Mesh
  24212. */
  24213. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24214. /**
  24215. * Creates an custom extruded shape mesh.
  24216. * The custom extrusion is a parametric shape.
  24217. * It has no predefined shape. Its final shape will depend on the input parameters.
  24218. * Please consider using the same method from the MeshBuilder class instead
  24219. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24220. * @param name defines the name of the mesh to create
  24221. * @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
  24222. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24223. * @param scaleFunction is a custom Javascript function called on each path point
  24224. * @param rotationFunction is a custom Javascript function called on each path point
  24225. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24226. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24227. * @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
  24228. * @param scene defines the hosting scene
  24229. * @param updatable defines if the mesh must be flagged as updatable
  24230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24231. * @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)
  24232. * @returns a new Mesh
  24233. */
  24234. 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;
  24235. /**
  24236. * Creates lathe mesh.
  24237. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24238. * Please consider using the same method from the MeshBuilder class instead
  24239. * @param name defines the name of the mesh to create
  24240. * @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
  24241. * @param radius is the radius value of the lathe
  24242. * @param tessellation is the side number of the lathe.
  24243. * @param scene defines the hosting scene
  24244. * @param updatable defines if the mesh must be flagged as updatable
  24245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24246. * @returns a new Mesh
  24247. */
  24248. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24249. /**
  24250. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24251. * @param name defines the name of the mesh to create
  24252. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24253. * @param scene defines the hosting scene
  24254. * @param updatable defines if the mesh must be flagged as updatable
  24255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24256. * @returns a new Mesh
  24257. */
  24258. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24259. /**
  24260. * Creates a ground mesh.
  24261. * Please consider using the same method from the MeshBuilder class instead
  24262. * @param name defines the name of the mesh to create
  24263. * @param width set the width of the ground
  24264. * @param height set the height of the ground
  24265. * @param subdivisions sets the number of subdivisions per side
  24266. * @param scene defines the hosting scene
  24267. * @param updatable defines if the mesh must be flagged as updatable
  24268. * @returns a new Mesh
  24269. */
  24270. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24271. /**
  24272. * Creates a tiled ground mesh.
  24273. * Please consider using the same method from the MeshBuilder class instead
  24274. * @param name defines the name of the mesh to create
  24275. * @param xmin set the ground minimum X coordinate
  24276. * @param zmin set the ground minimum Y coordinate
  24277. * @param xmax set the ground maximum X coordinate
  24278. * @param zmax set the ground maximum Z coordinate
  24279. * @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
  24280. * @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
  24281. * @param scene defines the hosting scene
  24282. * @param updatable defines if the mesh must be flagged as updatable
  24283. * @returns a new Mesh
  24284. */
  24285. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24286. w: number;
  24287. h: number;
  24288. }, precision: {
  24289. w: number;
  24290. h: number;
  24291. }, scene: Scene, updatable?: boolean): Mesh;
  24292. /**
  24293. * Creates a ground mesh from a height map.
  24294. * Please consider using the same method from the MeshBuilder class instead
  24295. * @see http://doc.babylonjs.com/babylon101/height_map
  24296. * @param name defines the name of the mesh to create
  24297. * @param url sets the URL of the height map image resource
  24298. * @param width set the ground width size
  24299. * @param height set the ground height size
  24300. * @param subdivisions sets the number of subdivision per side
  24301. * @param minHeight is the minimum altitude on the ground
  24302. * @param maxHeight is the maximum altitude on the ground
  24303. * @param scene defines the hosting scene
  24304. * @param updatable defines if the mesh must be flagged as updatable
  24305. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24306. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24307. * @returns a new Mesh
  24308. */
  24309. 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;
  24310. /**
  24311. * Creates a tube mesh.
  24312. * The tube is a parametric shape.
  24313. * It has no predefined shape. Its final shape will depend on the input parameters.
  24314. * Please consider using the same method from the MeshBuilder class instead
  24315. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24316. * @param name defines the name of the mesh to create
  24317. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24318. * @param radius sets the tube radius size
  24319. * @param tessellation is the number of sides on the tubular surface
  24320. * @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
  24321. * @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
  24322. * @param scene defines the hosting scene
  24323. * @param updatable defines if the mesh must be flagged as updatable
  24324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24325. * @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)
  24326. * @returns a new Mesh
  24327. */
  24328. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24329. (i: number, distance: number): number;
  24330. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24331. /**
  24332. * Creates a polyhedron mesh.
  24333. * Please consider using the same method from the MeshBuilder class instead.
  24334. * * 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
  24335. * * The parameter `size` (positive float, default 1) sets the polygon size
  24336. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24337. * * 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`
  24338. * * 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
  24339. * * 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)`)
  24340. * * 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
  24341. * * 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
  24342. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24343. * * 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
  24344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24345. * @param name defines the name of the mesh to create
  24346. * @param options defines the options used to create the mesh
  24347. * @param scene defines the hosting scene
  24348. * @returns a new Mesh
  24349. */
  24350. static CreatePolyhedron(name: string, options: {
  24351. type?: number;
  24352. size?: number;
  24353. sizeX?: number;
  24354. sizeY?: number;
  24355. sizeZ?: number;
  24356. custom?: any;
  24357. faceUV?: Vector4[];
  24358. faceColors?: Color4[];
  24359. updatable?: boolean;
  24360. sideOrientation?: number;
  24361. }, scene: Scene): Mesh;
  24362. /**
  24363. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24364. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24365. * * 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`)
  24366. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24367. * * 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
  24368. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * * 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
  24370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24371. * @param name defines the name of the mesh
  24372. * @param options defines the options used to create the mesh
  24373. * @param scene defines the hosting scene
  24374. * @returns a new Mesh
  24375. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24376. */
  24377. static CreateIcoSphere(name: string, options: {
  24378. radius?: number;
  24379. flat?: boolean;
  24380. subdivisions?: number;
  24381. sideOrientation?: number;
  24382. updatable?: boolean;
  24383. }, scene: Scene): Mesh;
  24384. /**
  24385. * Creates a decal mesh.
  24386. * Please consider using the same method from the MeshBuilder class instead.
  24387. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24388. * @param name defines the name of the mesh
  24389. * @param sourceMesh defines the mesh receiving the decal
  24390. * @param position sets the position of the decal in world coordinates
  24391. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24392. * @param size sets the decal scaling
  24393. * @param angle sets the angle to rotate the decal
  24394. * @returns a new Mesh
  24395. */
  24396. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24397. /**
  24398. * Prepare internal position array for software CPU skinning
  24399. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24400. */
  24401. setPositionsForCPUSkinning(): Float32Array;
  24402. /**
  24403. * Prepare internal normal array for software CPU skinning
  24404. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24405. */
  24406. setNormalsForCPUSkinning(): Float32Array;
  24407. /**
  24408. * Updates the vertex buffer by applying transformation from the bones
  24409. * @param skeleton defines the skeleton to apply to current mesh
  24410. * @returns the current mesh
  24411. */
  24412. applySkeleton(skeleton: Skeleton): Mesh;
  24413. /**
  24414. * 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
  24415. * @param meshes defines the list of meshes to scan
  24416. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24417. */
  24418. static MinMax(meshes: AbstractMesh[]): {
  24419. min: Vector3;
  24420. max: Vector3;
  24421. };
  24422. /**
  24423. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24424. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24425. * @returns a vector3
  24426. */
  24427. static Center(meshesOrMinMaxVector: {
  24428. min: Vector3;
  24429. max: Vector3;
  24430. } | AbstractMesh[]): Vector3;
  24431. /**
  24432. * Merge the array of meshes into a single mesh for performance reasons.
  24433. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24434. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24435. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24436. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24437. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24438. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24439. * @returns a new mesh
  24440. */
  24441. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24442. /** @hidden */
  24443. addInstance(instance: InstancedMesh): void;
  24444. /** @hidden */
  24445. removeInstance(instance: InstancedMesh): void;
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. /**
  24450. * This is the base class of all the camera used in the application.
  24451. * @see http://doc.babylonjs.com/features/cameras
  24452. */
  24453. export class Camera extends Node {
  24454. /** @hidden */
  24455. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24456. /**
  24457. * This is the default projection mode used by the cameras.
  24458. * It helps recreating a feeling of perspective and better appreciate depth.
  24459. * This is the best way to simulate real life cameras.
  24460. */
  24461. static readonly PERSPECTIVE_CAMERA: number;
  24462. /**
  24463. * This helps creating camera with an orthographic mode.
  24464. * 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.
  24465. */
  24466. static readonly ORTHOGRAPHIC_CAMERA: number;
  24467. /**
  24468. * This is the default FOV mode for perspective cameras.
  24469. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24470. */
  24471. static readonly FOVMODE_VERTICAL_FIXED: number;
  24472. /**
  24473. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24474. */
  24475. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24476. /**
  24477. * This specifies ther is no need for a camera rig.
  24478. * Basically only one eye is rendered corresponding to the camera.
  24479. */
  24480. static readonly RIG_MODE_NONE: number;
  24481. /**
  24482. * Simulates a camera Rig with one blue eye and one red eye.
  24483. * This can be use with 3d blue and red glasses.
  24484. */
  24485. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24486. /**
  24487. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24488. */
  24489. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24490. /**
  24491. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24492. */
  24493. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24494. /**
  24495. * Defines that both eyes of the camera will be rendered over under each other.
  24496. */
  24497. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24498. /**
  24499. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24500. */
  24501. static readonly RIG_MODE_VR: number;
  24502. /**
  24503. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24504. */
  24505. static readonly RIG_MODE_WEBVR: number;
  24506. /**
  24507. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24508. */
  24509. static readonly RIG_MODE_CUSTOM: number;
  24510. /**
  24511. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24512. */
  24513. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24514. /**
  24515. * Define the input manager associated with the camera.
  24516. */
  24517. inputs: CameraInputsManager<Camera>;
  24518. /** @hidden */
  24519. _position: Vector3;
  24520. /**
  24521. * Define the current local position of the camera in the scene
  24522. */
  24523. position: Vector3;
  24524. /**
  24525. * The vector the camera should consider as up.
  24526. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24527. */
  24528. upVector: Vector3;
  24529. /**
  24530. * Define the current limit on the left side for an orthographic camera
  24531. * In scene unit
  24532. */
  24533. orthoLeft: Nullable<number>;
  24534. /**
  24535. * Define the current limit on the right side for an orthographic camera
  24536. * In scene unit
  24537. */
  24538. orthoRight: Nullable<number>;
  24539. /**
  24540. * Define the current limit on the bottom side for an orthographic camera
  24541. * In scene unit
  24542. */
  24543. orthoBottom: Nullable<number>;
  24544. /**
  24545. * Define the current limit on the top side for an orthographic camera
  24546. * In scene unit
  24547. */
  24548. orthoTop: Nullable<number>;
  24549. /**
  24550. * Field Of View is set in Radians. (default is 0.8)
  24551. */
  24552. fov: number;
  24553. /**
  24554. * Define the minimum distance the camera can see from.
  24555. * This is important to note that the depth buffer are not infinite and the closer it starts
  24556. * the more your scene might encounter depth fighting issue.
  24557. */
  24558. minZ: number;
  24559. /**
  24560. * Define the maximum distance the camera can see to.
  24561. * This is important to note that the depth buffer are not infinite and the further it end
  24562. * the more your scene might encounter depth fighting issue.
  24563. */
  24564. maxZ: number;
  24565. /**
  24566. * Define the default inertia of the camera.
  24567. * This helps giving a smooth feeling to the camera movement.
  24568. */
  24569. inertia: number;
  24570. /**
  24571. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24572. */
  24573. mode: number;
  24574. /**
  24575. * Define wether the camera is intermediate.
  24576. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24577. */
  24578. isIntermediate: boolean;
  24579. /**
  24580. * Define the viewport of the camera.
  24581. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24582. */
  24583. viewport: Viewport;
  24584. /**
  24585. * Restricts the camera to viewing objects with the same layerMask.
  24586. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24587. */
  24588. layerMask: number;
  24589. /**
  24590. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24591. */
  24592. fovMode: number;
  24593. /**
  24594. * Rig mode of the camera.
  24595. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24596. * This is normally controlled byt the camera themselves as internal use.
  24597. */
  24598. cameraRigMode: number;
  24599. /**
  24600. * Defines the distance between both "eyes" in case of a RIG
  24601. */
  24602. interaxialDistance: number;
  24603. /**
  24604. * Defines if stereoscopic rendering is done side by side or over under.
  24605. */
  24606. isStereoscopicSideBySide: boolean;
  24607. /**
  24608. * 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
  24609. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24610. * else in the scene. (Eg. security camera)
  24611. *
  24612. * 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)
  24613. */
  24614. customRenderTargets: RenderTargetTexture[];
  24615. /**
  24616. * When set, the camera will render to this render target instead of the default canvas
  24617. *
  24618. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24619. */
  24620. outputRenderTarget: Nullable<RenderTargetTexture>;
  24621. /**
  24622. * Observable triggered when the camera view matrix has changed.
  24623. */
  24624. onViewMatrixChangedObservable: Observable<Camera>;
  24625. /**
  24626. * Observable triggered when the camera Projection matrix has changed.
  24627. */
  24628. onProjectionMatrixChangedObservable: Observable<Camera>;
  24629. /**
  24630. * Observable triggered when the inputs have been processed.
  24631. */
  24632. onAfterCheckInputsObservable: Observable<Camera>;
  24633. /**
  24634. * Observable triggered when reset has been called and applied to the camera.
  24635. */
  24636. onRestoreStateObservable: Observable<Camera>;
  24637. /** @hidden */
  24638. _cameraRigParams: any;
  24639. /** @hidden */
  24640. _rigCameras: Camera[];
  24641. /** @hidden */
  24642. _rigPostProcess: Nullable<PostProcess>;
  24643. protected _webvrViewMatrix: Matrix;
  24644. /** @hidden */
  24645. _skipRendering: boolean;
  24646. /** @hidden */
  24647. _projectionMatrix: Matrix;
  24648. /** @hidden */
  24649. _postProcesses: Nullable<PostProcess>[];
  24650. /** @hidden */
  24651. _activeMeshes: SmartArray<AbstractMesh>;
  24652. protected _globalPosition: Vector3;
  24653. /** @hidden */
  24654. _computedViewMatrix: Matrix;
  24655. private _doNotComputeProjectionMatrix;
  24656. private _transformMatrix;
  24657. private _frustumPlanes;
  24658. private _refreshFrustumPlanes;
  24659. private _storedFov;
  24660. private _stateStored;
  24661. /**
  24662. * Instantiates a new camera object.
  24663. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24664. * @see http://doc.babylonjs.com/features/cameras
  24665. * @param name Defines the name of the camera in the scene
  24666. * @param position Defines the position of the camera
  24667. * @param scene Defines the scene the camera belongs too
  24668. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24669. */
  24670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24671. /**
  24672. * Store current camera state (fov, position, etc..)
  24673. * @returns the camera
  24674. */
  24675. storeState(): Camera;
  24676. /**
  24677. * Restores the camera state values if it has been stored. You must call storeState() first
  24678. */
  24679. protected _restoreStateValues(): boolean;
  24680. /**
  24681. * Restored camera state. You must call storeState() first.
  24682. * @returns true if restored and false otherwise
  24683. */
  24684. restoreState(): boolean;
  24685. /**
  24686. * Gets the class name of the camera.
  24687. * @returns the class name
  24688. */
  24689. getClassName(): string;
  24690. /** @hidden */
  24691. readonly _isCamera: boolean;
  24692. /**
  24693. * Gets a string representation of the camera useful for debug purpose.
  24694. * @param fullDetails Defines that a more verboe level of logging is required
  24695. * @returns the string representation
  24696. */
  24697. toString(fullDetails?: boolean): string;
  24698. /**
  24699. * Gets the current world space position of the camera.
  24700. */
  24701. readonly globalPosition: Vector3;
  24702. /**
  24703. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24704. * @returns the active meshe list
  24705. */
  24706. getActiveMeshes(): SmartArray<AbstractMesh>;
  24707. /**
  24708. * Check wether a mesh is part of the current active mesh list of the camera
  24709. * @param mesh Defines the mesh to check
  24710. * @returns true if active, false otherwise
  24711. */
  24712. isActiveMesh(mesh: Mesh): boolean;
  24713. /**
  24714. * Is this camera ready to be used/rendered
  24715. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24716. * @return true if the camera is ready
  24717. */
  24718. isReady(completeCheck?: boolean): boolean;
  24719. /** @hidden */
  24720. _initCache(): void;
  24721. /** @hidden */
  24722. _updateCache(ignoreParentClass?: boolean): void;
  24723. /** @hidden */
  24724. _isSynchronized(): boolean;
  24725. /** @hidden */
  24726. _isSynchronizedViewMatrix(): boolean;
  24727. /** @hidden */
  24728. _isSynchronizedProjectionMatrix(): boolean;
  24729. /**
  24730. * Attach the input controls to a specific dom element to get the input from.
  24731. * @param element Defines the element the controls should be listened from
  24732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24733. */
  24734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24735. /**
  24736. * Detach the current controls from the specified dom element.
  24737. * @param element Defines the element to stop listening the inputs from
  24738. */
  24739. detachControl(element: HTMLElement): void;
  24740. /**
  24741. * Update the camera state according to the different inputs gathered during the frame.
  24742. */
  24743. update(): void;
  24744. /** @hidden */
  24745. _checkInputs(): void;
  24746. /** @hidden */
  24747. readonly rigCameras: Camera[];
  24748. /**
  24749. * Gets the post process used by the rig cameras
  24750. */
  24751. readonly rigPostProcess: Nullable<PostProcess>;
  24752. /**
  24753. * Internal, gets the first post proces.
  24754. * @returns the first post process to be run on this camera.
  24755. */
  24756. _getFirstPostProcess(): Nullable<PostProcess>;
  24757. private _cascadePostProcessesToRigCams;
  24758. /**
  24759. * Attach a post process to the camera.
  24760. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24761. * @param postProcess The post process to attach to the camera
  24762. * @param insertAt The position of the post process in case several of them are in use in the scene
  24763. * @returns the position the post process has been inserted at
  24764. */
  24765. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24766. /**
  24767. * Detach a post process to the camera.
  24768. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24769. * @param postProcess The post process to detach from the camera
  24770. */
  24771. detachPostProcess(postProcess: PostProcess): void;
  24772. /**
  24773. * Gets the current world matrix of the camera
  24774. */
  24775. getWorldMatrix(): Matrix;
  24776. /** @hidden */
  24777. _getViewMatrix(): Matrix;
  24778. /**
  24779. * Gets the current view matrix of the camera.
  24780. * @param force forces the camera to recompute the matrix without looking at the cached state
  24781. * @returns the view matrix
  24782. */
  24783. getViewMatrix(force?: boolean): Matrix;
  24784. /**
  24785. * Freeze the projection matrix.
  24786. * It will prevent the cache check of the camera projection compute and can speed up perf
  24787. * if no parameter of the camera are meant to change
  24788. * @param projection Defines manually a projection if necessary
  24789. */
  24790. freezeProjectionMatrix(projection?: Matrix): void;
  24791. /**
  24792. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24793. */
  24794. unfreezeProjectionMatrix(): void;
  24795. /**
  24796. * Gets the current projection matrix of the camera.
  24797. * @param force forces the camera to recompute the matrix without looking at the cached state
  24798. * @returns the projection matrix
  24799. */
  24800. getProjectionMatrix(force?: boolean): Matrix;
  24801. /**
  24802. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24803. * @returns a Matrix
  24804. */
  24805. getTransformationMatrix(): Matrix;
  24806. private _updateFrustumPlanes;
  24807. /**
  24808. * Checks if a cullable object (mesh...) is in the camera frustum
  24809. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24810. * @param target The object to check
  24811. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24812. * @returns true if the object is in frustum otherwise false
  24813. */
  24814. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24815. /**
  24816. * Checks if a cullable object (mesh...) is in the camera frustum
  24817. * Unlike isInFrustum this cheks the full bounding box
  24818. * @param target The object to check
  24819. * @returns true if the object is in frustum otherwise false
  24820. */
  24821. isCompletelyInFrustum(target: ICullable): boolean;
  24822. /**
  24823. * Gets a ray in the forward direction from the camera.
  24824. * @param length Defines the length of the ray to create
  24825. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24826. * @param origin Defines the start point of the ray which defaults to the camera position
  24827. * @returns the forward ray
  24828. */
  24829. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24830. /**
  24831. * Releases resources associated with this node.
  24832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24834. */
  24835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24836. /** @hidden */
  24837. _isLeftCamera: boolean;
  24838. /**
  24839. * Gets the left camera of a rig setup in case of Rigged Camera
  24840. */
  24841. readonly isLeftCamera: boolean;
  24842. /** @hidden */
  24843. _isRightCamera: boolean;
  24844. /**
  24845. * Gets the right camera of a rig setup in case of Rigged Camera
  24846. */
  24847. readonly isRightCamera: boolean;
  24848. /**
  24849. * Gets the left camera of a rig setup in case of Rigged Camera
  24850. */
  24851. readonly leftCamera: Nullable<FreeCamera>;
  24852. /**
  24853. * Gets the right camera of a rig setup in case of Rigged Camera
  24854. */
  24855. readonly rightCamera: Nullable<FreeCamera>;
  24856. /**
  24857. * Gets the left camera target of a rig setup in case of Rigged Camera
  24858. * @returns the target position
  24859. */
  24860. getLeftTarget(): Nullable<Vector3>;
  24861. /**
  24862. * Gets the right camera target of a rig setup in case of Rigged Camera
  24863. * @returns the target position
  24864. */
  24865. getRightTarget(): Nullable<Vector3>;
  24866. /**
  24867. * @hidden
  24868. */
  24869. setCameraRigMode(mode: number, rigParams: any): void;
  24870. /** @hidden */
  24871. static _setStereoscopicRigMode(camera: Camera): void;
  24872. /** @hidden */
  24873. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24874. /** @hidden */
  24875. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24876. /** @hidden */
  24877. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24878. /** @hidden */
  24879. _getVRProjectionMatrix(): Matrix;
  24880. protected _updateCameraRotationMatrix(): void;
  24881. protected _updateWebVRCameraRotationMatrix(): void;
  24882. /**
  24883. * This function MUST be overwritten by the different WebVR cameras available.
  24884. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24885. * @hidden
  24886. */
  24887. _getWebVRProjectionMatrix(): Matrix;
  24888. /**
  24889. * This function MUST be overwritten by the different WebVR cameras available.
  24890. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24891. * @hidden
  24892. */
  24893. _getWebVRViewMatrix(): Matrix;
  24894. /** @hidden */
  24895. setCameraRigParameter(name: string, value: any): void;
  24896. /**
  24897. * needs to be overridden by children so sub has required properties to be copied
  24898. * @hidden
  24899. */
  24900. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24901. /**
  24902. * May need to be overridden by children
  24903. * @hidden
  24904. */
  24905. _updateRigCameras(): void;
  24906. /** @hidden */
  24907. _setupInputs(): void;
  24908. /**
  24909. * Serialiaze the camera setup to a json represention
  24910. * @returns the JSON representation
  24911. */
  24912. serialize(): any;
  24913. /**
  24914. * Clones the current camera.
  24915. * @param name The cloned camera name
  24916. * @returns the cloned camera
  24917. */
  24918. clone(name: string): Camera;
  24919. /**
  24920. * Gets the direction of the camera relative to a given local axis.
  24921. * @param localAxis Defines the reference axis to provide a relative direction.
  24922. * @return the direction
  24923. */
  24924. getDirection(localAxis: Vector3): Vector3;
  24925. /**
  24926. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24927. * @param localAxis Defines the reference axis to provide a relative direction.
  24928. * @param result Defines the vector to store the result in
  24929. */
  24930. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24931. /**
  24932. * Gets a camera constructor for a given camera type
  24933. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24934. * @param name The name of the camera the result will be able to instantiate
  24935. * @param scene The scene the result will construct the camera in
  24936. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24937. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24938. * @returns a factory method to construc the camera
  24939. */
  24940. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24941. /**
  24942. * Compute the world matrix of the camera.
  24943. * @returns the camera workd matrix
  24944. */
  24945. computeWorldMatrix(): Matrix;
  24946. /**
  24947. * Parse a JSON and creates the camera from the parsed information
  24948. * @param parsedCamera The JSON to parse
  24949. * @param scene The scene to instantiate the camera in
  24950. * @returns the newly constructed camera
  24951. */
  24952. static Parse(parsedCamera: any, scene: Scene): Camera;
  24953. }
  24954. }
  24955. declare module BABYLON {
  24956. /**
  24957. * Class containing static functions to help procedurally build meshes
  24958. */
  24959. export class DiscBuilder {
  24960. /**
  24961. * Creates a plane polygonal mesh. By default, this is a disc
  24962. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24963. * * 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
  24964. * * 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
  24965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24966. * * 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
  24967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24968. * @param name defines the name of the mesh
  24969. * @param options defines the options used to create the mesh
  24970. * @param scene defines the hosting scene
  24971. * @returns the plane polygonal mesh
  24972. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24973. */
  24974. static CreateDisc(name: string, options: {
  24975. radius?: number;
  24976. tessellation?: number;
  24977. arc?: number;
  24978. updatable?: boolean;
  24979. sideOrientation?: number;
  24980. frontUVs?: Vector4;
  24981. backUVs?: Vector4;
  24982. }, scene?: Nullable<Scene>): Mesh;
  24983. }
  24984. }
  24985. declare module BABYLON {
  24986. /**
  24987. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24988. *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.
  24989. * The SPS is also a particle system. It provides some methods to manage the particles.
  24990. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24991. *
  24992. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24993. */
  24994. export class SolidParticleSystem implements IDisposable {
  24995. /**
  24996. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24997. * Example : var p = SPS.particles[i];
  24998. */
  24999. particles: SolidParticle[];
  25000. /**
  25001. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25002. */
  25003. nbParticles: number;
  25004. /**
  25005. * If the particles must ever face the camera (default false). Useful for planar particles.
  25006. */
  25007. billboard: boolean;
  25008. /**
  25009. * Recompute normals when adding a shape
  25010. */
  25011. recomputeNormals: boolean;
  25012. /**
  25013. * This a counter ofr your own usage. It's not set by any SPS functions.
  25014. */
  25015. counter: number;
  25016. /**
  25017. * The SPS name. This name is also given to the underlying mesh.
  25018. */
  25019. name: string;
  25020. /**
  25021. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25022. */
  25023. mesh: Mesh;
  25024. /**
  25025. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25026. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25027. */
  25028. vars: any;
  25029. /**
  25030. * This array is populated when the SPS is set as 'pickable'.
  25031. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25032. * Each element of this array is an object `{idx: int, faceId: int}`.
  25033. * `idx` is the picked particle index in the `SPS.particles` array
  25034. * `faceId` is the picked face index counted within this particle.
  25035. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25036. */
  25037. pickedParticles: {
  25038. idx: number;
  25039. faceId: number;
  25040. }[];
  25041. /**
  25042. * This array is populated when `enableDepthSort` is set to true.
  25043. * Each element of this array is an instance of the class DepthSortedParticle.
  25044. */
  25045. depthSortedParticles: DepthSortedParticle[];
  25046. /**
  25047. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25048. * @hidden
  25049. */
  25050. _bSphereOnly: boolean;
  25051. /**
  25052. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25053. * @hidden
  25054. */
  25055. _bSphereRadiusFactor: number;
  25056. private _scene;
  25057. private _positions;
  25058. private _indices;
  25059. private _normals;
  25060. private _colors;
  25061. private _uvs;
  25062. private _indices32;
  25063. private _positions32;
  25064. private _normals32;
  25065. private _fixedNormal32;
  25066. private _colors32;
  25067. private _uvs32;
  25068. private _index;
  25069. private _updatable;
  25070. private _pickable;
  25071. private _isVisibilityBoxLocked;
  25072. private _alwaysVisible;
  25073. private _depthSort;
  25074. private _shapeCounter;
  25075. private _copy;
  25076. private _color;
  25077. private _computeParticleColor;
  25078. private _computeParticleTexture;
  25079. private _computeParticleRotation;
  25080. private _computeParticleVertex;
  25081. private _computeBoundingBox;
  25082. private _depthSortParticles;
  25083. private _camera;
  25084. private _mustUnrotateFixedNormals;
  25085. private _particlesIntersect;
  25086. private _needs32Bits;
  25087. /**
  25088. * Creates a SPS (Solid Particle System) object.
  25089. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25090. * @param scene (Scene) is the scene in which the SPS is added.
  25091. * @param options defines the options of the sps e.g.
  25092. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25093. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25094. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25095. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25096. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25097. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25098. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25099. */
  25100. constructor(name: string, scene: Scene, options?: {
  25101. updatable?: boolean;
  25102. isPickable?: boolean;
  25103. enableDepthSort?: boolean;
  25104. particleIntersection?: boolean;
  25105. boundingSphereOnly?: boolean;
  25106. bSphereRadiusFactor?: number;
  25107. });
  25108. /**
  25109. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25110. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25111. * @returns the created mesh
  25112. */
  25113. buildMesh(): Mesh;
  25114. /**
  25115. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25116. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25117. * Thus the particles generated from `digest()` have their property `position` set yet.
  25118. * @param mesh ( Mesh ) is the mesh to be digested
  25119. * @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
  25120. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25121. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25122. * @returns the current SPS
  25123. */
  25124. digest(mesh: Mesh, options?: {
  25125. facetNb?: number;
  25126. number?: number;
  25127. delta?: number;
  25128. }): SolidParticleSystem;
  25129. private _unrotateFixedNormals;
  25130. private _resetCopy;
  25131. private _meshBuilder;
  25132. private _posToShape;
  25133. private _uvsToShapeUV;
  25134. private _addParticle;
  25135. /**
  25136. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25137. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25138. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25139. * @param nb (positive integer) the number of particles to be created from this model
  25140. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25141. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25142. * @returns the number of shapes in the system
  25143. */
  25144. addShape(mesh: Mesh, nb: number, options?: {
  25145. positionFunction?: any;
  25146. vertexFunction?: any;
  25147. }): number;
  25148. private _rebuildParticle;
  25149. /**
  25150. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25151. * @returns the SPS.
  25152. */
  25153. rebuildMesh(): SolidParticleSystem;
  25154. /**
  25155. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25156. * This method calls `updateParticle()` for each particle of the SPS.
  25157. * For an animated SPS, it is usually called within the render loop.
  25158. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25159. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25160. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25161. * @returns the SPS.
  25162. */
  25163. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25164. /**
  25165. * Disposes the SPS.
  25166. */
  25167. dispose(): void;
  25168. /**
  25169. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25171. * @returns the SPS.
  25172. */
  25173. refreshVisibleSize(): SolidParticleSystem;
  25174. /**
  25175. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25176. * @param size the size (float) of the visibility box
  25177. * note : this doesn't lock the SPS mesh bounding box.
  25178. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25179. */
  25180. setVisibilityBox(size: number): void;
  25181. /**
  25182. * Gets whether the SPS as always visible or not
  25183. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25184. */
  25185. /**
  25186. * Sets the SPS as always visible or not
  25187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25188. */
  25189. isAlwaysVisible: boolean;
  25190. /**
  25191. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25193. */
  25194. /**
  25195. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25197. */
  25198. isVisibilityBoxLocked: boolean;
  25199. /**
  25200. * Tells to `setParticles()` to compute the particle rotations or not.
  25201. * Default value : true. The SPS is faster when it's set to false.
  25202. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25203. */
  25204. /**
  25205. * Gets if `setParticles()` computes the particle rotations or not.
  25206. * Default value : true. The SPS is faster when it's set to false.
  25207. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25208. */
  25209. computeParticleRotation: boolean;
  25210. /**
  25211. * Tells to `setParticles()` to compute the particle colors or not.
  25212. * Default value : true. The SPS is faster when it's set to false.
  25213. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25214. */
  25215. /**
  25216. * Gets if `setParticles()` computes the particle colors or not.
  25217. * Default value : true. The SPS is faster when it's set to false.
  25218. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25219. */
  25220. computeParticleColor: boolean;
  25221. /**
  25222. * Gets if `setParticles()` computes the particle textures or not.
  25223. * Default value : true. The SPS is faster when it's set to false.
  25224. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25225. */
  25226. computeParticleTexture: boolean;
  25227. /**
  25228. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25229. * Default value : false. The SPS is faster when it's set to false.
  25230. * Note : the particle custom vertex positions aren't stored values.
  25231. */
  25232. /**
  25233. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25234. * Default value : false. The SPS is faster when it's set to false.
  25235. * Note : the particle custom vertex positions aren't stored values.
  25236. */
  25237. computeParticleVertex: boolean;
  25238. /**
  25239. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25240. */
  25241. /**
  25242. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25243. */
  25244. computeBoundingBox: boolean;
  25245. /**
  25246. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25247. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25248. * Default : `true`
  25249. */
  25250. /**
  25251. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25252. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25253. * Default : `true`
  25254. */
  25255. depthSortParticles: boolean;
  25256. /**
  25257. * This function does nothing. It may be overwritten to set all the particle first values.
  25258. * The SPS doesn't call this function, you may have to call it by your own.
  25259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25260. */
  25261. initParticles(): void;
  25262. /**
  25263. * This function does nothing. It may be overwritten to recycle a particle.
  25264. * The SPS doesn't call this function, you may have to call it by your own.
  25265. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25266. * @param particle The particle to recycle
  25267. * @returns the recycled particle
  25268. */
  25269. recycleParticle(particle: SolidParticle): SolidParticle;
  25270. /**
  25271. * Updates a particle : this function should be overwritten by the user.
  25272. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25273. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25274. * @example : just set a particle position or velocity and recycle conditions
  25275. * @param particle The particle to update
  25276. * @returns the updated particle
  25277. */
  25278. updateParticle(particle: SolidParticle): SolidParticle;
  25279. /**
  25280. * Updates a vertex of a particle : it can be overwritten by the user.
  25281. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25282. * @param particle the current particle
  25283. * @param vertex the current index of the current particle
  25284. * @param pt the index of the current vertex in the particle shape
  25285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25286. * @example : just set a vertex particle position
  25287. * @returns the updated vertex
  25288. */
  25289. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25290. /**
  25291. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25292. * This does nothing and may be overwritten by the user.
  25293. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25294. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25295. * @param update the boolean update value actually passed to setParticles()
  25296. */
  25297. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25298. /**
  25299. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25300. * This will be passed three parameters.
  25301. * This does nothing and may be overwritten by the user.
  25302. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25303. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25304. * @param update the boolean update value actually passed to setParticles()
  25305. */
  25306. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25307. }
  25308. }
  25309. declare module BABYLON {
  25310. /**
  25311. * Represents one particle of a solid particle system.
  25312. */
  25313. export class SolidParticle {
  25314. /**
  25315. * particle global index
  25316. */
  25317. idx: number;
  25318. /**
  25319. * The color of the particle
  25320. */
  25321. color: Nullable<Color4>;
  25322. /**
  25323. * The world space position of the particle.
  25324. */
  25325. position: Vector3;
  25326. /**
  25327. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25328. */
  25329. rotation: Vector3;
  25330. /**
  25331. * The world space rotation quaternion of the particle.
  25332. */
  25333. rotationQuaternion: Nullable<Quaternion>;
  25334. /**
  25335. * The scaling of the particle.
  25336. */
  25337. scaling: Vector3;
  25338. /**
  25339. * The uvs of the particle.
  25340. */
  25341. uvs: Vector4;
  25342. /**
  25343. * The current speed of the particle.
  25344. */
  25345. velocity: Vector3;
  25346. /**
  25347. * The pivot point in the particle local space.
  25348. */
  25349. pivot: Vector3;
  25350. /**
  25351. * Must the particle be translated from its pivot point in its local space ?
  25352. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25353. * Default : false
  25354. */
  25355. translateFromPivot: boolean;
  25356. /**
  25357. * Is the particle active or not ?
  25358. */
  25359. alive: boolean;
  25360. /**
  25361. * Is the particle visible or not ?
  25362. */
  25363. isVisible: boolean;
  25364. /**
  25365. * Index of this particle in the global "positions" array (Internal use)
  25366. * @hidden
  25367. */
  25368. _pos: number;
  25369. /**
  25370. * @hidden Index of this particle in the global "indices" array (Internal use)
  25371. */
  25372. _ind: number;
  25373. /**
  25374. * @hidden ModelShape of this particle (Internal use)
  25375. */
  25376. _model: ModelShape;
  25377. /**
  25378. * ModelShape id of this particle
  25379. */
  25380. shapeId: number;
  25381. /**
  25382. * Index of the particle in its shape id
  25383. */
  25384. idxInShape: number;
  25385. /**
  25386. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25387. */
  25388. _modelBoundingInfo: BoundingInfo;
  25389. /**
  25390. * @hidden Particle BoundingInfo object (Internal use)
  25391. */
  25392. _boundingInfo: BoundingInfo;
  25393. /**
  25394. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25395. */
  25396. _sps: SolidParticleSystem;
  25397. /**
  25398. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25399. */
  25400. _stillInvisible: boolean;
  25401. /**
  25402. * @hidden Last computed particle rotation matrix
  25403. */
  25404. _rotationMatrix: number[];
  25405. /**
  25406. * Parent particle Id, if any.
  25407. * Default null.
  25408. */
  25409. parentId: Nullable<number>;
  25410. /**
  25411. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25412. * The possible values are :
  25413. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25414. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25415. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25416. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25417. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25418. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25419. * */
  25420. cullingStrategy: number;
  25421. /**
  25422. * @hidden Internal global position in the SPS.
  25423. */
  25424. _globalPosition: Vector3;
  25425. /**
  25426. * Creates a Solid Particle object.
  25427. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25428. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25429. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25430. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25431. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25432. * @param shapeId (integer) is the model shape identifier in the SPS.
  25433. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25434. * @param sps defines the sps it is associated to
  25435. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25436. */
  25437. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25438. /**
  25439. * Legacy support, changed scale to scaling
  25440. */
  25441. /**
  25442. * Legacy support, changed scale to scaling
  25443. */
  25444. scale: Vector3;
  25445. /**
  25446. * Legacy support, changed quaternion to rotationQuaternion
  25447. */
  25448. /**
  25449. * Legacy support, changed quaternion to rotationQuaternion
  25450. */
  25451. quaternion: Nullable<Quaternion>;
  25452. /**
  25453. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25454. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25455. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25456. * @returns true if it intersects
  25457. */
  25458. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25459. /**
  25460. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25461. * A particle is in the frustum if its bounding box intersects the frustum
  25462. * @param frustumPlanes defines the frustum to test
  25463. * @returns true if the particle is in the frustum planes
  25464. */
  25465. isInFrustum(frustumPlanes: Plane[]): boolean;
  25466. /**
  25467. * get the rotation matrix of the particle
  25468. * @hidden
  25469. */
  25470. getRotationMatrix(m: Matrix): void;
  25471. }
  25472. /**
  25473. * Represents the shape of the model used by one particle of a solid particle system.
  25474. * SPS internal tool, don't use it manually.
  25475. */
  25476. export class ModelShape {
  25477. /**
  25478. * The shape id
  25479. * @hidden
  25480. */
  25481. shapeID: number;
  25482. /**
  25483. * flat array of model positions (internal use)
  25484. * @hidden
  25485. */
  25486. _shape: Vector3[];
  25487. /**
  25488. * flat array of model UVs (internal use)
  25489. * @hidden
  25490. */
  25491. _shapeUV: number[];
  25492. /**
  25493. * length of the shape in the model indices array (internal use)
  25494. * @hidden
  25495. */
  25496. _indicesLength: number;
  25497. /**
  25498. * Custom position function (internal use)
  25499. * @hidden
  25500. */
  25501. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25502. /**
  25503. * Custom vertex function (internal use)
  25504. * @hidden
  25505. */
  25506. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25507. /**
  25508. * 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.
  25509. * SPS internal tool, don't use it manually.
  25510. * @hidden
  25511. */
  25512. 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>);
  25513. }
  25514. /**
  25515. * Represents a Depth Sorted Particle in the solid particle system.
  25516. */
  25517. export class DepthSortedParticle {
  25518. /**
  25519. * Index of the particle in the "indices" array
  25520. */
  25521. ind: number;
  25522. /**
  25523. * Length of the particle shape in the "indices" array
  25524. */
  25525. indicesLength: number;
  25526. /**
  25527. * Squared distance from the particle to the camera
  25528. */
  25529. sqDistance: number;
  25530. }
  25531. }
  25532. declare module BABYLON {
  25533. /**
  25534. * @hidden
  25535. */
  25536. export class _MeshCollisionData {
  25537. _checkCollisions: boolean;
  25538. _collisionMask: number;
  25539. _collisionGroup: number;
  25540. _collider: Nullable<Collider>;
  25541. _oldPositionForCollisions: Vector3;
  25542. _diffPositionForCollisions: Vector3;
  25543. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25544. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25545. }
  25546. }
  25547. declare module BABYLON {
  25548. /** @hidden */
  25549. class _FacetDataStorage {
  25550. facetPositions: Vector3[];
  25551. facetNormals: Vector3[];
  25552. facetPartitioning: number[][];
  25553. facetNb: number;
  25554. partitioningSubdivisions: number;
  25555. partitioningBBoxRatio: number;
  25556. facetDataEnabled: boolean;
  25557. facetParameters: any;
  25558. bbSize: Vector3;
  25559. subDiv: {
  25560. max: number;
  25561. X: number;
  25562. Y: number;
  25563. Z: number;
  25564. };
  25565. facetDepthSort: boolean;
  25566. facetDepthSortEnabled: boolean;
  25567. depthSortedIndices: IndicesArray;
  25568. depthSortedFacets: {
  25569. ind: number;
  25570. sqDistance: number;
  25571. }[];
  25572. facetDepthSortFunction: (f1: {
  25573. ind: number;
  25574. sqDistance: number;
  25575. }, f2: {
  25576. ind: number;
  25577. sqDistance: number;
  25578. }) => number;
  25579. facetDepthSortFrom: Vector3;
  25580. facetDepthSortOrigin: Vector3;
  25581. invertedMatrix: Matrix;
  25582. }
  25583. /**
  25584. * @hidden
  25585. **/
  25586. class _InternalAbstractMeshDataInfo {
  25587. _hasVertexAlpha: boolean;
  25588. _useVertexColors: boolean;
  25589. _numBoneInfluencers: number;
  25590. _applyFog: boolean;
  25591. _receiveShadows: boolean;
  25592. _facetData: _FacetDataStorage;
  25593. _visibility: number;
  25594. _skeleton: Nullable<Skeleton>;
  25595. _layerMask: number;
  25596. _computeBonesUsingShaders: boolean;
  25597. _isActive: boolean;
  25598. _onlyForInstances: boolean;
  25599. _isActiveIntermediate: boolean;
  25600. _onlyForInstancesIntermediate: boolean;
  25601. }
  25602. /**
  25603. * Class used to store all common mesh properties
  25604. */
  25605. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25606. /** No occlusion */
  25607. static OCCLUSION_TYPE_NONE: number;
  25608. /** Occlusion set to optimisitic */
  25609. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25610. /** Occlusion set to strict */
  25611. static OCCLUSION_TYPE_STRICT: number;
  25612. /** Use an accurante occlusion algorithm */
  25613. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25614. /** Use a conservative occlusion algorithm */
  25615. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25616. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25617. * Test order :
  25618. * Is the bounding sphere outside the frustum ?
  25619. * If not, are the bounding box vertices outside the frustum ?
  25620. * It not, then the cullable object is in the frustum.
  25621. */
  25622. static readonly CULLINGSTRATEGY_STANDARD: number;
  25623. /** Culling strategy : Bounding Sphere Only.
  25624. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25625. * It's also less accurate than the standard because some not visible objects can still be selected.
  25626. * Test : is the bounding sphere outside the frustum ?
  25627. * If not, then the cullable object is in the frustum.
  25628. */
  25629. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25630. /** Culling strategy : Optimistic Inclusion.
  25631. * This in an inclusion test first, then the standard exclusion test.
  25632. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25633. * 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.
  25634. * Anyway, it's as accurate as the standard strategy.
  25635. * Test :
  25636. * Is the cullable object bounding sphere center in the frustum ?
  25637. * If not, apply the default culling strategy.
  25638. */
  25639. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25640. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25641. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25642. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25643. * 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.
  25644. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25645. * Test :
  25646. * Is the cullable object bounding sphere center in the frustum ?
  25647. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25648. */
  25649. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25650. /**
  25651. * No billboard
  25652. */
  25653. static readonly BILLBOARDMODE_NONE: number;
  25654. /** Billboard on X axis */
  25655. static readonly BILLBOARDMODE_X: number;
  25656. /** Billboard on Y axis */
  25657. static readonly BILLBOARDMODE_Y: number;
  25658. /** Billboard on Z axis */
  25659. static readonly BILLBOARDMODE_Z: number;
  25660. /** Billboard on all axes */
  25661. static readonly BILLBOARDMODE_ALL: number;
  25662. /** Billboard on using position instead of orientation */
  25663. static readonly BILLBOARDMODE_USE_POSITION: number;
  25664. /** @hidden */
  25665. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25666. /**
  25667. * The culling strategy to use to check whether the mesh must be rendered or not.
  25668. * This value can be changed at any time and will be used on the next render mesh selection.
  25669. * The possible values are :
  25670. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25671. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25672. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25673. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25674. * Please read each static variable documentation to get details about the culling process.
  25675. * */
  25676. cullingStrategy: number;
  25677. /**
  25678. * Gets the number of facets in the mesh
  25679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25680. */
  25681. readonly facetNb: number;
  25682. /**
  25683. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25685. */
  25686. partitioningSubdivisions: number;
  25687. /**
  25688. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25689. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25691. */
  25692. partitioningBBoxRatio: number;
  25693. /**
  25694. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25695. * Works only for updatable meshes.
  25696. * Doesn't work with multi-materials
  25697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25698. */
  25699. mustDepthSortFacets: boolean;
  25700. /**
  25701. * The location (Vector3) where the facet depth sort must be computed from.
  25702. * By default, the active camera position.
  25703. * Used only when facet depth sort is enabled
  25704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25705. */
  25706. facetDepthSortFrom: Vector3;
  25707. /**
  25708. * gets a boolean indicating if facetData is enabled
  25709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25710. */
  25711. readonly isFacetDataEnabled: boolean;
  25712. /** @hidden */
  25713. _updateNonUniformScalingState(value: boolean): boolean;
  25714. /**
  25715. * An event triggered when this mesh collides with another one
  25716. */
  25717. onCollideObservable: Observable<AbstractMesh>;
  25718. /** Set a function to call when this mesh collides with another one */
  25719. onCollide: () => void;
  25720. /**
  25721. * An event triggered when the collision's position changes
  25722. */
  25723. onCollisionPositionChangeObservable: Observable<Vector3>;
  25724. /** Set a function to call when the collision's position changes */
  25725. onCollisionPositionChange: () => void;
  25726. /**
  25727. * An event triggered when material is changed
  25728. */
  25729. onMaterialChangedObservable: Observable<AbstractMesh>;
  25730. /**
  25731. * Gets or sets the orientation for POV movement & rotation
  25732. */
  25733. definedFacingForward: boolean;
  25734. /** @hidden */
  25735. _occlusionQuery: Nullable<WebGLQuery>;
  25736. /** @hidden */
  25737. _renderingGroup: Nullable<RenderingGroup>;
  25738. /**
  25739. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25740. */
  25741. /**
  25742. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25743. */
  25744. visibility: number;
  25745. /** Gets or sets the alpha index used to sort transparent meshes
  25746. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25747. */
  25748. alphaIndex: number;
  25749. /**
  25750. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25751. */
  25752. isVisible: boolean;
  25753. /**
  25754. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25755. */
  25756. isPickable: boolean;
  25757. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25758. showSubMeshesBoundingBox: boolean;
  25759. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25760. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25761. */
  25762. isBlocker: boolean;
  25763. /**
  25764. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25765. */
  25766. enablePointerMoveEvents: boolean;
  25767. /**
  25768. * Specifies the rendering group id for this mesh (0 by default)
  25769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25770. */
  25771. renderingGroupId: number;
  25772. private _material;
  25773. /** Gets or sets current material */
  25774. material: Nullable<Material>;
  25775. /**
  25776. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25777. * @see http://doc.babylonjs.com/babylon101/shadows
  25778. */
  25779. receiveShadows: boolean;
  25780. /** Defines color to use when rendering outline */
  25781. outlineColor: Color3;
  25782. /** Define width to use when rendering outline */
  25783. outlineWidth: number;
  25784. /** Defines color to use when rendering overlay */
  25785. overlayColor: Color3;
  25786. /** Defines alpha to use when rendering overlay */
  25787. overlayAlpha: number;
  25788. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25789. hasVertexAlpha: boolean;
  25790. /** 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) */
  25791. useVertexColors: boolean;
  25792. /**
  25793. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25794. */
  25795. computeBonesUsingShaders: boolean;
  25796. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25797. numBoneInfluencers: number;
  25798. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25799. applyFog: boolean;
  25800. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25801. useOctreeForRenderingSelection: boolean;
  25802. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25803. useOctreeForPicking: boolean;
  25804. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25805. useOctreeForCollisions: boolean;
  25806. /**
  25807. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25808. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25809. */
  25810. layerMask: number;
  25811. /**
  25812. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25813. */
  25814. alwaysSelectAsActiveMesh: boolean;
  25815. /**
  25816. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25817. */
  25818. doNotSyncBoundingInfo: boolean;
  25819. /**
  25820. * Gets or sets the current action manager
  25821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25822. */
  25823. actionManager: Nullable<AbstractActionManager>;
  25824. private _meshCollisionData;
  25825. /**
  25826. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25828. */
  25829. ellipsoid: Vector3;
  25830. /**
  25831. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25832. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25833. */
  25834. ellipsoidOffset: Vector3;
  25835. /**
  25836. * Gets or sets a collision mask used to mask collisions (default is -1).
  25837. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25838. */
  25839. collisionMask: number;
  25840. /**
  25841. * Gets or sets the current collision group mask (-1 by default).
  25842. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25843. */
  25844. collisionGroup: number;
  25845. /**
  25846. * Defines edge width used when edgesRenderer is enabled
  25847. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25848. */
  25849. edgesWidth: number;
  25850. /**
  25851. * Defines edge color used when edgesRenderer is enabled
  25852. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25853. */
  25854. edgesColor: Color4;
  25855. /** @hidden */
  25856. _edgesRenderer: Nullable<IEdgesRenderer>;
  25857. /** @hidden */
  25858. _masterMesh: Nullable<AbstractMesh>;
  25859. /** @hidden */
  25860. _boundingInfo: Nullable<BoundingInfo>;
  25861. /** @hidden */
  25862. _renderId: number;
  25863. /**
  25864. * Gets or sets the list of subMeshes
  25865. * @see http://doc.babylonjs.com/how_to/multi_materials
  25866. */
  25867. subMeshes: SubMesh[];
  25868. /** @hidden */
  25869. _intersectionsInProgress: AbstractMesh[];
  25870. /** @hidden */
  25871. _unIndexed: boolean;
  25872. /** @hidden */
  25873. _lightSources: Light[];
  25874. /** Gets the list of lights affecting that mesh */
  25875. readonly lightSources: Light[];
  25876. /** @hidden */
  25877. readonly _positions: Nullable<Vector3[]>;
  25878. /** @hidden */
  25879. _waitingData: {
  25880. lods: Nullable<any>;
  25881. actions: Nullable<any>;
  25882. freezeWorldMatrix: Nullable<boolean>;
  25883. };
  25884. /** @hidden */
  25885. _bonesTransformMatrices: Nullable<Float32Array>;
  25886. /** @hidden */
  25887. _transformMatrixTexture: Nullable<RawTexture>;
  25888. /**
  25889. * Gets or sets a skeleton to apply skining transformations
  25890. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25891. */
  25892. skeleton: Nullable<Skeleton>;
  25893. /**
  25894. * An event triggered when the mesh is rebuilt.
  25895. */
  25896. onRebuildObservable: Observable<AbstractMesh>;
  25897. /**
  25898. * Creates a new AbstractMesh
  25899. * @param name defines the name of the mesh
  25900. * @param scene defines the hosting scene
  25901. */
  25902. constructor(name: string, scene?: Nullable<Scene>);
  25903. /**
  25904. * Returns the string "AbstractMesh"
  25905. * @returns "AbstractMesh"
  25906. */
  25907. getClassName(): string;
  25908. /**
  25909. * Gets a string representation of the current mesh
  25910. * @param fullDetails defines a boolean indicating if full details must be included
  25911. * @returns a string representation of the current mesh
  25912. */
  25913. toString(fullDetails?: boolean): string;
  25914. /**
  25915. * @hidden
  25916. */
  25917. protected _getEffectiveParent(): Nullable<Node>;
  25918. /** @hidden */
  25919. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25920. /** @hidden */
  25921. _rebuild(): void;
  25922. /** @hidden */
  25923. _resyncLightSources(): void;
  25924. /** @hidden */
  25925. _resyncLighSource(light: Light): void;
  25926. /** @hidden */
  25927. _unBindEffect(): void;
  25928. /** @hidden */
  25929. _removeLightSource(light: Light, dispose: boolean): void;
  25930. private _markSubMeshesAsDirty;
  25931. /** @hidden */
  25932. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25933. /** @hidden */
  25934. _markSubMeshesAsAttributesDirty(): void;
  25935. /** @hidden */
  25936. _markSubMeshesAsMiscDirty(): void;
  25937. /**
  25938. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25939. */
  25940. scaling: Vector3;
  25941. /**
  25942. * Returns true if the mesh is blocked. Implemented by child classes
  25943. */
  25944. readonly isBlocked: boolean;
  25945. /**
  25946. * Returns the mesh itself by default. Implemented by child classes
  25947. * @param camera defines the camera to use to pick the right LOD level
  25948. * @returns the currentAbstractMesh
  25949. */
  25950. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25951. /**
  25952. * Returns 0 by default. Implemented by child classes
  25953. * @returns an integer
  25954. */
  25955. getTotalVertices(): number;
  25956. /**
  25957. * Returns a positive integer : the total number of indices in this mesh geometry.
  25958. * @returns the numner of indices or zero if the mesh has no geometry.
  25959. */
  25960. getTotalIndices(): number;
  25961. /**
  25962. * Returns null by default. Implemented by child classes
  25963. * @returns null
  25964. */
  25965. getIndices(): Nullable<IndicesArray>;
  25966. /**
  25967. * Returns the array of the requested vertex data kind. Implemented by child classes
  25968. * @param kind defines the vertex data kind to use
  25969. * @returns null
  25970. */
  25971. getVerticesData(kind: string): Nullable<FloatArray>;
  25972. /**
  25973. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25974. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25975. * Note that a new underlying VertexBuffer object is created each call.
  25976. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25977. * @param kind defines vertex data kind:
  25978. * * VertexBuffer.PositionKind
  25979. * * VertexBuffer.UVKind
  25980. * * VertexBuffer.UV2Kind
  25981. * * VertexBuffer.UV3Kind
  25982. * * VertexBuffer.UV4Kind
  25983. * * VertexBuffer.UV5Kind
  25984. * * VertexBuffer.UV6Kind
  25985. * * VertexBuffer.ColorKind
  25986. * * VertexBuffer.MatricesIndicesKind
  25987. * * VertexBuffer.MatricesIndicesExtraKind
  25988. * * VertexBuffer.MatricesWeightsKind
  25989. * * VertexBuffer.MatricesWeightsExtraKind
  25990. * @param data defines the data source
  25991. * @param updatable defines if the data must be flagged as updatable (or static)
  25992. * @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
  25993. * @returns the current mesh
  25994. */
  25995. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25996. /**
  25997. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25998. * If the mesh has no geometry, it is simply returned as it is.
  25999. * @param kind defines vertex data kind:
  26000. * * VertexBuffer.PositionKind
  26001. * * VertexBuffer.UVKind
  26002. * * VertexBuffer.UV2Kind
  26003. * * VertexBuffer.UV3Kind
  26004. * * VertexBuffer.UV4Kind
  26005. * * VertexBuffer.UV5Kind
  26006. * * VertexBuffer.UV6Kind
  26007. * * VertexBuffer.ColorKind
  26008. * * VertexBuffer.MatricesIndicesKind
  26009. * * VertexBuffer.MatricesIndicesExtraKind
  26010. * * VertexBuffer.MatricesWeightsKind
  26011. * * VertexBuffer.MatricesWeightsExtraKind
  26012. * @param data defines the data source
  26013. * @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
  26014. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26015. * @returns the current mesh
  26016. */
  26017. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26018. /**
  26019. * Sets the mesh indices,
  26020. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26021. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26022. * @param totalVertices Defines the total number of vertices
  26023. * @returns the current mesh
  26024. */
  26025. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26026. /**
  26027. * Gets a boolean indicating if specific vertex data is present
  26028. * @param kind defines the vertex data kind to use
  26029. * @returns true is data kind is present
  26030. */
  26031. isVerticesDataPresent(kind: string): boolean;
  26032. /**
  26033. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26034. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26035. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26036. * @returns a BoundingInfo
  26037. */
  26038. getBoundingInfo(): BoundingInfo;
  26039. /**
  26040. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26041. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26042. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26043. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26044. * @returns the current mesh
  26045. */
  26046. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26047. /**
  26048. * Overwrite the current bounding info
  26049. * @param boundingInfo defines the new bounding info
  26050. * @returns the current mesh
  26051. */
  26052. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26053. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26054. readonly useBones: boolean;
  26055. /** @hidden */
  26056. _preActivate(): void;
  26057. /** @hidden */
  26058. _preActivateForIntermediateRendering(renderId: number): void;
  26059. /** @hidden */
  26060. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26061. /** @hidden */
  26062. _postActivate(): void;
  26063. /** @hidden */
  26064. _freeze(): void;
  26065. /** @hidden */
  26066. _unFreeze(): void;
  26067. /**
  26068. * Gets the current world matrix
  26069. * @returns a Matrix
  26070. */
  26071. getWorldMatrix(): Matrix;
  26072. /** @hidden */
  26073. _getWorldMatrixDeterminant(): number;
  26074. /**
  26075. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26076. */
  26077. readonly isAnInstance: boolean;
  26078. /**
  26079. * Gets a boolean indicating if this mesh has instances
  26080. */
  26081. readonly hasInstances: boolean;
  26082. /**
  26083. * Perform relative position change from the point of view of behind the front of the mesh.
  26084. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26085. * Supports definition of mesh facing forward or backward
  26086. * @param amountRight defines the distance on the right axis
  26087. * @param amountUp defines the distance on the up axis
  26088. * @param amountForward defines the distance on the forward axis
  26089. * @returns the current mesh
  26090. */
  26091. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26092. /**
  26093. * Calculate relative position change from the point of view of behind the front of the mesh.
  26094. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26095. * Supports definition of mesh facing forward or backward
  26096. * @param amountRight defines the distance on the right axis
  26097. * @param amountUp defines the distance on the up axis
  26098. * @param amountForward defines the distance on the forward axis
  26099. * @returns the new displacement vector
  26100. */
  26101. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26102. /**
  26103. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26104. * Supports definition of mesh facing forward or backward
  26105. * @param flipBack defines the flip
  26106. * @param twirlClockwise defines the twirl
  26107. * @param tiltRight defines the tilt
  26108. * @returns the current mesh
  26109. */
  26110. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26111. /**
  26112. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26113. * Supports definition of mesh facing forward or backward.
  26114. * @param flipBack defines the flip
  26115. * @param twirlClockwise defines the twirl
  26116. * @param tiltRight defines the tilt
  26117. * @returns the new rotation vector
  26118. */
  26119. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26120. /**
  26121. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26122. * This means the mesh underlying bounding box and sphere are recomputed.
  26123. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26124. * @returns the current mesh
  26125. */
  26126. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26127. /** @hidden */
  26128. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26129. /** @hidden */
  26130. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26131. /** @hidden */
  26132. _updateBoundingInfo(): AbstractMesh;
  26133. /** @hidden */
  26134. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26135. /** @hidden */
  26136. protected _afterComputeWorldMatrix(): void;
  26137. /** @hidden */
  26138. readonly _effectiveMesh: AbstractMesh;
  26139. /**
  26140. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26141. * A mesh is in the frustum if its bounding box intersects the frustum
  26142. * @param frustumPlanes defines the frustum to test
  26143. * @returns true if the mesh is in the frustum planes
  26144. */
  26145. isInFrustum(frustumPlanes: Plane[]): boolean;
  26146. /**
  26147. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26148. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26149. * @param frustumPlanes defines the frustum to test
  26150. * @returns true if the mesh is completely in the frustum planes
  26151. */
  26152. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26153. /**
  26154. * True if the mesh intersects another mesh or a SolidParticle object
  26155. * @param mesh defines a target mesh or SolidParticle to test
  26156. * @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)
  26157. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26158. * @returns true if there is an intersection
  26159. */
  26160. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26161. /**
  26162. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26163. * @param point defines the point to test
  26164. * @returns true if there is an intersection
  26165. */
  26166. intersectsPoint(point: Vector3): boolean;
  26167. /**
  26168. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26170. */
  26171. checkCollisions: boolean;
  26172. /**
  26173. * Gets Collider object used to compute collisions (not physics)
  26174. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26175. */
  26176. readonly collider: Nullable<Collider>;
  26177. /**
  26178. * Move the mesh using collision engine
  26179. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26180. * @param displacement defines the requested displacement vector
  26181. * @returns the current mesh
  26182. */
  26183. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26184. private _onCollisionPositionChange;
  26185. /** @hidden */
  26186. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26187. /** @hidden */
  26188. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26189. /** @hidden */
  26190. _checkCollision(collider: Collider): AbstractMesh;
  26191. /** @hidden */
  26192. _generatePointsArray(): boolean;
  26193. /**
  26194. * Checks if the passed Ray intersects with the mesh
  26195. * @param ray defines the ray to use
  26196. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26198. * @returns the picking info
  26199. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26200. */
  26201. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26202. /**
  26203. * Clones the current mesh
  26204. * @param name defines the mesh name
  26205. * @param newParent defines the new mesh parent
  26206. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26207. * @returns the new mesh
  26208. */
  26209. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26210. /**
  26211. * Disposes all the submeshes of the current meshnp
  26212. * @returns the current mesh
  26213. */
  26214. releaseSubMeshes(): AbstractMesh;
  26215. /**
  26216. * Releases resources associated with this abstract mesh.
  26217. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26218. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26219. */
  26220. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26221. /**
  26222. * Adds the passed mesh as a child to the current mesh
  26223. * @param mesh defines the child mesh
  26224. * @returns the current mesh
  26225. */
  26226. addChild(mesh: AbstractMesh): AbstractMesh;
  26227. /**
  26228. * Removes the passed mesh from the current mesh children list
  26229. * @param mesh defines the child mesh
  26230. * @returns the current mesh
  26231. */
  26232. removeChild(mesh: AbstractMesh): AbstractMesh;
  26233. /** @hidden */
  26234. private _initFacetData;
  26235. /**
  26236. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26237. * This method can be called within the render loop.
  26238. * 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
  26239. * @returns the current mesh
  26240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26241. */
  26242. updateFacetData(): AbstractMesh;
  26243. /**
  26244. * Returns the facetLocalNormals array.
  26245. * The normals are expressed in the mesh local spac
  26246. * @returns an array of Vector3
  26247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26248. */
  26249. getFacetLocalNormals(): Vector3[];
  26250. /**
  26251. * Returns the facetLocalPositions array.
  26252. * The facet positions are expressed in the mesh local space
  26253. * @returns an array of Vector3
  26254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26255. */
  26256. getFacetLocalPositions(): Vector3[];
  26257. /**
  26258. * Returns the facetLocalPartioning array
  26259. * @returns an array of array of numbers
  26260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26261. */
  26262. getFacetLocalPartitioning(): number[][];
  26263. /**
  26264. * Returns the i-th facet position in the world system.
  26265. * This method allocates a new Vector3 per call
  26266. * @param i defines the facet index
  26267. * @returns a new Vector3
  26268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26269. */
  26270. getFacetPosition(i: number): Vector3;
  26271. /**
  26272. * Sets the reference Vector3 with the i-th facet position in the world system
  26273. * @param i defines the facet index
  26274. * @param ref defines the target vector
  26275. * @returns the current mesh
  26276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26277. */
  26278. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26279. /**
  26280. * Returns the i-th facet normal in the world system.
  26281. * This method allocates a new Vector3 per call
  26282. * @param i defines the facet index
  26283. * @returns a new Vector3
  26284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26285. */
  26286. getFacetNormal(i: number): Vector3;
  26287. /**
  26288. * Sets the reference Vector3 with the i-th facet normal in the world system
  26289. * @param i defines the facet index
  26290. * @param ref defines the target vector
  26291. * @returns the current mesh
  26292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26293. */
  26294. getFacetNormalToRef(i: number, ref: Vector3): this;
  26295. /**
  26296. * 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)
  26297. * @param x defines x coordinate
  26298. * @param y defines y coordinate
  26299. * @param z defines z coordinate
  26300. * @returns the array of facet indexes
  26301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26302. */
  26303. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26304. /**
  26305. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26306. * @param projected sets as the (x,y,z) world projection on the facet
  26307. * @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
  26308. * @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
  26309. * @param x defines x coordinate
  26310. * @param y defines y coordinate
  26311. * @param z defines z coordinate
  26312. * @returns the face index if found (or null instead)
  26313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26314. */
  26315. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26316. /**
  26317. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26318. * @param projected sets as the (x,y,z) local projection on the facet
  26319. * @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
  26320. * @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
  26321. * @param x defines x coordinate
  26322. * @param y defines y coordinate
  26323. * @param z defines z coordinate
  26324. * @returns the face index if found (or null instead)
  26325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26326. */
  26327. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26328. /**
  26329. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26330. * @returns the parameters
  26331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26332. */
  26333. getFacetDataParameters(): any;
  26334. /**
  26335. * Disables the feature FacetData and frees the related memory
  26336. * @returns the current mesh
  26337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26338. */
  26339. disableFacetData(): AbstractMesh;
  26340. /**
  26341. * Updates the AbstractMesh indices array
  26342. * @param indices defines the data source
  26343. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26344. * @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)
  26345. * @returns the current mesh
  26346. */
  26347. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26348. /**
  26349. * Creates new normals data for the mesh
  26350. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26351. * @returns the current mesh
  26352. */
  26353. createNormals(updatable: boolean): AbstractMesh;
  26354. /**
  26355. * Align the mesh with a normal
  26356. * @param normal defines the normal to use
  26357. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26358. * @returns the current mesh
  26359. */
  26360. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26361. /** @hidden */
  26362. _checkOcclusionQuery(): boolean;
  26363. /**
  26364. * Disables the mesh edge rendering mode
  26365. * @returns the currentAbstractMesh
  26366. */
  26367. disableEdgesRendering(): AbstractMesh;
  26368. /**
  26369. * Enables the edge rendering mode on the mesh.
  26370. * This mode makes the mesh edges visible
  26371. * @param epsilon defines the maximal distance between two angles to detect a face
  26372. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26373. * @returns the currentAbstractMesh
  26374. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26375. */
  26376. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26377. }
  26378. }
  26379. declare module BABYLON {
  26380. /**
  26381. * Interface used to define ActionEvent
  26382. */
  26383. export interface IActionEvent {
  26384. /** The mesh or sprite that triggered the action */
  26385. source: any;
  26386. /** The X mouse cursor position at the time of the event */
  26387. pointerX: number;
  26388. /** The Y mouse cursor position at the time of the event */
  26389. pointerY: number;
  26390. /** The mesh that is currently pointed at (can be null) */
  26391. meshUnderPointer: Nullable<AbstractMesh>;
  26392. /** the original (browser) event that triggered the ActionEvent */
  26393. sourceEvent?: any;
  26394. /** additional data for the event */
  26395. additionalData?: any;
  26396. }
  26397. /**
  26398. * ActionEvent is the event being sent when an action is triggered.
  26399. */
  26400. export class ActionEvent implements IActionEvent {
  26401. /** The mesh or sprite that triggered the action */
  26402. source: any;
  26403. /** The X mouse cursor position at the time of the event */
  26404. pointerX: number;
  26405. /** The Y mouse cursor position at the time of the event */
  26406. pointerY: number;
  26407. /** The mesh that is currently pointed at (can be null) */
  26408. meshUnderPointer: Nullable<AbstractMesh>;
  26409. /** the original (browser) event that triggered the ActionEvent */
  26410. sourceEvent?: any;
  26411. /** additional data for the event */
  26412. additionalData?: any;
  26413. /**
  26414. * Creates a new ActionEvent
  26415. * @param source The mesh or sprite that triggered the action
  26416. * @param pointerX The X mouse cursor position at the time of the event
  26417. * @param pointerY The Y mouse cursor position at the time of the event
  26418. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26419. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26420. * @param additionalData additional data for the event
  26421. */
  26422. constructor(
  26423. /** The mesh or sprite that triggered the action */
  26424. source: any,
  26425. /** The X mouse cursor position at the time of the event */
  26426. pointerX: number,
  26427. /** The Y mouse cursor position at the time of the event */
  26428. pointerY: number,
  26429. /** The mesh that is currently pointed at (can be null) */
  26430. meshUnderPointer: Nullable<AbstractMesh>,
  26431. /** the original (browser) event that triggered the ActionEvent */
  26432. sourceEvent?: any,
  26433. /** additional data for the event */
  26434. additionalData?: any);
  26435. /**
  26436. * Helper function to auto-create an ActionEvent from a source mesh.
  26437. * @param source The source mesh that triggered the event
  26438. * @param evt The original (browser) event
  26439. * @param additionalData additional data for the event
  26440. * @returns the new ActionEvent
  26441. */
  26442. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26443. /**
  26444. * Helper function to auto-create an ActionEvent from a source sprite
  26445. * @param source The source sprite that triggered the event
  26446. * @param scene Scene associated with the sprite
  26447. * @param evt The original (browser) event
  26448. * @param additionalData additional data for the event
  26449. * @returns the new ActionEvent
  26450. */
  26451. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26452. /**
  26453. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26454. * @param scene the scene where the event occurred
  26455. * @param evt The original (browser) event
  26456. * @returns the new ActionEvent
  26457. */
  26458. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26459. /**
  26460. * Helper function to auto-create an ActionEvent from a primitive
  26461. * @param prim defines the target primitive
  26462. * @param pointerPos defines the pointer position
  26463. * @param evt The original (browser) event
  26464. * @param additionalData additional data for the event
  26465. * @returns the new ActionEvent
  26466. */
  26467. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26468. }
  26469. }
  26470. declare module BABYLON {
  26471. /**
  26472. * Abstract class used to decouple action Manager from scene and meshes.
  26473. * Do not instantiate.
  26474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26475. */
  26476. export abstract class AbstractActionManager implements IDisposable {
  26477. /** Gets the list of active triggers */
  26478. static Triggers: {
  26479. [key: string]: number;
  26480. };
  26481. /** Gets the cursor to use when hovering items */
  26482. hoverCursor: string;
  26483. /** Gets the list of actions */
  26484. actions: IAction[];
  26485. /**
  26486. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26487. */
  26488. isRecursive: boolean;
  26489. /**
  26490. * Releases all associated resources
  26491. */
  26492. abstract dispose(): void;
  26493. /**
  26494. * Does this action manager has pointer triggers
  26495. */
  26496. abstract readonly hasPointerTriggers: boolean;
  26497. /**
  26498. * Does this action manager has pick triggers
  26499. */
  26500. abstract readonly hasPickTriggers: boolean;
  26501. /**
  26502. * Process a specific trigger
  26503. * @param trigger defines the trigger to process
  26504. * @param evt defines the event details to be processed
  26505. */
  26506. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26507. /**
  26508. * Does this action manager handles actions of any of the given triggers
  26509. * @param triggers defines the triggers to be tested
  26510. * @return a boolean indicating whether one (or more) of the triggers is handled
  26511. */
  26512. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26513. /**
  26514. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26515. * speed.
  26516. * @param triggerA defines the trigger to be tested
  26517. * @param triggerB defines the trigger to be tested
  26518. * @return a boolean indicating whether one (or more) of the triggers is handled
  26519. */
  26520. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26521. /**
  26522. * Does this action manager handles actions of a given trigger
  26523. * @param trigger defines the trigger to be tested
  26524. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26525. * @return whether the trigger is handled
  26526. */
  26527. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26528. /**
  26529. * Serialize this manager to a JSON object
  26530. * @param name defines the property name to store this manager
  26531. * @returns a JSON representation of this manager
  26532. */
  26533. abstract serialize(name: string): any;
  26534. /**
  26535. * Registers an action to this action manager
  26536. * @param action defines the action to be registered
  26537. * @return the action amended (prepared) after registration
  26538. */
  26539. abstract registerAction(action: IAction): Nullable<IAction>;
  26540. /**
  26541. * Unregisters an action to this action manager
  26542. * @param action defines the action to be unregistered
  26543. * @return a boolean indicating whether the action has been unregistered
  26544. */
  26545. abstract unregisterAction(action: IAction): Boolean;
  26546. /**
  26547. * Does exist one action manager with at least one trigger
  26548. **/
  26549. static readonly HasTriggers: boolean;
  26550. /**
  26551. * Does exist one action manager with at least one pick trigger
  26552. **/
  26553. static readonly HasPickTriggers: boolean;
  26554. /**
  26555. * Does exist one action manager that handles actions of a given trigger
  26556. * @param trigger defines the trigger to be tested
  26557. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26558. **/
  26559. static HasSpecificTrigger(trigger: number): boolean;
  26560. }
  26561. }
  26562. declare module BABYLON {
  26563. /**
  26564. * Defines how a node can be built from a string name.
  26565. */
  26566. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26567. /**
  26568. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26569. */
  26570. export class Node implements IBehaviorAware<Node> {
  26571. /** @hidden */
  26572. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26573. private static _NodeConstructors;
  26574. /**
  26575. * Add a new node constructor
  26576. * @param type defines the type name of the node to construct
  26577. * @param constructorFunc defines the constructor function
  26578. */
  26579. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26580. /**
  26581. * Returns a node constructor based on type name
  26582. * @param type defines the type name
  26583. * @param name defines the new node name
  26584. * @param scene defines the hosting scene
  26585. * @param options defines optional options to transmit to constructors
  26586. * @returns the new constructor or null
  26587. */
  26588. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26589. /**
  26590. * Gets or sets the name of the node
  26591. */
  26592. name: string;
  26593. /**
  26594. * Gets or sets the id of the node
  26595. */
  26596. id: string;
  26597. /**
  26598. * Gets or sets the unique id of the node
  26599. */
  26600. uniqueId: number;
  26601. /**
  26602. * Gets or sets a string used to store user defined state for the node
  26603. */
  26604. state: string;
  26605. /**
  26606. * Gets or sets an object used to store user defined information for the node
  26607. */
  26608. metadata: any;
  26609. /**
  26610. * For internal use only. Please do not use.
  26611. */
  26612. reservedDataStore: any;
  26613. /**
  26614. * List of inspectable custom properties (used by the Inspector)
  26615. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26616. */
  26617. inspectableCustomProperties: IInspectable[];
  26618. /**
  26619. * Gets or sets a boolean used to define if the node must be serialized
  26620. */
  26621. doNotSerialize: boolean;
  26622. /** @hidden */
  26623. _isDisposed: boolean;
  26624. /**
  26625. * Gets a list of Animations associated with the node
  26626. */
  26627. animations: Animation[];
  26628. protected _ranges: {
  26629. [name: string]: Nullable<AnimationRange>;
  26630. };
  26631. /**
  26632. * Callback raised when the node is ready to be used
  26633. */
  26634. onReady: Nullable<(node: Node) => void>;
  26635. private _isEnabled;
  26636. private _isParentEnabled;
  26637. private _isReady;
  26638. /** @hidden */
  26639. _currentRenderId: number;
  26640. private _parentUpdateId;
  26641. /** @hidden */
  26642. _childUpdateId: number;
  26643. /** @hidden */
  26644. _waitingParentId: Nullable<string>;
  26645. /** @hidden */
  26646. _scene: Scene;
  26647. /** @hidden */
  26648. _cache: any;
  26649. private _parentNode;
  26650. private _children;
  26651. /** @hidden */
  26652. _worldMatrix: Matrix;
  26653. /** @hidden */
  26654. _worldMatrixDeterminant: number;
  26655. /** @hidden */
  26656. _worldMatrixDeterminantIsDirty: boolean;
  26657. /** @hidden */
  26658. private _sceneRootNodesIndex;
  26659. /**
  26660. * Gets a boolean indicating if the node has been disposed
  26661. * @returns true if the node was disposed
  26662. */
  26663. isDisposed(): boolean;
  26664. /**
  26665. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26666. * @see https://doc.babylonjs.com/how_to/parenting
  26667. */
  26668. parent: Nullable<Node>;
  26669. private addToSceneRootNodes;
  26670. private removeFromSceneRootNodes;
  26671. private _animationPropertiesOverride;
  26672. /**
  26673. * Gets or sets the animation properties override
  26674. */
  26675. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26676. /**
  26677. * Gets a string idenfifying the name of the class
  26678. * @returns "Node" string
  26679. */
  26680. getClassName(): string;
  26681. /** @hidden */
  26682. readonly _isNode: boolean;
  26683. /**
  26684. * An event triggered when the mesh is disposed
  26685. */
  26686. onDisposeObservable: Observable<Node>;
  26687. private _onDisposeObserver;
  26688. /**
  26689. * Sets a callback that will be raised when the node will be disposed
  26690. */
  26691. onDispose: () => void;
  26692. /**
  26693. * Creates a new Node
  26694. * @param name the name and id to be given to this node
  26695. * @param scene the scene this node will be added to
  26696. * @param addToRootNodes the node will be added to scene.rootNodes
  26697. */
  26698. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26699. /**
  26700. * Gets the scene of the node
  26701. * @returns a scene
  26702. */
  26703. getScene(): Scene;
  26704. /**
  26705. * Gets the engine of the node
  26706. * @returns a Engine
  26707. */
  26708. getEngine(): Engine;
  26709. private _behaviors;
  26710. /**
  26711. * Attach a behavior to the node
  26712. * @see http://doc.babylonjs.com/features/behaviour
  26713. * @param behavior defines the behavior to attach
  26714. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26715. * @returns the current Node
  26716. */
  26717. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26718. /**
  26719. * Remove an attached behavior
  26720. * @see http://doc.babylonjs.com/features/behaviour
  26721. * @param behavior defines the behavior to attach
  26722. * @returns the current Node
  26723. */
  26724. removeBehavior(behavior: Behavior<Node>): Node;
  26725. /**
  26726. * Gets the list of attached behaviors
  26727. * @see http://doc.babylonjs.com/features/behaviour
  26728. */
  26729. readonly behaviors: Behavior<Node>[];
  26730. /**
  26731. * Gets an attached behavior by name
  26732. * @param name defines the name of the behavior to look for
  26733. * @see http://doc.babylonjs.com/features/behaviour
  26734. * @returns null if behavior was not found else the requested behavior
  26735. */
  26736. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26737. /**
  26738. * Returns the latest update of the World matrix
  26739. * @returns a Matrix
  26740. */
  26741. getWorldMatrix(): Matrix;
  26742. /** @hidden */
  26743. _getWorldMatrixDeterminant(): number;
  26744. /**
  26745. * Returns directly the latest state of the mesh World matrix.
  26746. * A Matrix is returned.
  26747. */
  26748. readonly worldMatrixFromCache: Matrix;
  26749. /** @hidden */
  26750. _initCache(): void;
  26751. /** @hidden */
  26752. updateCache(force?: boolean): void;
  26753. /** @hidden */
  26754. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26755. /** @hidden */
  26756. _updateCache(ignoreParentClass?: boolean): void;
  26757. /** @hidden */
  26758. _isSynchronized(): boolean;
  26759. /** @hidden */
  26760. _markSyncedWithParent(): void;
  26761. /** @hidden */
  26762. isSynchronizedWithParent(): boolean;
  26763. /** @hidden */
  26764. isSynchronized(): boolean;
  26765. /**
  26766. * Is this node ready to be used/rendered
  26767. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26768. * @return true if the node is ready
  26769. */
  26770. isReady(completeCheck?: boolean): boolean;
  26771. /**
  26772. * Is this node enabled?
  26773. * 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
  26774. * @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
  26775. * @return whether this node (and its parent) is enabled
  26776. */
  26777. isEnabled(checkAncestors?: boolean): boolean;
  26778. /** @hidden */
  26779. protected _syncParentEnabledState(): void;
  26780. /**
  26781. * Set the enabled state of this node
  26782. * @param value defines the new enabled state
  26783. */
  26784. setEnabled(value: boolean): void;
  26785. /**
  26786. * Is this node a descendant of the given node?
  26787. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26788. * @param ancestor defines the parent node to inspect
  26789. * @returns a boolean indicating if this node is a descendant of the given node
  26790. */
  26791. isDescendantOf(ancestor: Node): boolean;
  26792. /** @hidden */
  26793. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26794. /**
  26795. * Will return all nodes that have this node as ascendant
  26796. * @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
  26797. * @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
  26798. * @return all children nodes of all types
  26799. */
  26800. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26801. /**
  26802. * Get all child-meshes of this node
  26803. * @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)
  26804. * @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
  26805. * @returns an array of AbstractMesh
  26806. */
  26807. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26808. /**
  26809. * Get all direct children of this node
  26810. * @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
  26811. * @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)
  26812. * @returns an array of Node
  26813. */
  26814. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26815. /** @hidden */
  26816. _setReady(state: boolean): void;
  26817. /**
  26818. * Get an animation by name
  26819. * @param name defines the name of the animation to look for
  26820. * @returns null if not found else the requested animation
  26821. */
  26822. getAnimationByName(name: string): Nullable<Animation>;
  26823. /**
  26824. * Creates an animation range for this node
  26825. * @param name defines the name of the range
  26826. * @param from defines the starting key
  26827. * @param to defines the end key
  26828. */
  26829. createAnimationRange(name: string, from: number, to: number): void;
  26830. /**
  26831. * Delete a specific animation range
  26832. * @param name defines the name of the range to delete
  26833. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26834. */
  26835. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26836. /**
  26837. * Get an animation range by name
  26838. * @param name defines the name of the animation range to look for
  26839. * @returns null if not found else the requested animation range
  26840. */
  26841. getAnimationRange(name: string): Nullable<AnimationRange>;
  26842. /**
  26843. * Gets the list of all animation ranges defined on this node
  26844. * @returns an array
  26845. */
  26846. getAnimationRanges(): Nullable<AnimationRange>[];
  26847. /**
  26848. * Will start the animation sequence
  26849. * @param name defines the range frames for animation sequence
  26850. * @param loop defines if the animation should loop (false by default)
  26851. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26852. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26853. * @returns the object created for this animation. If range does not exist, it will return null
  26854. */
  26855. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26856. /**
  26857. * Serialize animation ranges into a JSON compatible object
  26858. * @returns serialization object
  26859. */
  26860. serializeAnimationRanges(): any;
  26861. /**
  26862. * Computes the world matrix of the node
  26863. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26864. * @returns the world matrix
  26865. */
  26866. computeWorldMatrix(force?: boolean): Matrix;
  26867. /**
  26868. * Releases resources associated with this node.
  26869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26871. */
  26872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26873. /**
  26874. * Parse animation range data from a serialization object and store them into a given node
  26875. * @param node defines where to store the animation ranges
  26876. * @param parsedNode defines the serialization object to read data from
  26877. * @param scene defines the hosting scene
  26878. */
  26879. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26880. /**
  26881. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26882. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26883. * @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
  26884. * @returns the new bounding vectors
  26885. */
  26886. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26887. min: Vector3;
  26888. max: Vector3;
  26889. };
  26890. }
  26891. }
  26892. declare module BABYLON {
  26893. /**
  26894. * @hidden
  26895. */
  26896. export class _IAnimationState {
  26897. key: number;
  26898. repeatCount: number;
  26899. workValue?: any;
  26900. loopMode?: number;
  26901. offsetValue?: any;
  26902. highLimitValue?: any;
  26903. }
  26904. /**
  26905. * Class used to store any kind of animation
  26906. */
  26907. export class Animation {
  26908. /**Name of the animation */
  26909. name: string;
  26910. /**Property to animate */
  26911. targetProperty: string;
  26912. /**The frames per second of the animation */
  26913. framePerSecond: number;
  26914. /**The data type of the animation */
  26915. dataType: number;
  26916. /**The loop mode of the animation */
  26917. loopMode?: number | undefined;
  26918. /**Specifies if blending should be enabled */
  26919. enableBlending?: boolean | undefined;
  26920. /**
  26921. * Use matrix interpolation instead of using direct key value when animating matrices
  26922. */
  26923. static AllowMatricesInterpolation: boolean;
  26924. /**
  26925. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26926. */
  26927. static AllowMatrixDecomposeForInterpolation: boolean;
  26928. /**
  26929. * Stores the key frames of the animation
  26930. */
  26931. private _keys;
  26932. /**
  26933. * Stores the easing function of the animation
  26934. */
  26935. private _easingFunction;
  26936. /**
  26937. * @hidden Internal use only
  26938. */
  26939. _runtimeAnimations: RuntimeAnimation[];
  26940. /**
  26941. * The set of event that will be linked to this animation
  26942. */
  26943. private _events;
  26944. /**
  26945. * Stores an array of target property paths
  26946. */
  26947. targetPropertyPath: string[];
  26948. /**
  26949. * Stores the blending speed of the animation
  26950. */
  26951. blendingSpeed: number;
  26952. /**
  26953. * Stores the animation ranges for the animation
  26954. */
  26955. private _ranges;
  26956. /**
  26957. * @hidden Internal use
  26958. */
  26959. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26960. /**
  26961. * Sets up an animation
  26962. * @param property The property to animate
  26963. * @param animationType The animation type to apply
  26964. * @param framePerSecond The frames per second of the animation
  26965. * @param easingFunction The easing function used in the animation
  26966. * @returns The created animation
  26967. */
  26968. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26969. /**
  26970. * Create and start an animation on a node
  26971. * @param name defines the name of the global animation that will be run on all nodes
  26972. * @param node defines the root node where the animation will take place
  26973. * @param targetProperty defines property to animate
  26974. * @param framePerSecond defines the number of frame per second yo use
  26975. * @param totalFrame defines the number of frames in total
  26976. * @param from defines the initial value
  26977. * @param to defines the final value
  26978. * @param loopMode defines which loop mode you want to use (off by default)
  26979. * @param easingFunction defines the easing function to use (linear by default)
  26980. * @param onAnimationEnd defines the callback to call when animation end
  26981. * @returns the animatable created for this animation
  26982. */
  26983. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26984. /**
  26985. * Create and start an animation on a node and its descendants
  26986. * @param name defines the name of the global animation that will be run on all nodes
  26987. * @param node defines the root node where the animation will take place
  26988. * @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
  26989. * @param targetProperty defines property to animate
  26990. * @param framePerSecond defines the number of frame per second to use
  26991. * @param totalFrame defines the number of frames in total
  26992. * @param from defines the initial value
  26993. * @param to defines the final value
  26994. * @param loopMode defines which loop mode you want to use (off by default)
  26995. * @param easingFunction defines the easing function to use (linear by default)
  26996. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26997. * @returns the list of animatables created for all nodes
  26998. * @example https://www.babylonjs-playground.com/#MH0VLI
  26999. */
  27000. 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[]>;
  27001. /**
  27002. * Creates a new animation, merges it with the existing animations and starts it
  27003. * @param name Name of the animation
  27004. * @param node Node which contains the scene that begins the animations
  27005. * @param targetProperty Specifies which property to animate
  27006. * @param framePerSecond The frames per second of the animation
  27007. * @param totalFrame The total number of frames
  27008. * @param from The frame at the beginning of the animation
  27009. * @param to The frame at the end of the animation
  27010. * @param loopMode Specifies the loop mode of the animation
  27011. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27012. * @param onAnimationEnd Callback to run once the animation is complete
  27013. * @returns Nullable animation
  27014. */
  27015. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27016. /**
  27017. * Transition property of an host to the target Value
  27018. * @param property The property to transition
  27019. * @param targetValue The target Value of the property
  27020. * @param host The object where the property to animate belongs
  27021. * @param scene Scene used to run the animation
  27022. * @param frameRate Framerate (in frame/s) to use
  27023. * @param transition The transition type we want to use
  27024. * @param duration The duration of the animation, in milliseconds
  27025. * @param onAnimationEnd Callback trigger at the end of the animation
  27026. * @returns Nullable animation
  27027. */
  27028. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27029. /**
  27030. * Return the array of runtime animations currently using this animation
  27031. */
  27032. readonly runtimeAnimations: RuntimeAnimation[];
  27033. /**
  27034. * Specifies if any of the runtime animations are currently running
  27035. */
  27036. readonly hasRunningRuntimeAnimations: boolean;
  27037. /**
  27038. * Initializes the animation
  27039. * @param name Name of the animation
  27040. * @param targetProperty Property to animate
  27041. * @param framePerSecond The frames per second of the animation
  27042. * @param dataType The data type of the animation
  27043. * @param loopMode The loop mode of the animation
  27044. * @param enableBlending Specifies if blending should be enabled
  27045. */
  27046. constructor(
  27047. /**Name of the animation */
  27048. name: string,
  27049. /**Property to animate */
  27050. targetProperty: string,
  27051. /**The frames per second of the animation */
  27052. framePerSecond: number,
  27053. /**The data type of the animation */
  27054. dataType: number,
  27055. /**The loop mode of the animation */
  27056. loopMode?: number | undefined,
  27057. /**Specifies if blending should be enabled */
  27058. enableBlending?: boolean | undefined);
  27059. /**
  27060. * Converts the animation to a string
  27061. * @param fullDetails support for multiple levels of logging within scene loading
  27062. * @returns String form of the animation
  27063. */
  27064. toString(fullDetails?: boolean): string;
  27065. /**
  27066. * Add an event to this animation
  27067. * @param event Event to add
  27068. */
  27069. addEvent(event: AnimationEvent): void;
  27070. /**
  27071. * Remove all events found at the given frame
  27072. * @param frame The frame to remove events from
  27073. */
  27074. removeEvents(frame: number): void;
  27075. /**
  27076. * Retrieves all the events from the animation
  27077. * @returns Events from the animation
  27078. */
  27079. getEvents(): AnimationEvent[];
  27080. /**
  27081. * Creates an animation range
  27082. * @param name Name of the animation range
  27083. * @param from Starting frame of the animation range
  27084. * @param to Ending frame of the animation
  27085. */
  27086. createRange(name: string, from: number, to: number): void;
  27087. /**
  27088. * Deletes an animation range by name
  27089. * @param name Name of the animation range to delete
  27090. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27091. */
  27092. deleteRange(name: string, deleteFrames?: boolean): void;
  27093. /**
  27094. * Gets the animation range by name, or null if not defined
  27095. * @param name Name of the animation range
  27096. * @returns Nullable animation range
  27097. */
  27098. getRange(name: string): Nullable<AnimationRange>;
  27099. /**
  27100. * Gets the key frames from the animation
  27101. * @returns The key frames of the animation
  27102. */
  27103. getKeys(): Array<IAnimationKey>;
  27104. /**
  27105. * Gets the highest frame rate of the animation
  27106. * @returns Highest frame rate of the animation
  27107. */
  27108. getHighestFrame(): number;
  27109. /**
  27110. * Gets the easing function of the animation
  27111. * @returns Easing function of the animation
  27112. */
  27113. getEasingFunction(): IEasingFunction;
  27114. /**
  27115. * Sets the easing function of the animation
  27116. * @param easingFunction A custom mathematical formula for animation
  27117. */
  27118. setEasingFunction(easingFunction: EasingFunction): void;
  27119. /**
  27120. * Interpolates a scalar linearly
  27121. * @param startValue Start value of the animation curve
  27122. * @param endValue End value of the animation curve
  27123. * @param gradient Scalar amount to interpolate
  27124. * @returns Interpolated scalar value
  27125. */
  27126. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27127. /**
  27128. * Interpolates a scalar cubically
  27129. * @param startValue Start value of the animation curve
  27130. * @param outTangent End tangent of the animation
  27131. * @param endValue End value of the animation curve
  27132. * @param inTangent Start tangent of the animation curve
  27133. * @param gradient Scalar amount to interpolate
  27134. * @returns Interpolated scalar value
  27135. */
  27136. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27137. /**
  27138. * Interpolates a quaternion using a spherical linear interpolation
  27139. * @param startValue Start value of the animation curve
  27140. * @param endValue End value of the animation curve
  27141. * @param gradient Scalar amount to interpolate
  27142. * @returns Interpolated quaternion value
  27143. */
  27144. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27145. /**
  27146. * Interpolates a quaternion cubically
  27147. * @param startValue Start value of the animation curve
  27148. * @param outTangent End tangent of the animation curve
  27149. * @param endValue End value of the animation curve
  27150. * @param inTangent Start tangent of the animation curve
  27151. * @param gradient Scalar amount to interpolate
  27152. * @returns Interpolated quaternion value
  27153. */
  27154. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27155. /**
  27156. * Interpolates a Vector3 linearl
  27157. * @param startValue Start value of the animation curve
  27158. * @param endValue End value of the animation curve
  27159. * @param gradient Scalar amount to interpolate
  27160. * @returns Interpolated scalar value
  27161. */
  27162. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27163. /**
  27164. * Interpolates a Vector3 cubically
  27165. * @param startValue Start value of the animation curve
  27166. * @param outTangent End tangent of the animation
  27167. * @param endValue End value of the animation curve
  27168. * @param inTangent Start tangent of the animation curve
  27169. * @param gradient Scalar amount to interpolate
  27170. * @returns InterpolatedVector3 value
  27171. */
  27172. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27173. /**
  27174. * Interpolates a Vector2 linearly
  27175. * @param startValue Start value of the animation curve
  27176. * @param endValue End value of the animation curve
  27177. * @param gradient Scalar amount to interpolate
  27178. * @returns Interpolated Vector2 value
  27179. */
  27180. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27181. /**
  27182. * Interpolates a Vector2 cubically
  27183. * @param startValue Start value of the animation curve
  27184. * @param outTangent End tangent of the animation
  27185. * @param endValue End value of the animation curve
  27186. * @param inTangent Start tangent of the animation curve
  27187. * @param gradient Scalar amount to interpolate
  27188. * @returns Interpolated Vector2 value
  27189. */
  27190. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27191. /**
  27192. * Interpolates a size linearly
  27193. * @param startValue Start value of the animation curve
  27194. * @param endValue End value of the animation curve
  27195. * @param gradient Scalar amount to interpolate
  27196. * @returns Interpolated Size value
  27197. */
  27198. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27199. /**
  27200. * Interpolates a Color3 linearly
  27201. * @param startValue Start value of the animation curve
  27202. * @param endValue End value of the animation curve
  27203. * @param gradient Scalar amount to interpolate
  27204. * @returns Interpolated Color3 value
  27205. */
  27206. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27207. /**
  27208. * @hidden Internal use only
  27209. */
  27210. _getKeyValue(value: any): any;
  27211. /**
  27212. * @hidden Internal use only
  27213. */
  27214. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27215. /**
  27216. * Defines the function to use to interpolate matrices
  27217. * @param startValue defines the start matrix
  27218. * @param endValue defines the end matrix
  27219. * @param gradient defines the gradient between both matrices
  27220. * @param result defines an optional target matrix where to store the interpolation
  27221. * @returns the interpolated matrix
  27222. */
  27223. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27224. /**
  27225. * Makes a copy of the animation
  27226. * @returns Cloned animation
  27227. */
  27228. clone(): Animation;
  27229. /**
  27230. * Sets the key frames of the animation
  27231. * @param values The animation key frames to set
  27232. */
  27233. setKeys(values: Array<IAnimationKey>): void;
  27234. /**
  27235. * Serializes the animation to an object
  27236. * @returns Serialized object
  27237. */
  27238. serialize(): any;
  27239. /**
  27240. * Float animation type
  27241. */
  27242. private static _ANIMATIONTYPE_FLOAT;
  27243. /**
  27244. * Vector3 animation type
  27245. */
  27246. private static _ANIMATIONTYPE_VECTOR3;
  27247. /**
  27248. * Quaternion animation type
  27249. */
  27250. private static _ANIMATIONTYPE_QUATERNION;
  27251. /**
  27252. * Matrix animation type
  27253. */
  27254. private static _ANIMATIONTYPE_MATRIX;
  27255. /**
  27256. * Color3 animation type
  27257. */
  27258. private static _ANIMATIONTYPE_COLOR3;
  27259. /**
  27260. * Vector2 animation type
  27261. */
  27262. private static _ANIMATIONTYPE_VECTOR2;
  27263. /**
  27264. * Size animation type
  27265. */
  27266. private static _ANIMATIONTYPE_SIZE;
  27267. /**
  27268. * Relative Loop Mode
  27269. */
  27270. private static _ANIMATIONLOOPMODE_RELATIVE;
  27271. /**
  27272. * Cycle Loop Mode
  27273. */
  27274. private static _ANIMATIONLOOPMODE_CYCLE;
  27275. /**
  27276. * Constant Loop Mode
  27277. */
  27278. private static _ANIMATIONLOOPMODE_CONSTANT;
  27279. /**
  27280. * Get the float animation type
  27281. */
  27282. static readonly ANIMATIONTYPE_FLOAT: number;
  27283. /**
  27284. * Get the Vector3 animation type
  27285. */
  27286. static readonly ANIMATIONTYPE_VECTOR3: number;
  27287. /**
  27288. * Get the Vector2 animation type
  27289. */
  27290. static readonly ANIMATIONTYPE_VECTOR2: number;
  27291. /**
  27292. * Get the Size animation type
  27293. */
  27294. static readonly ANIMATIONTYPE_SIZE: number;
  27295. /**
  27296. * Get the Quaternion animation type
  27297. */
  27298. static readonly ANIMATIONTYPE_QUATERNION: number;
  27299. /**
  27300. * Get the Matrix animation type
  27301. */
  27302. static readonly ANIMATIONTYPE_MATRIX: number;
  27303. /**
  27304. * Get the Color3 animation type
  27305. */
  27306. static readonly ANIMATIONTYPE_COLOR3: number;
  27307. /**
  27308. * Get the Relative Loop Mode
  27309. */
  27310. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27311. /**
  27312. * Get the Cycle Loop Mode
  27313. */
  27314. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27315. /**
  27316. * Get the Constant Loop Mode
  27317. */
  27318. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27319. /** @hidden */
  27320. static _UniversalLerp(left: any, right: any, amount: number): any;
  27321. /**
  27322. * Parses an animation object and creates an animation
  27323. * @param parsedAnimation Parsed animation object
  27324. * @returns Animation object
  27325. */
  27326. static Parse(parsedAnimation: any): Animation;
  27327. /**
  27328. * Appends the serialized animations from the source animations
  27329. * @param source Source containing the animations
  27330. * @param destination Target to store the animations
  27331. */
  27332. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27333. }
  27334. }
  27335. declare module BABYLON {
  27336. /**
  27337. * Interface containing an array of animations
  27338. */
  27339. export interface IAnimatable {
  27340. /**
  27341. * Array of animations
  27342. */
  27343. animations: Nullable<Array<Animation>>;
  27344. }
  27345. }
  27346. declare module BABYLON {
  27347. /**
  27348. * This represents all the required information to add a fresnel effect on a material:
  27349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27350. */
  27351. export class FresnelParameters {
  27352. private _isEnabled;
  27353. /**
  27354. * Define if the fresnel effect is enable or not.
  27355. */
  27356. isEnabled: boolean;
  27357. /**
  27358. * Define the color used on edges (grazing angle)
  27359. */
  27360. leftColor: Color3;
  27361. /**
  27362. * Define the color used on center
  27363. */
  27364. rightColor: Color3;
  27365. /**
  27366. * Define bias applied to computed fresnel term
  27367. */
  27368. bias: number;
  27369. /**
  27370. * Defined the power exponent applied to fresnel term
  27371. */
  27372. power: number;
  27373. /**
  27374. * Clones the current fresnel and its valuues
  27375. * @returns a clone fresnel configuration
  27376. */
  27377. clone(): FresnelParameters;
  27378. /**
  27379. * Serializes the current fresnel parameters to a JSON representation.
  27380. * @return the JSON serialization
  27381. */
  27382. serialize(): any;
  27383. /**
  27384. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27385. * @param parsedFresnelParameters Define the JSON representation
  27386. * @returns the parsed parameters
  27387. */
  27388. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27389. }
  27390. }
  27391. declare module BABYLON {
  27392. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27393. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27394. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27395. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27396. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27397. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27398. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27399. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27400. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27401. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27402. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27403. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27404. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27405. /**
  27406. * Decorator used to define property that can be serialized as reference to a camera
  27407. * @param sourceName defines the name of the property to decorate
  27408. */
  27409. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27410. /**
  27411. * Class used to help serialization objects
  27412. */
  27413. export class SerializationHelper {
  27414. /** @hidden */
  27415. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27416. /** @hidden */
  27417. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27418. /** @hidden */
  27419. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27420. /** @hidden */
  27421. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27422. /**
  27423. * Appends the serialized animations from the source animations
  27424. * @param source Source containing the animations
  27425. * @param destination Target to store the animations
  27426. */
  27427. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27428. /**
  27429. * Static function used to serialized a specific entity
  27430. * @param entity defines the entity to serialize
  27431. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27432. * @returns a JSON compatible object representing the serialization of the entity
  27433. */
  27434. static Serialize<T>(entity: T, serializationObject?: any): any;
  27435. /**
  27436. * Creates a new entity from a serialization data object
  27437. * @param creationFunction defines a function used to instanciated the new entity
  27438. * @param source defines the source serialization data
  27439. * @param scene defines the hosting scene
  27440. * @param rootUrl defines the root url for resources
  27441. * @returns a new entity
  27442. */
  27443. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27444. /**
  27445. * Clones an object
  27446. * @param creationFunction defines the function used to instanciate the new object
  27447. * @param source defines the source object
  27448. * @returns the cloned object
  27449. */
  27450. static Clone<T>(creationFunction: () => T, source: T): T;
  27451. /**
  27452. * Instanciates a new object based on a source one (some data will be shared between both object)
  27453. * @param creationFunction defines the function used to instanciate the new object
  27454. * @param source defines the source object
  27455. * @returns the new object
  27456. */
  27457. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27458. }
  27459. }
  27460. declare module BABYLON {
  27461. /**
  27462. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27463. */
  27464. export interface CubeMapInfo {
  27465. /**
  27466. * The pixel array for the front face.
  27467. * This is stored in format, left to right, up to down format.
  27468. */
  27469. front: Nullable<ArrayBufferView>;
  27470. /**
  27471. * The pixel array for the back face.
  27472. * This is stored in format, left to right, up to down format.
  27473. */
  27474. back: Nullable<ArrayBufferView>;
  27475. /**
  27476. * The pixel array for the left face.
  27477. * This is stored in format, left to right, up to down format.
  27478. */
  27479. left: Nullable<ArrayBufferView>;
  27480. /**
  27481. * The pixel array for the right face.
  27482. * This is stored in format, left to right, up to down format.
  27483. */
  27484. right: Nullable<ArrayBufferView>;
  27485. /**
  27486. * The pixel array for the up face.
  27487. * This is stored in format, left to right, up to down format.
  27488. */
  27489. up: Nullable<ArrayBufferView>;
  27490. /**
  27491. * The pixel array for the down face.
  27492. * This is stored in format, left to right, up to down format.
  27493. */
  27494. down: Nullable<ArrayBufferView>;
  27495. /**
  27496. * The size of the cubemap stored.
  27497. *
  27498. * Each faces will be size * size pixels.
  27499. */
  27500. size: number;
  27501. /**
  27502. * The format of the texture.
  27503. *
  27504. * RGBA, RGB.
  27505. */
  27506. format: number;
  27507. /**
  27508. * The type of the texture data.
  27509. *
  27510. * UNSIGNED_INT, FLOAT.
  27511. */
  27512. type: number;
  27513. /**
  27514. * Specifies whether the texture is in gamma space.
  27515. */
  27516. gammaSpace: boolean;
  27517. }
  27518. /**
  27519. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27520. */
  27521. export class PanoramaToCubeMapTools {
  27522. private static FACE_FRONT;
  27523. private static FACE_BACK;
  27524. private static FACE_RIGHT;
  27525. private static FACE_LEFT;
  27526. private static FACE_DOWN;
  27527. private static FACE_UP;
  27528. /**
  27529. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27530. *
  27531. * @param float32Array The source data.
  27532. * @param inputWidth The width of the input panorama.
  27533. * @param inputHeight The height of the input panorama.
  27534. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27535. * @return The cubemap data
  27536. */
  27537. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27538. private static CreateCubemapTexture;
  27539. private static CalcProjectionSpherical;
  27540. }
  27541. }
  27542. declare module BABYLON {
  27543. /**
  27544. * Helper class dealing with the extraction of spherical polynomial dataArray
  27545. * from a cube map.
  27546. */
  27547. export class CubeMapToSphericalPolynomialTools {
  27548. private static FileFaces;
  27549. /**
  27550. * Converts a texture to the according Spherical Polynomial data.
  27551. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27552. *
  27553. * @param texture The texture to extract the information from.
  27554. * @return The Spherical Polynomial data.
  27555. */
  27556. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27557. /**
  27558. * Converts a cubemap to the according Spherical Polynomial data.
  27559. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27560. *
  27561. * @param cubeInfo The Cube map to extract the information from.
  27562. * @return The Spherical Polynomial data.
  27563. */
  27564. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27565. }
  27566. }
  27567. declare module BABYLON {
  27568. /**
  27569. * Class used to manipulate GUIDs
  27570. */
  27571. export class GUID {
  27572. /**
  27573. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27574. * Be aware Math.random() could cause collisions, but:
  27575. * "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"
  27576. * @returns a pseudo random id
  27577. */
  27578. static RandomId(): string;
  27579. }
  27580. }
  27581. declare module BABYLON {
  27582. /**
  27583. * Base class of all the textures in babylon.
  27584. * It groups all the common properties the materials, post process, lights... might need
  27585. * in order to make a correct use of the texture.
  27586. */
  27587. export class BaseTexture implements IAnimatable {
  27588. /**
  27589. * Default anisotropic filtering level for the application.
  27590. * It is set to 4 as a good tradeoff between perf and quality.
  27591. */
  27592. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27593. /**
  27594. * Gets or sets the unique id of the texture
  27595. */
  27596. uniqueId: number;
  27597. /**
  27598. * Define the name of the texture.
  27599. */
  27600. name: string;
  27601. /**
  27602. * Gets or sets an object used to store user defined information.
  27603. */
  27604. metadata: any;
  27605. /**
  27606. * For internal use only. Please do not use.
  27607. */
  27608. reservedDataStore: any;
  27609. private _hasAlpha;
  27610. /**
  27611. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27612. */
  27613. hasAlpha: boolean;
  27614. /**
  27615. * Defines if the alpha value should be determined via the rgb values.
  27616. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27617. */
  27618. getAlphaFromRGB: boolean;
  27619. /**
  27620. * Intensity or strength of the texture.
  27621. * It is commonly used by materials to fine tune the intensity of the texture
  27622. */
  27623. level: number;
  27624. /**
  27625. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27626. * This is part of the texture as textures usually maps to one uv set.
  27627. */
  27628. coordinatesIndex: number;
  27629. private _coordinatesMode;
  27630. /**
  27631. * How a texture is mapped.
  27632. *
  27633. * | Value | Type | Description |
  27634. * | ----- | ----------------------------------- | ----------- |
  27635. * | 0 | EXPLICIT_MODE | |
  27636. * | 1 | SPHERICAL_MODE | |
  27637. * | 2 | PLANAR_MODE | |
  27638. * | 3 | CUBIC_MODE | |
  27639. * | 4 | PROJECTION_MODE | |
  27640. * | 5 | SKYBOX_MODE | |
  27641. * | 6 | INVCUBIC_MODE | |
  27642. * | 7 | EQUIRECTANGULAR_MODE | |
  27643. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27644. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27645. */
  27646. coordinatesMode: number;
  27647. /**
  27648. * | Value | Type | Description |
  27649. * | ----- | ------------------ | ----------- |
  27650. * | 0 | CLAMP_ADDRESSMODE | |
  27651. * | 1 | WRAP_ADDRESSMODE | |
  27652. * | 2 | MIRROR_ADDRESSMODE | |
  27653. */
  27654. wrapU: number;
  27655. /**
  27656. * | Value | Type | Description |
  27657. * | ----- | ------------------ | ----------- |
  27658. * | 0 | CLAMP_ADDRESSMODE | |
  27659. * | 1 | WRAP_ADDRESSMODE | |
  27660. * | 2 | MIRROR_ADDRESSMODE | |
  27661. */
  27662. wrapV: number;
  27663. /**
  27664. * | Value | Type | Description |
  27665. * | ----- | ------------------ | ----------- |
  27666. * | 0 | CLAMP_ADDRESSMODE | |
  27667. * | 1 | WRAP_ADDRESSMODE | |
  27668. * | 2 | MIRROR_ADDRESSMODE | |
  27669. */
  27670. wrapR: number;
  27671. /**
  27672. * With compliant hardware and browser (supporting anisotropic filtering)
  27673. * this defines the level of anisotropic filtering in the texture.
  27674. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27675. */
  27676. anisotropicFilteringLevel: number;
  27677. /**
  27678. * Define if the texture is a cube texture or if false a 2d texture.
  27679. */
  27680. isCube: boolean;
  27681. /**
  27682. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27683. */
  27684. is3D: boolean;
  27685. /**
  27686. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27687. * HDR texture are usually stored in linear space.
  27688. * This only impacts the PBR and Background materials
  27689. */
  27690. gammaSpace: boolean;
  27691. /**
  27692. * Gets whether or not the texture contains RGBD data.
  27693. */
  27694. readonly isRGBD: boolean;
  27695. /**
  27696. * Is Z inverted in the texture (useful in a cube texture).
  27697. */
  27698. invertZ: boolean;
  27699. /**
  27700. * Are mip maps generated for this texture or not.
  27701. */
  27702. readonly noMipmap: boolean;
  27703. /**
  27704. * @hidden
  27705. */
  27706. lodLevelInAlpha: boolean;
  27707. /**
  27708. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27709. */
  27710. lodGenerationOffset: number;
  27711. /**
  27712. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27713. */
  27714. lodGenerationScale: number;
  27715. /**
  27716. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27717. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27718. * average roughness values.
  27719. */
  27720. linearSpecularLOD: boolean;
  27721. /**
  27722. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27723. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27724. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27725. */
  27726. irradianceTexture: Nullable<BaseTexture>;
  27727. /**
  27728. * Define if the texture is a render target.
  27729. */
  27730. isRenderTarget: boolean;
  27731. /**
  27732. * Define the unique id of the texture in the scene.
  27733. */
  27734. readonly uid: string;
  27735. /**
  27736. * Return a string representation of the texture.
  27737. * @returns the texture as a string
  27738. */
  27739. toString(): string;
  27740. /**
  27741. * Get the class name of the texture.
  27742. * @returns "BaseTexture"
  27743. */
  27744. getClassName(): string;
  27745. /**
  27746. * Define the list of animation attached to the texture.
  27747. */
  27748. animations: Animation[];
  27749. /**
  27750. * An event triggered when the texture is disposed.
  27751. */
  27752. onDisposeObservable: Observable<BaseTexture>;
  27753. private _onDisposeObserver;
  27754. /**
  27755. * Callback triggered when the texture has been disposed.
  27756. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27757. */
  27758. onDispose: () => void;
  27759. /**
  27760. * Define the current state of the loading sequence when in delayed load mode.
  27761. */
  27762. delayLoadState: number;
  27763. private _scene;
  27764. /** @hidden */
  27765. _texture: Nullable<InternalTexture>;
  27766. private _uid;
  27767. /**
  27768. * Define if the texture is preventinga material to render or not.
  27769. * If not and the texture is not ready, the engine will use a default black texture instead.
  27770. */
  27771. readonly isBlocking: boolean;
  27772. /**
  27773. * Instantiates a new BaseTexture.
  27774. * Base class of all the textures in babylon.
  27775. * It groups all the common properties the materials, post process, lights... might need
  27776. * in order to make a correct use of the texture.
  27777. * @param scene Define the scene the texture blongs to
  27778. */
  27779. constructor(scene: Nullable<Scene>);
  27780. /**
  27781. * Get the scene the texture belongs to.
  27782. * @returns the scene or null if undefined
  27783. */
  27784. getScene(): Nullable<Scene>;
  27785. /**
  27786. * Get the texture transform matrix used to offset tile the texture for istance.
  27787. * @returns the transformation matrix
  27788. */
  27789. getTextureMatrix(): Matrix;
  27790. /**
  27791. * Get the texture reflection matrix used to rotate/transform the reflection.
  27792. * @returns the reflection matrix
  27793. */
  27794. getReflectionTextureMatrix(): Matrix;
  27795. /**
  27796. * Get the underlying lower level texture from Babylon.
  27797. * @returns the insternal texture
  27798. */
  27799. getInternalTexture(): Nullable<InternalTexture>;
  27800. /**
  27801. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27802. * @returns true if ready or not blocking
  27803. */
  27804. isReadyOrNotBlocking(): boolean;
  27805. /**
  27806. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27807. * @returns true if fully ready
  27808. */
  27809. isReady(): boolean;
  27810. private _cachedSize;
  27811. /**
  27812. * Get the size of the texture.
  27813. * @returns the texture size.
  27814. */
  27815. getSize(): ISize;
  27816. /**
  27817. * Get the base size of the texture.
  27818. * It can be different from the size if the texture has been resized for POT for instance
  27819. * @returns the base size
  27820. */
  27821. getBaseSize(): ISize;
  27822. /**
  27823. * Update the sampling mode of the texture.
  27824. * Default is Trilinear mode.
  27825. *
  27826. * | Value | Type | Description |
  27827. * | ----- | ------------------ | ----------- |
  27828. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27829. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27830. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27831. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27832. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27833. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27834. * | 7 | NEAREST_LINEAR | |
  27835. * | 8 | NEAREST_NEAREST | |
  27836. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27837. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27838. * | 11 | LINEAR_LINEAR | |
  27839. * | 12 | LINEAR_NEAREST | |
  27840. *
  27841. * > _mag_: magnification filter (close to the viewer)
  27842. * > _min_: minification filter (far from the viewer)
  27843. * > _mip_: filter used between mip map levels
  27844. *@param samplingMode Define the new sampling mode of the texture
  27845. */
  27846. updateSamplingMode(samplingMode: number): void;
  27847. /**
  27848. * Scales the texture if is `canRescale()`
  27849. * @param ratio the resize factor we want to use to rescale
  27850. */
  27851. scale(ratio: number): void;
  27852. /**
  27853. * Get if the texture can rescale.
  27854. */
  27855. readonly canRescale: boolean;
  27856. /** @hidden */
  27857. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27858. /** @hidden */
  27859. _rebuild(): void;
  27860. /**
  27861. * Triggers the load sequence in delayed load mode.
  27862. */
  27863. delayLoad(): void;
  27864. /**
  27865. * Clones the texture.
  27866. * @returns the cloned texture
  27867. */
  27868. clone(): Nullable<BaseTexture>;
  27869. /**
  27870. * Get the texture underlying type (INT, FLOAT...)
  27871. */
  27872. readonly textureType: number;
  27873. /**
  27874. * Get the texture underlying format (RGB, RGBA...)
  27875. */
  27876. readonly textureFormat: number;
  27877. /**
  27878. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27879. * This will returns an RGBA array buffer containing either in values (0-255) or
  27880. * float values (0-1) depending of the underlying buffer type.
  27881. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27882. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27883. * @param buffer defines a user defined buffer to fill with data (can be null)
  27884. * @returns The Array buffer containing the pixels data.
  27885. */
  27886. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27887. /**
  27888. * Release and destroy the underlying lower level texture aka internalTexture.
  27889. */
  27890. releaseInternalTexture(): void;
  27891. /**
  27892. * Get the polynomial representation of the texture data.
  27893. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27894. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27895. */
  27896. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27897. /** @hidden */
  27898. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27899. /** @hidden */
  27900. readonly _lodTextureMid: Nullable<BaseTexture>;
  27901. /** @hidden */
  27902. readonly _lodTextureLow: Nullable<BaseTexture>;
  27903. /**
  27904. * Dispose the texture and release its associated resources.
  27905. */
  27906. dispose(): void;
  27907. /**
  27908. * Serialize the texture into a JSON representation that can be parsed later on.
  27909. * @returns the JSON representation of the texture
  27910. */
  27911. serialize(): any;
  27912. /**
  27913. * Helper function to be called back once a list of texture contains only ready textures.
  27914. * @param textures Define the list of textures to wait for
  27915. * @param callback Define the callback triggered once the entire list will be ready
  27916. */
  27917. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27918. }
  27919. }
  27920. declare module BABYLON {
  27921. /**
  27922. * Class used to store data associated with WebGL texture data for the engine
  27923. * This class should not be used directly
  27924. */
  27925. export class InternalTexture {
  27926. /** @hidden */
  27927. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27928. /**
  27929. * The source of the texture data is unknown
  27930. */
  27931. static DATASOURCE_UNKNOWN: number;
  27932. /**
  27933. * Texture data comes from an URL
  27934. */
  27935. static DATASOURCE_URL: number;
  27936. /**
  27937. * Texture data is only used for temporary storage
  27938. */
  27939. static DATASOURCE_TEMP: number;
  27940. /**
  27941. * Texture data comes from raw data (ArrayBuffer)
  27942. */
  27943. static DATASOURCE_RAW: number;
  27944. /**
  27945. * Texture content is dynamic (video or dynamic texture)
  27946. */
  27947. static DATASOURCE_DYNAMIC: number;
  27948. /**
  27949. * Texture content is generated by rendering to it
  27950. */
  27951. static DATASOURCE_RENDERTARGET: number;
  27952. /**
  27953. * Texture content is part of a multi render target process
  27954. */
  27955. static DATASOURCE_MULTIRENDERTARGET: number;
  27956. /**
  27957. * Texture data comes from a cube data file
  27958. */
  27959. static DATASOURCE_CUBE: number;
  27960. /**
  27961. * Texture data comes from a raw cube data
  27962. */
  27963. static DATASOURCE_CUBERAW: number;
  27964. /**
  27965. * Texture data come from a prefiltered cube data file
  27966. */
  27967. static DATASOURCE_CUBEPREFILTERED: number;
  27968. /**
  27969. * Texture content is raw 3D data
  27970. */
  27971. static DATASOURCE_RAW3D: number;
  27972. /**
  27973. * Texture content is a depth texture
  27974. */
  27975. static DATASOURCE_DEPTHTEXTURE: number;
  27976. /**
  27977. * Texture data comes from a raw cube data encoded with RGBD
  27978. */
  27979. static DATASOURCE_CUBERAW_RGBD: number;
  27980. /**
  27981. * Defines if the texture is ready
  27982. */
  27983. isReady: boolean;
  27984. /**
  27985. * Defines if the texture is a cube texture
  27986. */
  27987. isCube: boolean;
  27988. /**
  27989. * Defines if the texture contains 3D data
  27990. */
  27991. is3D: boolean;
  27992. /**
  27993. * Defines if the texture contains multiview data
  27994. */
  27995. isMultiview: boolean;
  27996. /**
  27997. * Gets the URL used to load this texture
  27998. */
  27999. url: string;
  28000. /**
  28001. * Gets the sampling mode of the texture
  28002. */
  28003. samplingMode: number;
  28004. /**
  28005. * Gets a boolean indicating if the texture needs mipmaps generation
  28006. */
  28007. generateMipMaps: boolean;
  28008. /**
  28009. * Gets the number of samples used by the texture (WebGL2+ only)
  28010. */
  28011. samples: number;
  28012. /**
  28013. * Gets the type of the texture (int, float...)
  28014. */
  28015. type: number;
  28016. /**
  28017. * Gets the format of the texture (RGB, RGBA...)
  28018. */
  28019. format: number;
  28020. /**
  28021. * Observable called when the texture is loaded
  28022. */
  28023. onLoadedObservable: Observable<InternalTexture>;
  28024. /**
  28025. * Gets the width of the texture
  28026. */
  28027. width: number;
  28028. /**
  28029. * Gets the height of the texture
  28030. */
  28031. height: number;
  28032. /**
  28033. * Gets the depth of the texture
  28034. */
  28035. depth: number;
  28036. /**
  28037. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28038. */
  28039. baseWidth: number;
  28040. /**
  28041. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28042. */
  28043. baseHeight: number;
  28044. /**
  28045. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28046. */
  28047. baseDepth: number;
  28048. /**
  28049. * Gets a boolean indicating if the texture is inverted on Y axis
  28050. */
  28051. invertY: boolean;
  28052. /** @hidden */
  28053. _invertVScale: boolean;
  28054. /** @hidden */
  28055. _associatedChannel: number;
  28056. /** @hidden */
  28057. _dataSource: number;
  28058. /** @hidden */
  28059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28060. /** @hidden */
  28061. _bufferView: Nullable<ArrayBufferView>;
  28062. /** @hidden */
  28063. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28064. /** @hidden */
  28065. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28066. /** @hidden */
  28067. _size: number;
  28068. /** @hidden */
  28069. _extension: string;
  28070. /** @hidden */
  28071. _files: Nullable<string[]>;
  28072. /** @hidden */
  28073. _workingCanvas: Nullable<HTMLCanvasElement>;
  28074. /** @hidden */
  28075. _workingContext: Nullable<CanvasRenderingContext2D>;
  28076. /** @hidden */
  28077. _framebuffer: Nullable<WebGLFramebuffer>;
  28078. /** @hidden */
  28079. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28080. /** @hidden */
  28081. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28082. /** @hidden */
  28083. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28084. /** @hidden */
  28085. _attachments: Nullable<number[]>;
  28086. /** @hidden */
  28087. _cachedCoordinatesMode: Nullable<number>;
  28088. /** @hidden */
  28089. _cachedWrapU: Nullable<number>;
  28090. /** @hidden */
  28091. _cachedWrapV: Nullable<number>;
  28092. /** @hidden */
  28093. _cachedWrapR: Nullable<number>;
  28094. /** @hidden */
  28095. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28096. /** @hidden */
  28097. _isDisabled: boolean;
  28098. /** @hidden */
  28099. _compression: Nullable<string>;
  28100. /** @hidden */
  28101. _generateStencilBuffer: boolean;
  28102. /** @hidden */
  28103. _generateDepthBuffer: boolean;
  28104. /** @hidden */
  28105. _comparisonFunction: number;
  28106. /** @hidden */
  28107. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28108. /** @hidden */
  28109. _lodGenerationScale: number;
  28110. /** @hidden */
  28111. _lodGenerationOffset: number;
  28112. /** @hidden */
  28113. _colorTextureArray: Nullable<WebGLTexture>;
  28114. /** @hidden */
  28115. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28116. /** @hidden */
  28117. _lodTextureHigh: Nullable<BaseTexture>;
  28118. /** @hidden */
  28119. _lodTextureMid: Nullable<BaseTexture>;
  28120. /** @hidden */
  28121. _lodTextureLow: Nullable<BaseTexture>;
  28122. /** @hidden */
  28123. _isRGBD: boolean;
  28124. /** @hidden */
  28125. _linearSpecularLOD: boolean;
  28126. /** @hidden */
  28127. _irradianceTexture: Nullable<BaseTexture>;
  28128. /** @hidden */
  28129. _webGLTexture: Nullable<WebGLTexture>;
  28130. /** @hidden */
  28131. _references: number;
  28132. private _engine;
  28133. /**
  28134. * Gets the Engine the texture belongs to.
  28135. * @returns The babylon engine
  28136. */
  28137. getEngine(): Engine;
  28138. /**
  28139. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28140. */
  28141. readonly dataSource: number;
  28142. /**
  28143. * Creates a new InternalTexture
  28144. * @param engine defines the engine to use
  28145. * @param dataSource defines the type of data that will be used
  28146. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28147. */
  28148. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28149. /**
  28150. * Increments the number of references (ie. the number of Texture that point to it)
  28151. */
  28152. incrementReferences(): void;
  28153. /**
  28154. * Change the size of the texture (not the size of the content)
  28155. * @param width defines the new width
  28156. * @param height defines the new height
  28157. * @param depth defines the new depth (1 by default)
  28158. */
  28159. updateSize(width: int, height: int, depth?: int): void;
  28160. /** @hidden */
  28161. _rebuild(): void;
  28162. /** @hidden */
  28163. _swapAndDie(target: InternalTexture): void;
  28164. /**
  28165. * Dispose the current allocated resources
  28166. */
  28167. dispose(): void;
  28168. }
  28169. }
  28170. declare module BABYLON {
  28171. /**
  28172. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28173. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28174. */
  28175. export class EffectFallbacks {
  28176. private _defines;
  28177. private _currentRank;
  28178. private _maxRank;
  28179. private _mesh;
  28180. /**
  28181. * Removes the fallback from the bound mesh.
  28182. */
  28183. unBindMesh(): void;
  28184. /**
  28185. * Adds a fallback on the specified property.
  28186. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28187. * @param define The name of the define in the shader
  28188. */
  28189. addFallback(rank: number, define: string): void;
  28190. /**
  28191. * Sets the mesh to use CPU skinning when needing to fallback.
  28192. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28193. * @param mesh The mesh to use the fallbacks.
  28194. */
  28195. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28196. /**
  28197. * Checks to see if more fallbacks are still availible.
  28198. */
  28199. readonly hasMoreFallbacks: boolean;
  28200. /**
  28201. * Removes the defines that should be removed when falling back.
  28202. * @param currentDefines defines the current define statements for the shader.
  28203. * @param effect defines the current effect we try to compile
  28204. * @returns The resulting defines with defines of the current rank removed.
  28205. */
  28206. reduce(currentDefines: string, effect: Effect): string;
  28207. }
  28208. /**
  28209. * Options to be used when creating an effect.
  28210. */
  28211. export class EffectCreationOptions {
  28212. /**
  28213. * Atrributes that will be used in the shader.
  28214. */
  28215. attributes: string[];
  28216. /**
  28217. * Uniform varible names that will be set in the shader.
  28218. */
  28219. uniformsNames: string[];
  28220. /**
  28221. * Uniform buffer varible names that will be set in the shader.
  28222. */
  28223. uniformBuffersNames: string[];
  28224. /**
  28225. * Sampler texture variable names that will be set in the shader.
  28226. */
  28227. samplers: string[];
  28228. /**
  28229. * Define statements that will be set in the shader.
  28230. */
  28231. defines: any;
  28232. /**
  28233. * Possible fallbacks for this effect to improve performance when needed.
  28234. */
  28235. fallbacks: Nullable<EffectFallbacks>;
  28236. /**
  28237. * Callback that will be called when the shader is compiled.
  28238. */
  28239. onCompiled: Nullable<(effect: Effect) => void>;
  28240. /**
  28241. * Callback that will be called if an error occurs during shader compilation.
  28242. */
  28243. onError: Nullable<(effect: Effect, errors: string) => void>;
  28244. /**
  28245. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28246. */
  28247. indexParameters: any;
  28248. /**
  28249. * Max number of lights that can be used in the shader.
  28250. */
  28251. maxSimultaneousLights: number;
  28252. /**
  28253. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28254. */
  28255. transformFeedbackVaryings: Nullable<string[]>;
  28256. }
  28257. /**
  28258. * Effect containing vertex and fragment shader that can be executed on an object.
  28259. */
  28260. export class Effect implements IDisposable {
  28261. /**
  28262. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28263. */
  28264. static ShadersRepository: string;
  28265. /**
  28266. * Name of the effect.
  28267. */
  28268. name: any;
  28269. /**
  28270. * String container all the define statements that should be set on the shader.
  28271. */
  28272. defines: string;
  28273. /**
  28274. * Callback that will be called when the shader is compiled.
  28275. */
  28276. onCompiled: Nullable<(effect: Effect) => void>;
  28277. /**
  28278. * Callback that will be called if an error occurs during shader compilation.
  28279. */
  28280. onError: Nullable<(effect: Effect, errors: string) => void>;
  28281. /**
  28282. * Callback that will be called when effect is bound.
  28283. */
  28284. onBind: Nullable<(effect: Effect) => void>;
  28285. /**
  28286. * Unique ID of the effect.
  28287. */
  28288. uniqueId: number;
  28289. /**
  28290. * Observable that will be called when the shader is compiled.
  28291. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28292. */
  28293. onCompileObservable: Observable<Effect>;
  28294. /**
  28295. * Observable that will be called if an error occurs during shader compilation.
  28296. */
  28297. onErrorObservable: Observable<Effect>;
  28298. /** @hidden */
  28299. _onBindObservable: Nullable<Observable<Effect>>;
  28300. /**
  28301. * Observable that will be called when effect is bound.
  28302. */
  28303. readonly onBindObservable: Observable<Effect>;
  28304. /** @hidden */
  28305. _bonesComputationForcedToCPU: boolean;
  28306. private static _uniqueIdSeed;
  28307. private _engine;
  28308. private _uniformBuffersNames;
  28309. private _uniformsNames;
  28310. private _samplerList;
  28311. private _samplers;
  28312. private _isReady;
  28313. private _compilationError;
  28314. private _attributesNames;
  28315. private _attributes;
  28316. private _uniforms;
  28317. /**
  28318. * Key for the effect.
  28319. * @hidden
  28320. */
  28321. _key: string;
  28322. private _indexParameters;
  28323. private _fallbacks;
  28324. private _vertexSourceCode;
  28325. private _fragmentSourceCode;
  28326. private _vertexSourceCodeOverride;
  28327. private _fragmentSourceCodeOverride;
  28328. private _transformFeedbackVaryings;
  28329. /**
  28330. * Compiled shader to webGL program.
  28331. * @hidden
  28332. */
  28333. _pipelineContext: Nullable<IPipelineContext>;
  28334. private _valueCache;
  28335. private static _baseCache;
  28336. /**
  28337. * Instantiates an effect.
  28338. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28339. * @param baseName Name of the effect.
  28340. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28341. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28342. * @param samplers List of sampler variables that will be passed to the shader.
  28343. * @param engine Engine to be used to render the effect
  28344. * @param defines Define statements to be added to the shader.
  28345. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28346. * @param onCompiled Callback that will be called when the shader is compiled.
  28347. * @param onError Callback that will be called if an error occurs during shader compilation.
  28348. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28349. */
  28350. 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);
  28351. private _useFinalCode;
  28352. /**
  28353. * Unique key for this effect
  28354. */
  28355. readonly key: string;
  28356. /**
  28357. * If the effect has been compiled and prepared.
  28358. * @returns if the effect is compiled and prepared.
  28359. */
  28360. isReady(): boolean;
  28361. private _isReadyInternal;
  28362. /**
  28363. * The engine the effect was initialized with.
  28364. * @returns the engine.
  28365. */
  28366. getEngine(): Engine;
  28367. /**
  28368. * The pipeline context for this effect
  28369. * @returns the associated pipeline context
  28370. */
  28371. getPipelineContext(): Nullable<IPipelineContext>;
  28372. /**
  28373. * The set of names of attribute variables for the shader.
  28374. * @returns An array of attribute names.
  28375. */
  28376. getAttributesNames(): string[];
  28377. /**
  28378. * Returns the attribute at the given index.
  28379. * @param index The index of the attribute.
  28380. * @returns The location of the attribute.
  28381. */
  28382. getAttributeLocation(index: number): number;
  28383. /**
  28384. * Returns the attribute based on the name of the variable.
  28385. * @param name of the attribute to look up.
  28386. * @returns the attribute location.
  28387. */
  28388. getAttributeLocationByName(name: string): number;
  28389. /**
  28390. * The number of attributes.
  28391. * @returns the numnber of attributes.
  28392. */
  28393. getAttributesCount(): number;
  28394. /**
  28395. * Gets the index of a uniform variable.
  28396. * @param uniformName of the uniform to look up.
  28397. * @returns the index.
  28398. */
  28399. getUniformIndex(uniformName: string): number;
  28400. /**
  28401. * Returns the attribute based on the name of the variable.
  28402. * @param uniformName of the uniform to look up.
  28403. * @returns the location of the uniform.
  28404. */
  28405. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28406. /**
  28407. * Returns an array of sampler variable names
  28408. * @returns The array of sampler variable neames.
  28409. */
  28410. getSamplers(): string[];
  28411. /**
  28412. * The error from the last compilation.
  28413. * @returns the error string.
  28414. */
  28415. getCompilationError(): string;
  28416. /**
  28417. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28418. * @param func The callback to be used.
  28419. */
  28420. executeWhenCompiled(func: (effect: Effect) => void): void;
  28421. private _checkIsReady;
  28422. /** @hidden */
  28423. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28424. /** @hidden */
  28425. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28426. /** @hidden */
  28427. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28428. /**
  28429. * Recompiles the webGL program
  28430. * @param vertexSourceCode The source code for the vertex shader.
  28431. * @param fragmentSourceCode The source code for the fragment shader.
  28432. * @param onCompiled Callback called when completed.
  28433. * @param onError Callback called on error.
  28434. * @hidden
  28435. */
  28436. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28437. /**
  28438. * Prepares the effect
  28439. * @hidden
  28440. */
  28441. _prepareEffect(): void;
  28442. private _processCompilationErrors;
  28443. /**
  28444. * Checks if the effect is supported. (Must be called after compilation)
  28445. */
  28446. readonly isSupported: boolean;
  28447. /**
  28448. * Binds a texture to the engine to be used as output of the shader.
  28449. * @param channel Name of the output variable.
  28450. * @param texture Texture to bind.
  28451. * @hidden
  28452. */
  28453. _bindTexture(channel: string, texture: InternalTexture): void;
  28454. /**
  28455. * Sets a texture on the engine to be used in the shader.
  28456. * @param channel Name of the sampler variable.
  28457. * @param texture Texture to set.
  28458. */
  28459. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28460. /**
  28461. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28462. * @param channel Name of the sampler variable.
  28463. * @param texture Texture to set.
  28464. */
  28465. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28466. /**
  28467. * Sets an array of textures on the engine to be used in the shader.
  28468. * @param channel Name of the variable.
  28469. * @param textures Textures to set.
  28470. */
  28471. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28472. /**
  28473. * 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)
  28474. * @param channel Name of the sampler variable.
  28475. * @param postProcess Post process to get the input texture from.
  28476. */
  28477. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28478. /**
  28479. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28480. * 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)
  28481. * @param channel Name of the sampler variable.
  28482. * @param postProcess Post process to get the output texture from.
  28483. */
  28484. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28485. /** @hidden */
  28486. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28487. /** @hidden */
  28488. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28489. /** @hidden */
  28490. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28491. /** @hidden */
  28492. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28493. /**
  28494. * Binds a buffer to a uniform.
  28495. * @param buffer Buffer to bind.
  28496. * @param name Name of the uniform variable to bind to.
  28497. */
  28498. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28499. /**
  28500. * Binds block to a uniform.
  28501. * @param blockName Name of the block to bind.
  28502. * @param index Index to bind.
  28503. */
  28504. bindUniformBlock(blockName: string, index: number): void;
  28505. /**
  28506. * Sets an interger value on a uniform variable.
  28507. * @param uniformName Name of the variable.
  28508. * @param value Value to be set.
  28509. * @returns this effect.
  28510. */
  28511. setInt(uniformName: string, value: number): Effect;
  28512. /**
  28513. * Sets an int array on a uniform variable.
  28514. * @param uniformName Name of the variable.
  28515. * @param array array to be set.
  28516. * @returns this effect.
  28517. */
  28518. setIntArray(uniformName: string, array: Int32Array): Effect;
  28519. /**
  28520. * 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)
  28521. * @param uniformName Name of the variable.
  28522. * @param array array to be set.
  28523. * @returns this effect.
  28524. */
  28525. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28526. /**
  28527. * 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)
  28528. * @param uniformName Name of the variable.
  28529. * @param array array to be set.
  28530. * @returns this effect.
  28531. */
  28532. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28533. /**
  28534. * 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)
  28535. * @param uniformName Name of the variable.
  28536. * @param array array to be set.
  28537. * @returns this effect.
  28538. */
  28539. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28540. /**
  28541. * Sets an float array on a uniform variable.
  28542. * @param uniformName Name of the variable.
  28543. * @param array array to be set.
  28544. * @returns this effect.
  28545. */
  28546. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28547. /**
  28548. * 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)
  28549. * @param uniformName Name of the variable.
  28550. * @param array array to be set.
  28551. * @returns this effect.
  28552. */
  28553. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28554. /**
  28555. * 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)
  28556. * @param uniformName Name of the variable.
  28557. * @param array array to be set.
  28558. * @returns this effect.
  28559. */
  28560. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28561. /**
  28562. * 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)
  28563. * @param uniformName Name of the variable.
  28564. * @param array array to be set.
  28565. * @returns this effect.
  28566. */
  28567. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28568. /**
  28569. * Sets an array on a uniform variable.
  28570. * @param uniformName Name of the variable.
  28571. * @param array array to be set.
  28572. * @returns this effect.
  28573. */
  28574. setArray(uniformName: string, array: number[]): Effect;
  28575. /**
  28576. * 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)
  28577. * @param uniformName Name of the variable.
  28578. * @param array array to be set.
  28579. * @returns this effect.
  28580. */
  28581. setArray2(uniformName: string, array: number[]): Effect;
  28582. /**
  28583. * 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)
  28584. * @param uniformName Name of the variable.
  28585. * @param array array to be set.
  28586. * @returns this effect.
  28587. */
  28588. setArray3(uniformName: string, array: number[]): Effect;
  28589. /**
  28590. * 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)
  28591. * @param uniformName Name of the variable.
  28592. * @param array array to be set.
  28593. * @returns this effect.
  28594. */
  28595. setArray4(uniformName: string, array: number[]): Effect;
  28596. /**
  28597. * Sets matrices on a uniform variable.
  28598. * @param uniformName Name of the variable.
  28599. * @param matrices matrices to be set.
  28600. * @returns this effect.
  28601. */
  28602. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28603. /**
  28604. * Sets matrix on a uniform variable.
  28605. * @param uniformName Name of the variable.
  28606. * @param matrix matrix to be set.
  28607. * @returns this effect.
  28608. */
  28609. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28610. /**
  28611. * 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)
  28612. * @param uniformName Name of the variable.
  28613. * @param matrix matrix to be set.
  28614. * @returns this effect.
  28615. */
  28616. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28617. /**
  28618. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28619. * @param uniformName Name of the variable.
  28620. * @param matrix matrix to be set.
  28621. * @returns this effect.
  28622. */
  28623. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28624. /**
  28625. * Sets a float on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param value value to be set.
  28628. * @returns this effect.
  28629. */
  28630. setFloat(uniformName: string, value: number): Effect;
  28631. /**
  28632. * Sets a boolean on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param bool value to be set.
  28635. * @returns this effect.
  28636. */
  28637. setBool(uniformName: string, bool: boolean): Effect;
  28638. /**
  28639. * Sets a Vector2 on a uniform variable.
  28640. * @param uniformName Name of the variable.
  28641. * @param vector2 vector2 to be set.
  28642. * @returns this effect.
  28643. */
  28644. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28645. /**
  28646. * Sets a float2 on a uniform variable.
  28647. * @param uniformName Name of the variable.
  28648. * @param x First float in float2.
  28649. * @param y Second float in float2.
  28650. * @returns this effect.
  28651. */
  28652. setFloat2(uniformName: string, x: number, y: number): Effect;
  28653. /**
  28654. * Sets a Vector3 on a uniform variable.
  28655. * @param uniformName Name of the variable.
  28656. * @param vector3 Value to be set.
  28657. * @returns this effect.
  28658. */
  28659. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28660. /**
  28661. * Sets a float3 on a uniform variable.
  28662. * @param uniformName Name of the variable.
  28663. * @param x First float in float3.
  28664. * @param y Second float in float3.
  28665. * @param z Third float in float3.
  28666. * @returns this effect.
  28667. */
  28668. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28669. /**
  28670. * Sets a Vector4 on a uniform variable.
  28671. * @param uniformName Name of the variable.
  28672. * @param vector4 Value to be set.
  28673. * @returns this effect.
  28674. */
  28675. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28676. /**
  28677. * Sets a float4 on a uniform variable.
  28678. * @param uniformName Name of the variable.
  28679. * @param x First float in float4.
  28680. * @param y Second float in float4.
  28681. * @param z Third float in float4.
  28682. * @param w Fourth float in float4.
  28683. * @returns this effect.
  28684. */
  28685. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28686. /**
  28687. * Sets a Color3 on a uniform variable.
  28688. * @param uniformName Name of the variable.
  28689. * @param color3 Value to be set.
  28690. * @returns this effect.
  28691. */
  28692. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28693. /**
  28694. * Sets a Color4 on a uniform variable.
  28695. * @param uniformName Name of the variable.
  28696. * @param color3 Value to be set.
  28697. * @param alpha Alpha value to be set.
  28698. * @returns this effect.
  28699. */
  28700. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28701. /**
  28702. * Sets a Color4 on a uniform variable
  28703. * @param uniformName defines the name of the variable
  28704. * @param color4 defines the value to be set
  28705. * @returns this effect.
  28706. */
  28707. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28708. /** Release all associated resources */
  28709. dispose(): void;
  28710. /**
  28711. * This function will add a new shader to the shader store
  28712. * @param name the name of the shader
  28713. * @param pixelShader optional pixel shader content
  28714. * @param vertexShader optional vertex shader content
  28715. */
  28716. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28717. /**
  28718. * Store of each shader (The can be looked up using effect.key)
  28719. */
  28720. static ShadersStore: {
  28721. [key: string]: string;
  28722. };
  28723. /**
  28724. * Store of each included file for a shader (The can be looked up using effect.key)
  28725. */
  28726. static IncludesShadersStore: {
  28727. [key: string]: string;
  28728. };
  28729. /**
  28730. * Resets the cache of effects.
  28731. */
  28732. static ResetCache(): void;
  28733. }
  28734. }
  28735. declare module BABYLON {
  28736. /**
  28737. * Uniform buffer objects.
  28738. *
  28739. * Handles blocks of uniform on the GPU.
  28740. *
  28741. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28742. *
  28743. * For more information, please refer to :
  28744. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28745. */
  28746. export class UniformBuffer {
  28747. private _engine;
  28748. private _buffer;
  28749. private _data;
  28750. private _bufferData;
  28751. private _dynamic?;
  28752. private _uniformLocations;
  28753. private _uniformSizes;
  28754. private _uniformLocationPointer;
  28755. private _needSync;
  28756. private _noUBO;
  28757. private _currentEffect;
  28758. private static _MAX_UNIFORM_SIZE;
  28759. private static _tempBuffer;
  28760. /**
  28761. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28762. * This is dynamic to allow compat with webgl 1 and 2.
  28763. * You will need to pass the name of the uniform as well as the value.
  28764. */
  28765. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28766. /**
  28767. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28768. * This is dynamic to allow compat with webgl 1 and 2.
  28769. * You will need to pass the name of the uniform as well as the value.
  28770. */
  28771. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28772. /**
  28773. * Lambda to Update a single float in a uniform buffer.
  28774. * This is dynamic to allow compat with webgl 1 and 2.
  28775. * You will need to pass the name of the uniform as well as the value.
  28776. */
  28777. updateFloat: (name: string, x: number) => void;
  28778. /**
  28779. * Lambda to Update a vec2 of float in a uniform buffer.
  28780. * This is dynamic to allow compat with webgl 1 and 2.
  28781. * You will need to pass the name of the uniform as well as the value.
  28782. */
  28783. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28784. /**
  28785. * Lambda to Update a vec3 of float in a uniform buffer.
  28786. * This is dynamic to allow compat with webgl 1 and 2.
  28787. * You will need to pass the name of the uniform as well as the value.
  28788. */
  28789. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28790. /**
  28791. * Lambda to Update a vec4 of float in a uniform buffer.
  28792. * This is dynamic to allow compat with webgl 1 and 2.
  28793. * You will need to pass the name of the uniform as well as the value.
  28794. */
  28795. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28796. /**
  28797. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28798. * This is dynamic to allow compat with webgl 1 and 2.
  28799. * You will need to pass the name of the uniform as well as the value.
  28800. */
  28801. updateMatrix: (name: string, mat: Matrix) => void;
  28802. /**
  28803. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28804. * This is dynamic to allow compat with webgl 1 and 2.
  28805. * You will need to pass the name of the uniform as well as the value.
  28806. */
  28807. updateVector3: (name: string, vector: Vector3) => void;
  28808. /**
  28809. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28810. * This is dynamic to allow compat with webgl 1 and 2.
  28811. * You will need to pass the name of the uniform as well as the value.
  28812. */
  28813. updateVector4: (name: string, vector: Vector4) => void;
  28814. /**
  28815. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28816. * This is dynamic to allow compat with webgl 1 and 2.
  28817. * You will need to pass the name of the uniform as well as the value.
  28818. */
  28819. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28820. /**
  28821. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28822. * This is dynamic to allow compat with webgl 1 and 2.
  28823. * You will need to pass the name of the uniform as well as the value.
  28824. */
  28825. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28826. /**
  28827. * Instantiates a new Uniform buffer objects.
  28828. *
  28829. * Handles blocks of uniform on the GPU.
  28830. *
  28831. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28832. *
  28833. * For more information, please refer to :
  28834. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28835. * @param engine Define the engine the buffer is associated with
  28836. * @param data Define the data contained in the buffer
  28837. * @param dynamic Define if the buffer is updatable
  28838. */
  28839. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28840. /**
  28841. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28842. * or just falling back on setUniformXXX calls.
  28843. */
  28844. readonly useUbo: boolean;
  28845. /**
  28846. * Indicates if the WebGL underlying uniform buffer is in sync
  28847. * with the javascript cache data.
  28848. */
  28849. readonly isSync: boolean;
  28850. /**
  28851. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28852. * Also, a dynamic UniformBuffer will disable cache verification and always
  28853. * update the underlying WebGL uniform buffer to the GPU.
  28854. * @returns if Dynamic, otherwise false
  28855. */
  28856. isDynamic(): boolean;
  28857. /**
  28858. * The data cache on JS side.
  28859. * @returns the underlying data as a float array
  28860. */
  28861. getData(): Float32Array;
  28862. /**
  28863. * The underlying WebGL Uniform buffer.
  28864. * @returns the webgl buffer
  28865. */
  28866. getBuffer(): Nullable<DataBuffer>;
  28867. /**
  28868. * std140 layout specifies how to align data within an UBO structure.
  28869. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28870. * for specs.
  28871. */
  28872. private _fillAlignment;
  28873. /**
  28874. * Adds an uniform in the buffer.
  28875. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28876. * for the layout to be correct !
  28877. * @param name Name of the uniform, as used in the uniform block in the shader.
  28878. * @param size Data size, or data directly.
  28879. */
  28880. addUniform(name: string, size: number | number[]): void;
  28881. /**
  28882. * Adds a Matrix 4x4 to the uniform buffer.
  28883. * @param name Name of the uniform, as used in the uniform block in the shader.
  28884. * @param mat A 4x4 matrix.
  28885. */
  28886. addMatrix(name: string, mat: Matrix): void;
  28887. /**
  28888. * Adds a vec2 to the uniform buffer.
  28889. * @param name Name of the uniform, as used in the uniform block in the shader.
  28890. * @param x Define the x component value of the vec2
  28891. * @param y Define the y component value of the vec2
  28892. */
  28893. addFloat2(name: string, x: number, y: number): void;
  28894. /**
  28895. * Adds a vec3 to the uniform buffer.
  28896. * @param name Name of the uniform, as used in the uniform block in the shader.
  28897. * @param x Define the x component value of the vec3
  28898. * @param y Define the y component value of the vec3
  28899. * @param z Define the z component value of the vec3
  28900. */
  28901. addFloat3(name: string, x: number, y: number, z: number): void;
  28902. /**
  28903. * Adds a vec3 to the uniform buffer.
  28904. * @param name Name of the uniform, as used in the uniform block in the shader.
  28905. * @param color Define the vec3 from a Color
  28906. */
  28907. addColor3(name: string, color: Color3): void;
  28908. /**
  28909. * Adds a vec4 to the uniform buffer.
  28910. * @param name Name of the uniform, as used in the uniform block in the shader.
  28911. * @param color Define the rgb components from a Color
  28912. * @param alpha Define the a component of the vec4
  28913. */
  28914. addColor4(name: string, color: Color3, alpha: number): void;
  28915. /**
  28916. * Adds a vec3 to the uniform buffer.
  28917. * @param name Name of the uniform, as used in the uniform block in the shader.
  28918. * @param vector Define the vec3 components from a Vector
  28919. */
  28920. addVector3(name: string, vector: Vector3): void;
  28921. /**
  28922. * Adds a Matrix 3x3 to the uniform buffer.
  28923. * @param name Name of the uniform, as used in the uniform block in the shader.
  28924. */
  28925. addMatrix3x3(name: string): void;
  28926. /**
  28927. * Adds a Matrix 2x2 to the uniform buffer.
  28928. * @param name Name of the uniform, as used in the uniform block in the shader.
  28929. */
  28930. addMatrix2x2(name: string): void;
  28931. /**
  28932. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28933. */
  28934. create(): void;
  28935. /** @hidden */
  28936. _rebuild(): void;
  28937. /**
  28938. * Updates the WebGL Uniform Buffer on the GPU.
  28939. * If the `dynamic` flag is set to true, no cache comparison is done.
  28940. * Otherwise, the buffer will be updated only if the cache differs.
  28941. */
  28942. update(): void;
  28943. /**
  28944. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28945. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28946. * @param data Define the flattened data
  28947. * @param size Define the size of the data.
  28948. */
  28949. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28950. private _valueCache;
  28951. private _cacheMatrix;
  28952. private _updateMatrix3x3ForUniform;
  28953. private _updateMatrix3x3ForEffect;
  28954. private _updateMatrix2x2ForEffect;
  28955. private _updateMatrix2x2ForUniform;
  28956. private _updateFloatForEffect;
  28957. private _updateFloatForUniform;
  28958. private _updateFloat2ForEffect;
  28959. private _updateFloat2ForUniform;
  28960. private _updateFloat3ForEffect;
  28961. private _updateFloat3ForUniform;
  28962. private _updateFloat4ForEffect;
  28963. private _updateFloat4ForUniform;
  28964. private _updateMatrixForEffect;
  28965. private _updateMatrixForUniform;
  28966. private _updateVector3ForEffect;
  28967. private _updateVector3ForUniform;
  28968. private _updateVector4ForEffect;
  28969. private _updateVector4ForUniform;
  28970. private _updateColor3ForEffect;
  28971. private _updateColor3ForUniform;
  28972. private _updateColor4ForEffect;
  28973. private _updateColor4ForUniform;
  28974. /**
  28975. * Sets a sampler uniform on the effect.
  28976. * @param name Define the name of the sampler.
  28977. * @param texture Define the texture to set in the sampler
  28978. */
  28979. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28980. /**
  28981. * Directly updates the value of the uniform in the cache AND on the GPU.
  28982. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28983. * @param data Define the flattened data
  28984. */
  28985. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28986. /**
  28987. * Binds this uniform buffer to an effect.
  28988. * @param effect Define the effect to bind the buffer to
  28989. * @param name Name of the uniform block in the shader.
  28990. */
  28991. bindToEffect(effect: Effect, name: string): void;
  28992. /**
  28993. * Disposes the uniform buffer.
  28994. */
  28995. dispose(): void;
  28996. }
  28997. }
  28998. declare module BABYLON {
  28999. /**
  29000. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29002. */
  29003. export class Analyser {
  29004. /**
  29005. * Gets or sets the smoothing
  29006. * @ignorenaming
  29007. */
  29008. SMOOTHING: number;
  29009. /**
  29010. * Gets or sets the FFT table size
  29011. * @ignorenaming
  29012. */
  29013. FFT_SIZE: number;
  29014. /**
  29015. * Gets or sets the bar graph amplitude
  29016. * @ignorenaming
  29017. */
  29018. BARGRAPHAMPLITUDE: number;
  29019. /**
  29020. * Gets or sets the position of the debug canvas
  29021. * @ignorenaming
  29022. */
  29023. DEBUGCANVASPOS: {
  29024. x: number;
  29025. y: number;
  29026. };
  29027. /**
  29028. * Gets or sets the debug canvas size
  29029. * @ignorenaming
  29030. */
  29031. DEBUGCANVASSIZE: {
  29032. width: number;
  29033. height: number;
  29034. };
  29035. private _byteFreqs;
  29036. private _byteTime;
  29037. private _floatFreqs;
  29038. private _webAudioAnalyser;
  29039. private _debugCanvas;
  29040. private _debugCanvasContext;
  29041. private _scene;
  29042. private _registerFunc;
  29043. private _audioEngine;
  29044. /**
  29045. * Creates a new analyser
  29046. * @param scene defines hosting scene
  29047. */
  29048. constructor(scene: Scene);
  29049. /**
  29050. * Get the number of data values you will have to play with for the visualization
  29051. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29052. * @returns a number
  29053. */
  29054. getFrequencyBinCount(): number;
  29055. /**
  29056. * Gets the current frequency data as a byte array
  29057. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29058. * @returns a Uint8Array
  29059. */
  29060. getByteFrequencyData(): Uint8Array;
  29061. /**
  29062. * Gets the current waveform as a byte array
  29063. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29064. * @returns a Uint8Array
  29065. */
  29066. getByteTimeDomainData(): Uint8Array;
  29067. /**
  29068. * Gets the current frequency data as a float array
  29069. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29070. * @returns a Float32Array
  29071. */
  29072. getFloatFrequencyData(): Float32Array;
  29073. /**
  29074. * Renders the debug canvas
  29075. */
  29076. drawDebugCanvas(): void;
  29077. /**
  29078. * Stops rendering the debug canvas and removes it
  29079. */
  29080. stopDebugCanvas(): void;
  29081. /**
  29082. * Connects two audio nodes
  29083. * @param inputAudioNode defines first node to connect
  29084. * @param outputAudioNode defines second node to connect
  29085. */
  29086. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29087. /**
  29088. * Releases all associated resources
  29089. */
  29090. dispose(): void;
  29091. }
  29092. }
  29093. declare module BABYLON {
  29094. /**
  29095. * This represents an audio engine and it is responsible
  29096. * to play, synchronize and analyse sounds throughout the application.
  29097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29098. */
  29099. export interface IAudioEngine extends IDisposable {
  29100. /**
  29101. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29102. */
  29103. readonly canUseWebAudio: boolean;
  29104. /**
  29105. * Gets the current AudioContext if available.
  29106. */
  29107. readonly audioContext: Nullable<AudioContext>;
  29108. /**
  29109. * The master gain node defines the global audio volume of your audio engine.
  29110. */
  29111. readonly masterGain: GainNode;
  29112. /**
  29113. * Gets whether or not mp3 are supported by your browser.
  29114. */
  29115. readonly isMP3supported: boolean;
  29116. /**
  29117. * Gets whether or not ogg are supported by your browser.
  29118. */
  29119. readonly isOGGsupported: boolean;
  29120. /**
  29121. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29122. * @ignoreNaming
  29123. */
  29124. WarnedWebAudioUnsupported: boolean;
  29125. /**
  29126. * Defines if the audio engine relies on a custom unlocked button.
  29127. * In this case, the embedded button will not be displayed.
  29128. */
  29129. useCustomUnlockedButton: boolean;
  29130. /**
  29131. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29132. */
  29133. readonly unlocked: boolean;
  29134. /**
  29135. * Event raised when audio has been unlocked on the browser.
  29136. */
  29137. onAudioUnlockedObservable: Observable<AudioEngine>;
  29138. /**
  29139. * Event raised when audio has been locked on the browser.
  29140. */
  29141. onAudioLockedObservable: Observable<AudioEngine>;
  29142. /**
  29143. * Flags the audio engine in Locked state.
  29144. * This happens due to new browser policies preventing audio to autoplay.
  29145. */
  29146. lock(): void;
  29147. /**
  29148. * Unlocks the audio engine once a user action has been done on the dom.
  29149. * This is helpful to resume play once browser policies have been satisfied.
  29150. */
  29151. unlock(): void;
  29152. }
  29153. /**
  29154. * This represents the default audio engine used in babylon.
  29155. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29157. */
  29158. export class AudioEngine implements IAudioEngine {
  29159. private _audioContext;
  29160. private _audioContextInitialized;
  29161. private _muteButton;
  29162. private _hostElement;
  29163. /**
  29164. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29165. */
  29166. canUseWebAudio: boolean;
  29167. /**
  29168. * The master gain node defines the global audio volume of your audio engine.
  29169. */
  29170. masterGain: GainNode;
  29171. /**
  29172. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29173. * @ignoreNaming
  29174. */
  29175. WarnedWebAudioUnsupported: boolean;
  29176. /**
  29177. * Gets whether or not mp3 are supported by your browser.
  29178. */
  29179. isMP3supported: boolean;
  29180. /**
  29181. * Gets whether or not ogg are supported by your browser.
  29182. */
  29183. isOGGsupported: boolean;
  29184. /**
  29185. * Gets whether audio has been unlocked on the device.
  29186. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29187. * a user interaction has happened.
  29188. */
  29189. unlocked: boolean;
  29190. /**
  29191. * Defines if the audio engine relies on a custom unlocked button.
  29192. * In this case, the embedded button will not be displayed.
  29193. */
  29194. useCustomUnlockedButton: boolean;
  29195. /**
  29196. * Event raised when audio has been unlocked on the browser.
  29197. */
  29198. onAudioUnlockedObservable: Observable<AudioEngine>;
  29199. /**
  29200. * Event raised when audio has been locked on the browser.
  29201. */
  29202. onAudioLockedObservable: Observable<AudioEngine>;
  29203. /**
  29204. * Gets the current AudioContext if available.
  29205. */
  29206. readonly audioContext: Nullable<AudioContext>;
  29207. private _connectedAnalyser;
  29208. /**
  29209. * Instantiates a new audio engine.
  29210. *
  29211. * There should be only one per page as some browsers restrict the number
  29212. * of audio contexts you can create.
  29213. * @param hostElement defines the host element where to display the mute icon if necessary
  29214. */
  29215. constructor(hostElement?: Nullable<HTMLElement>);
  29216. /**
  29217. * Flags the audio engine in Locked state.
  29218. * This happens due to new browser policies preventing audio to autoplay.
  29219. */
  29220. lock(): void;
  29221. /**
  29222. * Unlocks the audio engine once a user action has been done on the dom.
  29223. * This is helpful to resume play once browser policies have been satisfied.
  29224. */
  29225. unlock(): void;
  29226. private _resumeAudioContext;
  29227. private _initializeAudioContext;
  29228. private _tryToRun;
  29229. private _triggerRunningState;
  29230. private _triggerSuspendedState;
  29231. private _displayMuteButton;
  29232. private _moveButtonToTopLeft;
  29233. private _onResize;
  29234. private _hideMuteButton;
  29235. /**
  29236. * Destroy and release the resources associated with the audio ccontext.
  29237. */
  29238. dispose(): void;
  29239. /**
  29240. * Gets the global volume sets on the master gain.
  29241. * @returns the global volume if set or -1 otherwise
  29242. */
  29243. getGlobalVolume(): number;
  29244. /**
  29245. * Sets the global volume of your experience (sets on the master gain).
  29246. * @param newVolume Defines the new global volume of the application
  29247. */
  29248. setGlobalVolume(newVolume: number): void;
  29249. /**
  29250. * Connect the audio engine to an audio analyser allowing some amazing
  29251. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29253. * @param analyser The analyser to connect to the engine
  29254. */
  29255. connectToAnalyser(analyser: Analyser): void;
  29256. }
  29257. }
  29258. declare module BABYLON {
  29259. /**
  29260. * Interface used to present a loading screen while loading a scene
  29261. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29262. */
  29263. export interface ILoadingScreen {
  29264. /**
  29265. * Function called to display the loading screen
  29266. */
  29267. displayLoadingUI: () => void;
  29268. /**
  29269. * Function called to hide the loading screen
  29270. */
  29271. hideLoadingUI: () => void;
  29272. /**
  29273. * Gets or sets the color to use for the background
  29274. */
  29275. loadingUIBackgroundColor: string;
  29276. /**
  29277. * Gets or sets the text to display while loading
  29278. */
  29279. loadingUIText: string;
  29280. }
  29281. /**
  29282. * Class used for the default loading screen
  29283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29284. */
  29285. export class DefaultLoadingScreen implements ILoadingScreen {
  29286. private _renderingCanvas;
  29287. private _loadingText;
  29288. private _loadingDivBackgroundColor;
  29289. private _loadingDiv;
  29290. private _loadingTextDiv;
  29291. /** Gets or sets the logo url to use for the default loading screen */
  29292. static DefaultLogoUrl: string;
  29293. /** Gets or sets the spinner url to use for the default loading screen */
  29294. static DefaultSpinnerUrl: string;
  29295. /**
  29296. * Creates a new default loading screen
  29297. * @param _renderingCanvas defines the canvas used to render the scene
  29298. * @param _loadingText defines the default text to display
  29299. * @param _loadingDivBackgroundColor defines the default background color
  29300. */
  29301. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29302. /**
  29303. * Function called to display the loading screen
  29304. */
  29305. displayLoadingUI(): void;
  29306. /**
  29307. * Function called to hide the loading screen
  29308. */
  29309. hideLoadingUI(): void;
  29310. /**
  29311. * Gets or sets the text to display while loading
  29312. */
  29313. loadingUIText: string;
  29314. /**
  29315. * Gets or sets the color to use for the background
  29316. */
  29317. loadingUIBackgroundColor: string;
  29318. private _resizeLoadingUI;
  29319. }
  29320. }
  29321. declare module BABYLON {
  29322. /** @hidden */
  29323. export class WebGLPipelineContext implements IPipelineContext {
  29324. engine: Engine;
  29325. program: Nullable<WebGLProgram>;
  29326. context?: WebGLRenderingContext;
  29327. vertexShader?: WebGLShader;
  29328. fragmentShader?: WebGLShader;
  29329. isParallelCompiled: boolean;
  29330. onCompiled?: () => void;
  29331. transformFeedback?: WebGLTransformFeedback | null;
  29332. readonly isAsync: boolean;
  29333. readonly isReady: boolean;
  29334. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29335. }
  29336. }
  29337. declare module BABYLON {
  29338. /** @hidden */
  29339. export class WebGLDataBuffer extends DataBuffer {
  29340. private _buffer;
  29341. constructor(resource: WebGLBuffer);
  29342. readonly underlyingResource: any;
  29343. }
  29344. }
  29345. declare module BABYLON {
  29346. /** @hidden */
  29347. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29348. attributeProcessor(attribute: string): string;
  29349. varyingProcessor(varying: string, isFragment: boolean): string;
  29350. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29351. }
  29352. }
  29353. declare module BABYLON {
  29354. /**
  29355. * This class is used to track a performance counter which is number based.
  29356. * The user has access to many properties which give statistics of different nature.
  29357. *
  29358. * The implementer can track two kinds of Performance Counter: time and count.
  29359. * 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.
  29360. * 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.
  29361. */
  29362. export class PerfCounter {
  29363. /**
  29364. * Gets or sets a global boolean to turn on and off all the counters
  29365. */
  29366. static Enabled: boolean;
  29367. /**
  29368. * Returns the smallest value ever
  29369. */
  29370. readonly min: number;
  29371. /**
  29372. * Returns the biggest value ever
  29373. */
  29374. readonly max: number;
  29375. /**
  29376. * Returns the average value since the performance counter is running
  29377. */
  29378. readonly average: number;
  29379. /**
  29380. * Returns the average value of the last second the counter was monitored
  29381. */
  29382. readonly lastSecAverage: number;
  29383. /**
  29384. * Returns the current value
  29385. */
  29386. readonly current: number;
  29387. /**
  29388. * Gets the accumulated total
  29389. */
  29390. readonly total: number;
  29391. /**
  29392. * Gets the total value count
  29393. */
  29394. readonly count: number;
  29395. /**
  29396. * Creates a new counter
  29397. */
  29398. constructor();
  29399. /**
  29400. * Call this method to start monitoring a new frame.
  29401. * 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.
  29402. */
  29403. fetchNewFrame(): void;
  29404. /**
  29405. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29406. * @param newCount the count value to add to the monitored count
  29407. * @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.
  29408. */
  29409. addCount(newCount: number, fetchResult: boolean): void;
  29410. /**
  29411. * Start monitoring this performance counter
  29412. */
  29413. beginMonitoring(): void;
  29414. /**
  29415. * Compute the time lapsed since the previous beginMonitoring() call.
  29416. * @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
  29417. */
  29418. endMonitoring(newFrame?: boolean): void;
  29419. private _fetchResult;
  29420. private _startMonitoringTime;
  29421. private _min;
  29422. private _max;
  29423. private _average;
  29424. private _current;
  29425. private _totalValueCount;
  29426. private _totalAccumulated;
  29427. private _lastSecAverage;
  29428. private _lastSecAccumulated;
  29429. private _lastSecTime;
  29430. private _lastSecValueCount;
  29431. }
  29432. }
  29433. declare module BABYLON {
  29434. /**
  29435. * Interface for any object that can request an animation frame
  29436. */
  29437. export interface ICustomAnimationFrameRequester {
  29438. /**
  29439. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29440. */
  29441. renderFunction?: Function;
  29442. /**
  29443. * Called to request the next frame to render to
  29444. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29445. */
  29446. requestAnimationFrame: Function;
  29447. /**
  29448. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29449. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29450. */
  29451. requestID?: number;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * Settings for finer control over video usage
  29457. */
  29458. export interface VideoTextureSettings {
  29459. /**
  29460. * Applies `autoplay` to video, if specified
  29461. */
  29462. autoPlay?: boolean;
  29463. /**
  29464. * Applies `loop` to video, if specified
  29465. */
  29466. loop?: boolean;
  29467. /**
  29468. * Automatically updates internal texture from video at every frame in the render loop
  29469. */
  29470. autoUpdateTexture: boolean;
  29471. /**
  29472. * Image src displayed during the video loading or until the user interacts with the video.
  29473. */
  29474. poster?: string;
  29475. }
  29476. /**
  29477. * If you want to display a video in your scene, this is the special texture for that.
  29478. * This special texture works similar to other textures, with the exception of a few parameters.
  29479. * @see https://doc.babylonjs.com/how_to/video_texture
  29480. */
  29481. export class VideoTexture extends Texture {
  29482. /**
  29483. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29484. */
  29485. readonly autoUpdateTexture: boolean;
  29486. /**
  29487. * The video instance used by the texture internally
  29488. */
  29489. readonly video: HTMLVideoElement;
  29490. private _onUserActionRequestedObservable;
  29491. /**
  29492. * Event triggerd when a dom action is required by the user to play the video.
  29493. * This happens due to recent changes in browser policies preventing video to auto start.
  29494. */
  29495. readonly onUserActionRequestedObservable: Observable<Texture>;
  29496. private _generateMipMaps;
  29497. private _engine;
  29498. private _stillImageCaptured;
  29499. private _displayingPosterTexture;
  29500. private _settings;
  29501. private _createInternalTextureOnEvent;
  29502. private _frameId;
  29503. /**
  29504. * Creates a video texture.
  29505. * If you want to display a video in your scene, this is the special texture for that.
  29506. * This special texture works similar to other textures, with the exception of a few parameters.
  29507. * @see https://doc.babylonjs.com/how_to/video_texture
  29508. * @param name optional name, will detect from video source, if not defined
  29509. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29510. * @param scene is obviously the current scene.
  29511. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29512. * @param invertY is false by default but can be used to invert video on Y axis
  29513. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29514. * @param settings allows finer control over video usage
  29515. */
  29516. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29517. private _getName;
  29518. private _getVideo;
  29519. private _createInternalTexture;
  29520. private reset;
  29521. /**
  29522. * @hidden Internal method to initiate `update`.
  29523. */
  29524. _rebuild(): void;
  29525. /**
  29526. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29527. */
  29528. update(): void;
  29529. /**
  29530. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29531. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29532. */
  29533. updateTexture(isVisible: boolean): void;
  29534. protected _updateInternalTexture: () => void;
  29535. /**
  29536. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29537. * @param url New url.
  29538. */
  29539. updateURL(url: string): void;
  29540. /**
  29541. * Dispose the texture and release its associated resources.
  29542. */
  29543. dispose(): void;
  29544. /**
  29545. * Creates a video texture straight from a stream.
  29546. * @param scene Define the scene the texture should be created in
  29547. * @param stream Define the stream the texture should be created from
  29548. * @returns The created video texture as a promise
  29549. */
  29550. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29551. /**
  29552. * Creates a video texture straight from your WebCam video feed.
  29553. * @param scene Define the scene the texture should be created in
  29554. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29555. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29556. * @returns The created video texture as a promise
  29557. */
  29558. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29559. minWidth: number;
  29560. maxWidth: number;
  29561. minHeight: number;
  29562. maxHeight: number;
  29563. deviceId: string;
  29564. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29565. /**
  29566. * Creates a video texture straight from your WebCam video feed.
  29567. * @param scene Define the scene the texture should be created in
  29568. * @param onReady Define a callback to triggered once the texture will be ready
  29569. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29570. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29571. */
  29572. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29573. minWidth: number;
  29574. maxWidth: number;
  29575. minHeight: number;
  29576. maxHeight: number;
  29577. deviceId: string;
  29578. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29579. }
  29580. }
  29581. declare module BABYLON {
  29582. /**
  29583. * Defines the interface used by objects containing a viewport (like a camera)
  29584. */
  29585. interface IViewportOwnerLike {
  29586. /**
  29587. * Gets or sets the viewport
  29588. */
  29589. viewport: IViewportLike;
  29590. }
  29591. /**
  29592. * Interface for attribute information associated with buffer instanciation
  29593. */
  29594. export class InstancingAttributeInfo {
  29595. /**
  29596. * Index/offset of the attribute in the vertex shader
  29597. */
  29598. index: number;
  29599. /**
  29600. * size of the attribute, 1, 2, 3 or 4
  29601. */
  29602. attributeSize: number;
  29603. /**
  29604. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29605. * default is FLOAT
  29606. */
  29607. attribyteType: number;
  29608. /**
  29609. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29610. */
  29611. normalized: boolean;
  29612. /**
  29613. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29614. */
  29615. offset: number;
  29616. /**
  29617. * Name of the GLSL attribute, for debugging purpose only
  29618. */
  29619. attributeName: string;
  29620. }
  29621. /**
  29622. * Define options used to create a depth texture
  29623. */
  29624. export class DepthTextureCreationOptions {
  29625. /** Specifies whether or not a stencil should be allocated in the texture */
  29626. generateStencil?: boolean;
  29627. /** Specifies whether or not bilinear filtering is enable on the texture */
  29628. bilinearFiltering?: boolean;
  29629. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29630. comparisonFunction?: number;
  29631. /** Specifies if the created texture is a cube texture */
  29632. isCube?: boolean;
  29633. }
  29634. /**
  29635. * Class used to describe the capabilities of the engine relatively to the current browser
  29636. */
  29637. export class EngineCapabilities {
  29638. /** Maximum textures units per fragment shader */
  29639. maxTexturesImageUnits: number;
  29640. /** Maximum texture units per vertex shader */
  29641. maxVertexTextureImageUnits: number;
  29642. /** Maximum textures units in the entire pipeline */
  29643. maxCombinedTexturesImageUnits: number;
  29644. /** Maximum texture size */
  29645. maxTextureSize: number;
  29646. /** Maximum cube texture size */
  29647. maxCubemapTextureSize: number;
  29648. /** Maximum render texture size */
  29649. maxRenderTextureSize: number;
  29650. /** Maximum number of vertex attributes */
  29651. maxVertexAttribs: number;
  29652. /** Maximum number of varyings */
  29653. maxVaryingVectors: number;
  29654. /** Maximum number of uniforms per vertex shader */
  29655. maxVertexUniformVectors: number;
  29656. /** Maximum number of uniforms per fragment shader */
  29657. maxFragmentUniformVectors: number;
  29658. /** Defines if standard derivates (dx/dy) are supported */
  29659. standardDerivatives: boolean;
  29660. /** Defines if s3tc texture compression is supported */
  29661. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29662. /** Defines if pvrtc texture compression is supported */
  29663. pvrtc: any;
  29664. /** Defines if etc1 texture compression is supported */
  29665. etc1: any;
  29666. /** Defines if etc2 texture compression is supported */
  29667. etc2: any;
  29668. /** Defines if astc texture compression is supported */
  29669. astc: any;
  29670. /** Defines if float textures are supported */
  29671. textureFloat: boolean;
  29672. /** Defines if vertex array objects are supported */
  29673. vertexArrayObject: boolean;
  29674. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29675. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29676. /** Gets the maximum level of anisotropy supported */
  29677. maxAnisotropy: number;
  29678. /** Defines if instancing is supported */
  29679. instancedArrays: boolean;
  29680. /** Defines if 32 bits indices are supported */
  29681. uintIndices: boolean;
  29682. /** Defines if high precision shaders are supported */
  29683. highPrecisionShaderSupported: boolean;
  29684. /** Defines if depth reading in the fragment shader is supported */
  29685. fragmentDepthSupported: boolean;
  29686. /** Defines if float texture linear filtering is supported*/
  29687. textureFloatLinearFiltering: boolean;
  29688. /** Defines if rendering to float textures is supported */
  29689. textureFloatRender: boolean;
  29690. /** Defines if half float textures are supported*/
  29691. textureHalfFloat: boolean;
  29692. /** Defines if half float texture linear filtering is supported*/
  29693. textureHalfFloatLinearFiltering: boolean;
  29694. /** Defines if rendering to half float textures is supported */
  29695. textureHalfFloatRender: boolean;
  29696. /** Defines if textureLOD shader command is supported */
  29697. textureLOD: boolean;
  29698. /** Defines if draw buffers extension is supported */
  29699. drawBuffersExtension: boolean;
  29700. /** Defines if depth textures are supported */
  29701. depthTextureExtension: boolean;
  29702. /** Defines if float color buffer are supported */
  29703. colorBufferFloat: boolean;
  29704. /** Gets disjoint timer query extension (null if not supported) */
  29705. timerQuery: EXT_disjoint_timer_query;
  29706. /** Defines if timestamp can be used with timer query */
  29707. canUseTimestampForTimerQuery: boolean;
  29708. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29709. multiview: any;
  29710. /** Function used to let the system compiles shaders in background */
  29711. parallelShaderCompile: {
  29712. COMPLETION_STATUS_KHR: number;
  29713. };
  29714. /** Max number of texture samples for MSAA */
  29715. maxMSAASamples: number;
  29716. }
  29717. /** Interface defining initialization parameters for Engine class */
  29718. export interface EngineOptions extends WebGLContextAttributes {
  29719. /**
  29720. * Defines if the engine should no exceed a specified device ratio
  29721. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29722. */
  29723. limitDeviceRatio?: number;
  29724. /**
  29725. * Defines if webvr should be enabled automatically
  29726. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29727. */
  29728. autoEnableWebVR?: boolean;
  29729. /**
  29730. * Defines if webgl2 should be turned off even if supported
  29731. * @see http://doc.babylonjs.com/features/webgl2
  29732. */
  29733. disableWebGL2Support?: boolean;
  29734. /**
  29735. * Defines if webaudio should be initialized as well
  29736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29737. */
  29738. audioEngine?: boolean;
  29739. /**
  29740. * Defines if animations should run using a deterministic lock step
  29741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29742. */
  29743. deterministicLockstep?: boolean;
  29744. /** Defines the maximum steps to use with deterministic lock step mode */
  29745. lockstepMaxSteps?: number;
  29746. /**
  29747. * Defines that engine should ignore context lost events
  29748. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29749. */
  29750. doNotHandleContextLost?: boolean;
  29751. /**
  29752. * Defines that engine should ignore modifying touch action attribute and style
  29753. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29754. */
  29755. doNotHandleTouchAction?: boolean;
  29756. /**
  29757. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29758. */
  29759. useHighPrecisionFloats?: boolean;
  29760. }
  29761. /**
  29762. * Defines the interface used by display changed events
  29763. */
  29764. export interface IDisplayChangedEventArgs {
  29765. /** Gets the vrDisplay object (if any) */
  29766. vrDisplay: Nullable<any>;
  29767. /** Gets a boolean indicating if webVR is supported */
  29768. vrSupported: boolean;
  29769. }
  29770. /**
  29771. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29772. */
  29773. export class Engine {
  29774. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29775. static ExceptionList: ({
  29776. key: string;
  29777. capture: string;
  29778. captureConstraint: number;
  29779. targets: string[];
  29780. } | {
  29781. key: string;
  29782. capture: null;
  29783. captureConstraint: null;
  29784. targets: string[];
  29785. })[];
  29786. /** Gets the list of created engines */
  29787. static readonly Instances: Engine[];
  29788. /**
  29789. * Gets the latest created engine
  29790. */
  29791. static readonly LastCreatedEngine: Nullable<Engine>;
  29792. /**
  29793. * Gets the latest created scene
  29794. */
  29795. static readonly LastCreatedScene: Nullable<Scene>;
  29796. /**
  29797. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29798. * @param flag defines which part of the materials must be marked as dirty
  29799. * @param predicate defines a predicate used to filter which materials should be affected
  29800. */
  29801. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29802. /** @hidden */
  29803. static _TextureLoaders: IInternalTextureLoader[];
  29804. /** Defines that alpha blending is disabled */
  29805. static readonly ALPHA_DISABLE: number;
  29806. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29807. static readonly ALPHA_ADD: number;
  29808. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29809. static readonly ALPHA_COMBINE: number;
  29810. /** Defines that alpha blending to DEST - SRC * DEST */
  29811. static readonly ALPHA_SUBTRACT: number;
  29812. /** Defines that alpha blending to SRC * DEST */
  29813. static readonly ALPHA_MULTIPLY: number;
  29814. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29815. static readonly ALPHA_MAXIMIZED: number;
  29816. /** Defines that alpha blending to SRC + DEST */
  29817. static readonly ALPHA_ONEONE: number;
  29818. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29819. static readonly ALPHA_PREMULTIPLIED: number;
  29820. /**
  29821. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29822. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29823. */
  29824. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29825. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29826. static readonly ALPHA_INTERPOLATE: number;
  29827. /**
  29828. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29829. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29830. */
  29831. static readonly ALPHA_SCREENMODE: number;
  29832. /** Defines that the ressource is not delayed*/
  29833. static readonly DELAYLOADSTATE_NONE: number;
  29834. /** Defines that the ressource was successfully delay loaded */
  29835. static readonly DELAYLOADSTATE_LOADED: number;
  29836. /** Defines that the ressource is currently delay loading */
  29837. static readonly DELAYLOADSTATE_LOADING: number;
  29838. /** Defines that the ressource is delayed and has not started loading */
  29839. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29841. static readonly NEVER: number;
  29842. /** 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 */
  29843. static readonly ALWAYS: number;
  29844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29845. static readonly LESS: number;
  29846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29847. static readonly EQUAL: number;
  29848. /** 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 */
  29849. static readonly LEQUAL: number;
  29850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29851. static readonly GREATER: number;
  29852. /** 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 */
  29853. static readonly GEQUAL: number;
  29854. /** 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 */
  29855. static readonly NOTEQUAL: number;
  29856. /** Passed to stencilOperation to specify that stencil value must be kept */
  29857. static readonly KEEP: number;
  29858. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29859. static readonly REPLACE: number;
  29860. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29861. static readonly INCR: number;
  29862. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29863. static readonly DECR: number;
  29864. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29865. static readonly INVERT: number;
  29866. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29867. static readonly INCR_WRAP: number;
  29868. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29869. static readonly DECR_WRAP: number;
  29870. /** Texture is not repeating outside of 0..1 UVs */
  29871. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29872. /** Texture is repeating outside of 0..1 UVs */
  29873. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29874. /** Texture is repeating and mirrored */
  29875. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29876. /** ALPHA */
  29877. static readonly TEXTUREFORMAT_ALPHA: number;
  29878. /** LUMINANCE */
  29879. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29880. /** LUMINANCE_ALPHA */
  29881. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29882. /** RGB */
  29883. static readonly TEXTUREFORMAT_RGB: number;
  29884. /** RGBA */
  29885. static readonly TEXTUREFORMAT_RGBA: number;
  29886. /** RED */
  29887. static readonly TEXTUREFORMAT_RED: number;
  29888. /** RED (2nd reference) */
  29889. static readonly TEXTUREFORMAT_R: number;
  29890. /** RG */
  29891. static readonly TEXTUREFORMAT_RG: number;
  29892. /** RED_INTEGER */
  29893. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29894. /** RED_INTEGER (2nd reference) */
  29895. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29896. /** RG_INTEGER */
  29897. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29898. /** RGB_INTEGER */
  29899. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29900. /** RGBA_INTEGER */
  29901. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29902. /** UNSIGNED_BYTE */
  29903. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29904. /** UNSIGNED_BYTE (2nd reference) */
  29905. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29906. /** FLOAT */
  29907. static readonly TEXTURETYPE_FLOAT: number;
  29908. /** HALF_FLOAT */
  29909. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29910. /** BYTE */
  29911. static readonly TEXTURETYPE_BYTE: number;
  29912. /** SHORT */
  29913. static readonly TEXTURETYPE_SHORT: number;
  29914. /** UNSIGNED_SHORT */
  29915. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29916. /** INT */
  29917. static readonly TEXTURETYPE_INT: number;
  29918. /** UNSIGNED_INT */
  29919. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29920. /** UNSIGNED_SHORT_4_4_4_4 */
  29921. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29922. /** UNSIGNED_SHORT_5_5_5_1 */
  29923. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29924. /** UNSIGNED_SHORT_5_6_5 */
  29925. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29926. /** UNSIGNED_INT_2_10_10_10_REV */
  29927. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29928. /** UNSIGNED_INT_24_8 */
  29929. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29930. /** UNSIGNED_INT_10F_11F_11F_REV */
  29931. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29932. /** UNSIGNED_INT_5_9_9_9_REV */
  29933. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29934. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29935. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29936. /** nearest is mag = nearest and min = nearest and mip = linear */
  29937. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29938. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29939. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29940. /** Trilinear is mag = linear and min = linear and mip = linear */
  29941. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29942. /** nearest is mag = nearest and min = nearest and mip = linear */
  29943. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29944. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29945. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29946. /** Trilinear is mag = linear and min = linear and mip = linear */
  29947. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29948. /** mag = nearest and min = nearest and mip = nearest */
  29949. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29950. /** mag = nearest and min = linear and mip = nearest */
  29951. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29952. /** mag = nearest and min = linear and mip = linear */
  29953. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29954. /** mag = nearest and min = linear and mip = none */
  29955. static readonly TEXTURE_NEAREST_LINEAR: number;
  29956. /** mag = nearest and min = nearest and mip = none */
  29957. static readonly TEXTURE_NEAREST_NEAREST: number;
  29958. /** mag = linear and min = nearest and mip = nearest */
  29959. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29960. /** mag = linear and min = nearest and mip = linear */
  29961. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29962. /** mag = linear and min = linear and mip = none */
  29963. static readonly TEXTURE_LINEAR_LINEAR: number;
  29964. /** mag = linear and min = nearest and mip = none */
  29965. static readonly TEXTURE_LINEAR_NEAREST: number;
  29966. /** Explicit coordinates mode */
  29967. static readonly TEXTURE_EXPLICIT_MODE: number;
  29968. /** Spherical coordinates mode */
  29969. static readonly TEXTURE_SPHERICAL_MODE: number;
  29970. /** Planar coordinates mode */
  29971. static readonly TEXTURE_PLANAR_MODE: number;
  29972. /** Cubic coordinates mode */
  29973. static readonly TEXTURE_CUBIC_MODE: number;
  29974. /** Projection coordinates mode */
  29975. static readonly TEXTURE_PROJECTION_MODE: number;
  29976. /** Skybox coordinates mode */
  29977. static readonly TEXTURE_SKYBOX_MODE: number;
  29978. /** Inverse Cubic coordinates mode */
  29979. static readonly TEXTURE_INVCUBIC_MODE: number;
  29980. /** Equirectangular coordinates mode */
  29981. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29982. /** Equirectangular Fixed coordinates mode */
  29983. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29984. /** Equirectangular Fixed Mirrored coordinates mode */
  29985. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29986. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29987. static readonly SCALEMODE_FLOOR: number;
  29988. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29989. static readonly SCALEMODE_NEAREST: number;
  29990. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29991. static readonly SCALEMODE_CEILING: number;
  29992. /**
  29993. * Returns the current npm package of the sdk
  29994. */
  29995. static readonly NpmPackage: string;
  29996. /**
  29997. * Returns the current version of the framework
  29998. */
  29999. static readonly Version: string;
  30000. /**
  30001. * Returns a string describing the current engine
  30002. */
  30003. readonly description: string;
  30004. /**
  30005. * Gets or sets the epsilon value used by collision engine
  30006. */
  30007. static CollisionsEpsilon: number;
  30008. /**
  30009. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30010. */
  30011. static ShadersRepository: string;
  30012. /**
  30013. * Method called to create the default loading screen.
  30014. * This can be overriden in your own app.
  30015. * @param canvas The rendering canvas element
  30016. * @returns The loading screen
  30017. */
  30018. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30019. /**
  30020. * Method called to create the default rescale post process on each engine.
  30021. */
  30022. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30023. /** @hidden */
  30024. _shaderProcessor: IShaderProcessor;
  30025. /**
  30026. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30027. */
  30028. forcePOTTextures: boolean;
  30029. /**
  30030. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30031. */
  30032. isFullscreen: boolean;
  30033. /**
  30034. * Gets a boolean indicating if the pointer is currently locked
  30035. */
  30036. isPointerLock: boolean;
  30037. /**
  30038. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30039. */
  30040. cullBackFaces: boolean;
  30041. /**
  30042. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30043. */
  30044. renderEvenInBackground: boolean;
  30045. /**
  30046. * Gets or sets a boolean indicating that cache can be kept between frames
  30047. */
  30048. preventCacheWipeBetweenFrames: boolean;
  30049. /**
  30050. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30051. **/
  30052. enableOfflineSupport: boolean;
  30053. /**
  30054. * 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)
  30055. **/
  30056. disableManifestCheck: boolean;
  30057. /**
  30058. * Gets the list of created scenes
  30059. */
  30060. scenes: Scene[];
  30061. /**
  30062. * Event raised when a new scene is created
  30063. */
  30064. onNewSceneAddedObservable: Observable<Scene>;
  30065. /**
  30066. * Gets the list of created postprocesses
  30067. */
  30068. postProcesses: PostProcess[];
  30069. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30070. validateShaderPrograms: boolean;
  30071. /**
  30072. * Observable event triggered each time the rendering canvas is resized
  30073. */
  30074. onResizeObservable: Observable<Engine>;
  30075. /**
  30076. * Observable event triggered each time the canvas loses focus
  30077. */
  30078. onCanvasBlurObservable: Observable<Engine>;
  30079. /**
  30080. * Observable event triggered each time the canvas gains focus
  30081. */
  30082. onCanvasFocusObservable: Observable<Engine>;
  30083. /**
  30084. * Observable event triggered each time the canvas receives pointerout event
  30085. */
  30086. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30087. /**
  30088. * Observable event triggered before each texture is initialized
  30089. */
  30090. onBeforeTextureInitObservable: Observable<Texture>;
  30091. /**
  30092. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30093. */
  30094. disableUniformBuffers: boolean;
  30095. /** @hidden */
  30096. _uniformBuffers: UniformBuffer[];
  30097. /**
  30098. * Gets a boolean indicating that the engine supports uniform buffers
  30099. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30100. */
  30101. readonly supportsUniformBuffers: boolean;
  30102. /**
  30103. * Observable raised when the engine begins a new frame
  30104. */
  30105. onBeginFrameObservable: Observable<Engine>;
  30106. /**
  30107. * If set, will be used to request the next animation frame for the render loop
  30108. */
  30109. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30110. /**
  30111. * Observable raised when the engine ends the current frame
  30112. */
  30113. onEndFrameObservable: Observable<Engine>;
  30114. /**
  30115. * Observable raised when the engine is about to compile a shader
  30116. */
  30117. onBeforeShaderCompilationObservable: Observable<Engine>;
  30118. /**
  30119. * Observable raised when the engine has jsut compiled a shader
  30120. */
  30121. onAfterShaderCompilationObservable: Observable<Engine>;
  30122. /** @hidden */
  30123. _gl: WebGLRenderingContext;
  30124. private _renderingCanvas;
  30125. private _windowIsBackground;
  30126. protected _webGLVersion: number;
  30127. protected _highPrecisionShadersAllowed: boolean;
  30128. /** @hidden */
  30129. readonly _shouldUseHighPrecisionShader: boolean;
  30130. /**
  30131. * Gets a boolean indicating that only power of 2 textures are supported
  30132. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30133. */
  30134. readonly needPOTTextures: boolean;
  30135. /** @hidden */
  30136. _badOS: boolean;
  30137. /** @hidden */
  30138. _badDesktopOS: boolean;
  30139. /**
  30140. * Gets the audio engine
  30141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30142. * @ignorenaming
  30143. */
  30144. static audioEngine: IAudioEngine;
  30145. /**
  30146. * Default AudioEngine factory responsible of creating the Audio Engine.
  30147. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30148. */
  30149. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30150. /**
  30151. * Default offline support factory responsible of creating a tool used to store data locally.
  30152. * By default, this will create a Database object if the workload has been embedded.
  30153. */
  30154. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30155. private _onFocus;
  30156. private _onBlur;
  30157. private _onCanvasPointerOut;
  30158. private _onCanvasBlur;
  30159. private _onCanvasFocus;
  30160. private _onFullscreenChange;
  30161. private _onPointerLockChange;
  30162. private _hardwareScalingLevel;
  30163. /** @hidden */
  30164. _caps: EngineCapabilities;
  30165. private _pointerLockRequested;
  30166. private _isStencilEnable;
  30167. protected _colorWrite: boolean;
  30168. private _loadingScreen;
  30169. /** @hidden */
  30170. _drawCalls: PerfCounter;
  30171. private _glVersion;
  30172. private _glRenderer;
  30173. private _glVendor;
  30174. private _videoTextureSupported;
  30175. private _renderingQueueLaunched;
  30176. private _activeRenderLoops;
  30177. private _deterministicLockstep;
  30178. private _lockstepMaxSteps;
  30179. /**
  30180. * Observable signaled when a context lost event is raised
  30181. */
  30182. onContextLostObservable: Observable<Engine>;
  30183. /**
  30184. * Observable signaled when a context restored event is raised
  30185. */
  30186. onContextRestoredObservable: Observable<Engine>;
  30187. private _onContextLost;
  30188. private _onContextRestored;
  30189. private _contextWasLost;
  30190. /** @hidden */
  30191. _doNotHandleContextLost: boolean;
  30192. /**
  30193. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30195. */
  30196. doNotHandleContextLost: boolean;
  30197. private _performanceMonitor;
  30198. private _fps;
  30199. private _deltaTime;
  30200. /**
  30201. * Turn this value on if you want to pause FPS computation when in background
  30202. */
  30203. disablePerformanceMonitorInBackground: boolean;
  30204. /**
  30205. * Gets the performance monitor attached to this engine
  30206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30207. */
  30208. readonly performanceMonitor: PerformanceMonitor;
  30209. /**
  30210. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30211. */
  30212. disableVertexArrayObjects: boolean;
  30213. /** @hidden */
  30214. protected _depthCullingState: _DepthCullingState;
  30215. /** @hidden */
  30216. protected _stencilState: _StencilState;
  30217. /** @hidden */
  30218. protected _alphaState: _AlphaState;
  30219. /** @hidden */
  30220. protected _alphaMode: number;
  30221. /** @hidden */
  30222. _internalTexturesCache: InternalTexture[];
  30223. /** @hidden */
  30224. protected _activeChannel: number;
  30225. private _currentTextureChannel;
  30226. /** @hidden */
  30227. protected _boundTexturesCache: {
  30228. [key: string]: Nullable<InternalTexture>;
  30229. };
  30230. /** @hidden */
  30231. protected _currentEffect: Nullable<Effect>;
  30232. /** @hidden */
  30233. protected _currentProgram: Nullable<WebGLProgram>;
  30234. private _compiledEffects;
  30235. private _vertexAttribArraysEnabled;
  30236. /** @hidden */
  30237. protected _cachedViewport: Nullable<IViewportLike>;
  30238. private _cachedVertexArrayObject;
  30239. /** @hidden */
  30240. protected _cachedVertexBuffers: any;
  30241. /** @hidden */
  30242. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30243. /** @hidden */
  30244. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30245. /** @hidden */
  30246. _currentRenderTarget: Nullable<InternalTexture>;
  30247. private _uintIndicesCurrentlySet;
  30248. private _currentBoundBuffer;
  30249. /** @hidden */
  30250. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30251. private _currentBufferPointers;
  30252. private _currentInstanceLocations;
  30253. private _currentInstanceBuffers;
  30254. private _textureUnits;
  30255. /** @hidden */
  30256. _workingCanvas: Nullable<HTMLCanvasElement>;
  30257. /** @hidden */
  30258. _workingContext: Nullable<CanvasRenderingContext2D>;
  30259. private _rescalePostProcess;
  30260. private _dummyFramebuffer;
  30261. private _externalData;
  30262. /** @hidden */
  30263. _bindedRenderFunction: any;
  30264. private _vaoRecordInProgress;
  30265. private _mustWipeVertexAttributes;
  30266. private _emptyTexture;
  30267. private _emptyCubeTexture;
  30268. private _emptyTexture3D;
  30269. /** @hidden */
  30270. _frameHandler: number;
  30271. private _nextFreeTextureSlots;
  30272. private _maxSimultaneousTextures;
  30273. private _activeRequests;
  30274. private _texturesSupported;
  30275. /** @hidden */
  30276. _textureFormatInUse: Nullable<string>;
  30277. /**
  30278. * Gets the list of texture formats supported
  30279. */
  30280. readonly texturesSupported: Array<string>;
  30281. /**
  30282. * Gets the list of texture formats in use
  30283. */
  30284. readonly textureFormatInUse: Nullable<string>;
  30285. /**
  30286. * Gets the current viewport
  30287. */
  30288. readonly currentViewport: Nullable<IViewportLike>;
  30289. /**
  30290. * Gets the default empty texture
  30291. */
  30292. readonly emptyTexture: InternalTexture;
  30293. /**
  30294. * Gets the default empty 3D texture
  30295. */
  30296. readonly emptyTexture3D: InternalTexture;
  30297. /**
  30298. * Gets the default empty cube texture
  30299. */
  30300. readonly emptyCubeTexture: InternalTexture;
  30301. /**
  30302. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30303. */
  30304. readonly premultipliedAlpha: boolean;
  30305. /**
  30306. * Creates a new engine
  30307. * @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
  30308. * @param antialias defines enable antialiasing (default: false)
  30309. * @param options defines further options to be sent to the getContext() function
  30310. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30311. */
  30312. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30313. /**
  30314. * Initializes a webVR display and starts listening to display change events
  30315. * The onVRDisplayChangedObservable will be notified upon these changes
  30316. * @returns The onVRDisplayChangedObservable
  30317. */
  30318. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30319. /** @hidden */
  30320. _prepareVRComponent(): void;
  30321. /** @hidden */
  30322. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30323. /** @hidden */
  30324. _submitVRFrame(): void;
  30325. /**
  30326. * Call this function to leave webVR mode
  30327. * Will do nothing if webVR is not supported or if there is no webVR device
  30328. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30329. */
  30330. disableVR(): void;
  30331. /**
  30332. * Gets a boolean indicating that the system is in VR mode and is presenting
  30333. * @returns true if VR mode is engaged
  30334. */
  30335. isVRPresenting(): boolean;
  30336. /** @hidden */
  30337. _requestVRFrame(): void;
  30338. private _disableTouchAction;
  30339. private _rebuildInternalTextures;
  30340. private _rebuildEffects;
  30341. /**
  30342. * Gets a boolean indicating if all created effects are ready
  30343. * @returns true if all effects are ready
  30344. */
  30345. areAllEffectsReady(): boolean;
  30346. private _rebuildBuffers;
  30347. private _initGLContext;
  30348. /**
  30349. * Gets version of the current webGL context
  30350. */
  30351. readonly webGLVersion: number;
  30352. /**
  30353. * Gets a string idenfifying the name of the class
  30354. * @returns "Engine" string
  30355. */
  30356. getClassName(): string;
  30357. /**
  30358. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30359. */
  30360. readonly isStencilEnable: boolean;
  30361. /** @hidden */
  30362. _prepareWorkingCanvas(): void;
  30363. /**
  30364. * Reset the texture cache to empty state
  30365. */
  30366. resetTextureCache(): void;
  30367. /**
  30368. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30370. * @returns true if engine is in deterministic lock step mode
  30371. */
  30372. isDeterministicLockStep(): boolean;
  30373. /**
  30374. * Gets the max steps when engine is running in deterministic lock step
  30375. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30376. * @returns the max steps
  30377. */
  30378. getLockstepMaxSteps(): number;
  30379. /**
  30380. * Gets an object containing information about the current webGL context
  30381. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30382. */
  30383. getGlInfo(): {
  30384. vendor: string;
  30385. renderer: string;
  30386. version: string;
  30387. };
  30388. /**
  30389. * Gets current aspect ratio
  30390. * @param viewportOwner defines the camera to use to get the aspect ratio
  30391. * @param useScreen defines if screen size must be used (or the current render target if any)
  30392. * @returns a number defining the aspect ratio
  30393. */
  30394. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30395. /**
  30396. * Gets current screen aspect ratio
  30397. * @returns a number defining the aspect ratio
  30398. */
  30399. getScreenAspectRatio(): number;
  30400. /**
  30401. * Gets the current render width
  30402. * @param useScreen defines if screen size must be used (or the current render target if any)
  30403. * @returns a number defining the current render width
  30404. */
  30405. getRenderWidth(useScreen?: boolean): number;
  30406. /**
  30407. * Gets the current render height
  30408. * @param useScreen defines if screen size must be used (or the current render target if any)
  30409. * @returns a number defining the current render height
  30410. */
  30411. getRenderHeight(useScreen?: boolean): number;
  30412. /**
  30413. * Gets the HTML canvas attached with the current webGL context
  30414. * @returns a HTML canvas
  30415. */
  30416. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30417. /**
  30418. * Gets host window
  30419. * @returns the host window object
  30420. */
  30421. getHostWindow(): Window;
  30422. /**
  30423. * Gets host document
  30424. * @returns the host document object
  30425. */
  30426. getHostDocument(): Document;
  30427. /**
  30428. * Gets the client rect of the HTML canvas attached with the current webGL context
  30429. * @returns a client rectanglee
  30430. */
  30431. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30432. /**
  30433. * Defines the hardware scaling level.
  30434. * By default the hardware scaling level is computed from the window device ratio.
  30435. * 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.
  30436. * @param level defines the level to use
  30437. */
  30438. setHardwareScalingLevel(level: number): void;
  30439. /**
  30440. * Gets the current hardware scaling level.
  30441. * By default the hardware scaling level is computed from the window device ratio.
  30442. * 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.
  30443. * @returns a number indicating the current hardware scaling level
  30444. */
  30445. getHardwareScalingLevel(): number;
  30446. /**
  30447. * Gets the list of loaded textures
  30448. * @returns an array containing all loaded textures
  30449. */
  30450. getLoadedTexturesCache(): InternalTexture[];
  30451. /**
  30452. * Gets the object containing all engine capabilities
  30453. * @returns the EngineCapabilities object
  30454. */
  30455. getCaps(): EngineCapabilities;
  30456. /**
  30457. * Gets the current depth function
  30458. * @returns a number defining the depth function
  30459. */
  30460. getDepthFunction(): Nullable<number>;
  30461. /**
  30462. * Sets the current depth function
  30463. * @param depthFunc defines the function to use
  30464. */
  30465. setDepthFunction(depthFunc: number): void;
  30466. /**
  30467. * Sets the current depth function to GREATER
  30468. */
  30469. setDepthFunctionToGreater(): void;
  30470. /**
  30471. * Sets the current depth function to GEQUAL
  30472. */
  30473. setDepthFunctionToGreaterOrEqual(): void;
  30474. /**
  30475. * Sets the current depth function to LESS
  30476. */
  30477. setDepthFunctionToLess(): void;
  30478. private _cachedStencilBuffer;
  30479. private _cachedStencilFunction;
  30480. private _cachedStencilMask;
  30481. private _cachedStencilOperationPass;
  30482. private _cachedStencilOperationFail;
  30483. private _cachedStencilOperationDepthFail;
  30484. private _cachedStencilReference;
  30485. /**
  30486. * Caches the the state of the stencil buffer
  30487. */
  30488. cacheStencilState(): void;
  30489. /**
  30490. * Restores the state of the stencil buffer
  30491. */
  30492. restoreStencilState(): void;
  30493. /**
  30494. * Sets the current depth function to LEQUAL
  30495. */
  30496. setDepthFunctionToLessOrEqual(): void;
  30497. /**
  30498. * Gets a boolean indicating if stencil buffer is enabled
  30499. * @returns the current stencil buffer state
  30500. */
  30501. getStencilBuffer(): boolean;
  30502. /**
  30503. * Enable or disable the stencil buffer
  30504. * @param enable defines if the stencil buffer must be enabled or disabled
  30505. */
  30506. setStencilBuffer(enable: boolean): void;
  30507. /**
  30508. * Gets the current stencil mask
  30509. * @returns a number defining the new stencil mask to use
  30510. */
  30511. getStencilMask(): number;
  30512. /**
  30513. * Sets the current stencil mask
  30514. * @param mask defines the new stencil mask to use
  30515. */
  30516. setStencilMask(mask: number): void;
  30517. /**
  30518. * Gets the current stencil function
  30519. * @returns a number defining the stencil function to use
  30520. */
  30521. getStencilFunction(): number;
  30522. /**
  30523. * Gets the current stencil reference value
  30524. * @returns a number defining the stencil reference value to use
  30525. */
  30526. getStencilFunctionReference(): number;
  30527. /**
  30528. * Gets the current stencil mask
  30529. * @returns a number defining the stencil mask to use
  30530. */
  30531. getStencilFunctionMask(): number;
  30532. /**
  30533. * Sets the current stencil function
  30534. * @param stencilFunc defines the new stencil function to use
  30535. */
  30536. setStencilFunction(stencilFunc: number): void;
  30537. /**
  30538. * Sets the current stencil reference
  30539. * @param reference defines the new stencil reference to use
  30540. */
  30541. setStencilFunctionReference(reference: number): void;
  30542. /**
  30543. * Sets the current stencil mask
  30544. * @param mask defines the new stencil mask to use
  30545. */
  30546. setStencilFunctionMask(mask: number): void;
  30547. /**
  30548. * Gets the current stencil operation when stencil fails
  30549. * @returns a number defining stencil operation to use when stencil fails
  30550. */
  30551. getStencilOperationFail(): number;
  30552. /**
  30553. * Gets the current stencil operation when depth fails
  30554. * @returns a number defining stencil operation to use when depth fails
  30555. */
  30556. getStencilOperationDepthFail(): number;
  30557. /**
  30558. * Gets the current stencil operation when stencil passes
  30559. * @returns a number defining stencil operation to use when stencil passes
  30560. */
  30561. getStencilOperationPass(): number;
  30562. /**
  30563. * Sets the stencil operation to use when stencil fails
  30564. * @param operation defines the stencil operation to use when stencil fails
  30565. */
  30566. setStencilOperationFail(operation: number): void;
  30567. /**
  30568. * Sets the stencil operation to use when depth fails
  30569. * @param operation defines the stencil operation to use when depth fails
  30570. */
  30571. setStencilOperationDepthFail(operation: number): void;
  30572. /**
  30573. * Sets the stencil operation to use when stencil passes
  30574. * @param operation defines the stencil operation to use when stencil passes
  30575. */
  30576. setStencilOperationPass(operation: number): void;
  30577. /**
  30578. * Sets a boolean indicating if the dithering state is enabled or disabled
  30579. * @param value defines the dithering state
  30580. */
  30581. setDitheringState(value: boolean): void;
  30582. /**
  30583. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30584. * @param value defines the rasterizer state
  30585. */
  30586. setRasterizerState(value: boolean): void;
  30587. /**
  30588. * stop executing a render loop function and remove it from the execution array
  30589. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30590. */
  30591. stopRenderLoop(renderFunction?: () => void): void;
  30592. /** @hidden */
  30593. _renderLoop(): void;
  30594. /**
  30595. * Can be used to override the current requestAnimationFrame requester.
  30596. * @hidden
  30597. */
  30598. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30599. /**
  30600. * Register and execute a render loop. The engine can have more than one render function
  30601. * @param renderFunction defines the function to continuously execute
  30602. */
  30603. runRenderLoop(renderFunction: () => void): void;
  30604. /**
  30605. * Toggle full screen mode
  30606. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30607. */
  30608. switchFullscreen(requestPointerLock: boolean): void;
  30609. /**
  30610. * Enters full screen mode
  30611. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30612. */
  30613. enterFullscreen(requestPointerLock: boolean): void;
  30614. /**
  30615. * Exits full screen mode
  30616. */
  30617. exitFullscreen(): void;
  30618. /**
  30619. * Enters Pointerlock mode
  30620. */
  30621. enterPointerlock(): void;
  30622. /**
  30623. * Exits Pointerlock mode
  30624. */
  30625. exitPointerlock(): void;
  30626. /**
  30627. * Clear the current render buffer or the current render target (if any is set up)
  30628. * @param color defines the color to use
  30629. * @param backBuffer defines if the back buffer must be cleared
  30630. * @param depth defines if the depth buffer must be cleared
  30631. * @param stencil defines if the stencil buffer must be cleared
  30632. */
  30633. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30634. /**
  30635. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30637. * @param y defines the y-coordinate of the corner of the clear rectangle
  30638. * @param width defines the width of the clear rectangle
  30639. * @param height defines the height of the clear rectangle
  30640. * @param clearColor defines the clear color
  30641. */
  30642. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30643. /**
  30644. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30646. * @param y defines the y-coordinate of the corner of the clear rectangle
  30647. * @param width defines the width of the clear rectangle
  30648. * @param height defines the height of the clear rectangle
  30649. */
  30650. enableScissor(x: number, y: number, width: number, height: number): void;
  30651. /**
  30652. * Disable previously set scissor test rectangle
  30653. */
  30654. disableScissor(): void;
  30655. private _viewportCached;
  30656. /** @hidden */
  30657. _viewport(x: number, y: number, width: number, height: number): void;
  30658. /**
  30659. * Set the WebGL's viewport
  30660. * @param viewport defines the viewport element to be used
  30661. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30662. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30663. */
  30664. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30665. /**
  30666. * Directly set the WebGL Viewport
  30667. * @param x defines the x coordinate of the viewport (in screen space)
  30668. * @param y defines the y coordinate of the viewport (in screen space)
  30669. * @param width defines the width of the viewport (in screen space)
  30670. * @param height defines the height of the viewport (in screen space)
  30671. * @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
  30672. */
  30673. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30674. /**
  30675. * Begin a new frame
  30676. */
  30677. beginFrame(): void;
  30678. /**
  30679. * Enf the current frame
  30680. */
  30681. endFrame(): void;
  30682. /**
  30683. * Resize the view according to the canvas' size
  30684. */
  30685. resize(): void;
  30686. /**
  30687. * Force a specific size of the canvas
  30688. * @param width defines the new canvas' width
  30689. * @param height defines the new canvas' height
  30690. */
  30691. setSize(width: number, height: number): void;
  30692. /**
  30693. * Binds the frame buffer to the specified texture.
  30694. * @param texture The texture to render to or null for the default canvas
  30695. * @param faceIndex The face of the texture to render to in case of cube texture
  30696. * @param requiredWidth The width of the target to render to
  30697. * @param requiredHeight The height of the target to render to
  30698. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30699. * @param depthStencilTexture The depth stencil texture to use to render
  30700. * @param lodLevel defines le lod level to bind to the frame buffer
  30701. */
  30702. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30703. /** @hidden */
  30704. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30705. /**
  30706. * Unbind the current render target texture from the webGL context
  30707. * @param texture defines the render target texture to unbind
  30708. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30709. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30710. */
  30711. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30712. /**
  30713. * Force the mipmap generation for the given render target texture
  30714. * @param texture defines the render target texture to use
  30715. */
  30716. generateMipMapsForCubemap(texture: InternalTexture): void;
  30717. /**
  30718. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30719. */
  30720. flushFramebuffer(): void;
  30721. /**
  30722. * Unbind the current render target and bind the default framebuffer
  30723. */
  30724. restoreDefaultFramebuffer(): void;
  30725. /**
  30726. * Create an uniform buffer
  30727. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30728. * @param elements defines the content of the uniform buffer
  30729. * @returns the webGL uniform buffer
  30730. */
  30731. createUniformBuffer(elements: FloatArray): DataBuffer;
  30732. /**
  30733. * Create a dynamic uniform buffer
  30734. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30735. * @param elements defines the content of the uniform buffer
  30736. * @returns the webGL uniform buffer
  30737. */
  30738. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30739. /**
  30740. * Update an existing uniform buffer
  30741. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30742. * @param uniformBuffer defines the target uniform buffer
  30743. * @param elements defines the content to update
  30744. * @param offset defines the offset in the uniform buffer where update should start
  30745. * @param count defines the size of the data to update
  30746. */
  30747. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30748. private _resetVertexBufferBinding;
  30749. /**
  30750. * Creates a vertex buffer
  30751. * @param data the data for the vertex buffer
  30752. * @returns the new WebGL static buffer
  30753. */
  30754. createVertexBuffer(data: DataArray): DataBuffer;
  30755. /**
  30756. * Creates a dynamic vertex buffer
  30757. * @param data the data for the dynamic vertex buffer
  30758. * @returns the new WebGL dynamic buffer
  30759. */
  30760. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30761. /**
  30762. * Update a dynamic index buffer
  30763. * @param indexBuffer defines the target index buffer
  30764. * @param indices defines the data to update
  30765. * @param offset defines the offset in the target index buffer where update should start
  30766. */
  30767. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30768. /**
  30769. * Updates a dynamic vertex buffer.
  30770. * @param vertexBuffer the vertex buffer to update
  30771. * @param data the data used to update the vertex buffer
  30772. * @param byteOffset the byte offset of the data
  30773. * @param byteLength the byte length of the data
  30774. */
  30775. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30776. private _resetIndexBufferBinding;
  30777. /**
  30778. * Creates a new index buffer
  30779. * @param indices defines the content of the index buffer
  30780. * @param updatable defines if the index buffer must be updatable
  30781. * @returns a new webGL buffer
  30782. */
  30783. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30784. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30785. /**
  30786. * Bind a webGL buffer to the webGL context
  30787. * @param buffer defines the buffer to bind
  30788. */
  30789. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30790. /**
  30791. * Bind an uniform buffer to the current webGL context
  30792. * @param buffer defines the buffer to bind
  30793. */
  30794. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30795. /**
  30796. * Bind a buffer to the current webGL context at a given location
  30797. * @param buffer defines the buffer to bind
  30798. * @param location defines the index where to bind the buffer
  30799. */
  30800. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30801. /**
  30802. * Bind a specific block at a given index in a specific shader program
  30803. * @param pipelineContext defines the pipeline context to use
  30804. * @param blockName defines the block name
  30805. * @param index defines the index where to bind the block
  30806. */
  30807. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30808. private bindIndexBuffer;
  30809. private bindBuffer;
  30810. /**
  30811. * update the bound buffer with the given data
  30812. * @param data defines the data to update
  30813. */
  30814. updateArrayBuffer(data: Float32Array): void;
  30815. private _vertexAttribPointer;
  30816. private _bindIndexBufferWithCache;
  30817. private _bindVertexBuffersAttributes;
  30818. /**
  30819. * Records a vertex array object
  30820. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30821. * @param vertexBuffers defines the list of vertex buffers to store
  30822. * @param indexBuffer defines the index buffer to store
  30823. * @param effect defines the effect to store
  30824. * @returns the new vertex array object
  30825. */
  30826. recordVertexArrayObject(vertexBuffers: {
  30827. [key: string]: VertexBuffer;
  30828. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30829. /**
  30830. * Bind a specific vertex array object
  30831. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30832. * @param vertexArrayObject defines the vertex array object to bind
  30833. * @param indexBuffer defines the index buffer to bind
  30834. */
  30835. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30836. /**
  30837. * Bind webGl buffers directly to the webGL context
  30838. * @param vertexBuffer defines the vertex buffer to bind
  30839. * @param indexBuffer defines the index buffer to bind
  30840. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30841. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30842. * @param effect defines the effect associated with the vertex buffer
  30843. */
  30844. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30845. private _unbindVertexArrayObject;
  30846. /**
  30847. * Bind a list of vertex buffers to the webGL context
  30848. * @param vertexBuffers defines the list of vertex buffers to bind
  30849. * @param indexBuffer defines the index buffer to bind
  30850. * @param effect defines the effect associated with the vertex buffers
  30851. */
  30852. bindBuffers(vertexBuffers: {
  30853. [key: string]: Nullable<VertexBuffer>;
  30854. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30855. /**
  30856. * Unbind all instance attributes
  30857. */
  30858. unbindInstanceAttributes(): void;
  30859. /**
  30860. * Release and free the memory of a vertex array object
  30861. * @param vao defines the vertex array object to delete
  30862. */
  30863. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30864. /** @hidden */
  30865. _releaseBuffer(buffer: DataBuffer): boolean;
  30866. protected _deleteBuffer(buffer: DataBuffer): void;
  30867. /**
  30868. * Creates a webGL buffer to use with instanciation
  30869. * @param capacity defines the size of the buffer
  30870. * @returns the webGL buffer
  30871. */
  30872. createInstancesBuffer(capacity: number): DataBuffer;
  30873. /**
  30874. * Delete a webGL buffer used with instanciation
  30875. * @param buffer defines the webGL buffer to delete
  30876. */
  30877. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30878. /**
  30879. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30880. * @param instancesBuffer defines the webGL buffer to update and bind
  30881. * @param data defines the data to store in the buffer
  30882. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30883. */
  30884. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30885. /**
  30886. * Apply all cached states (depth, culling, stencil and alpha)
  30887. */
  30888. applyStates(): void;
  30889. /**
  30890. * Send a draw order
  30891. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30892. * @param indexStart defines the starting index
  30893. * @param indexCount defines the number of index to draw
  30894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30895. */
  30896. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30897. /**
  30898. * Draw a list of points
  30899. * @param verticesStart defines the index of first vertex to draw
  30900. * @param verticesCount defines the count of vertices to draw
  30901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30902. */
  30903. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30904. /**
  30905. * Draw a list of unindexed primitives
  30906. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30907. * @param verticesStart defines the index of first vertex to draw
  30908. * @param verticesCount defines the count of vertices to draw
  30909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30910. */
  30911. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30912. /**
  30913. * Draw a list of indexed primitives
  30914. * @param fillMode defines the primitive to use
  30915. * @param indexStart defines the starting index
  30916. * @param indexCount defines the number of index to draw
  30917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30918. */
  30919. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30920. /**
  30921. * Draw a list of unindexed primitives
  30922. * @param fillMode defines the primitive to use
  30923. * @param verticesStart defines the index of first vertex to draw
  30924. * @param verticesCount defines the count of vertices to draw
  30925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30926. */
  30927. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30928. private _drawMode;
  30929. /** @hidden */
  30930. _releaseEffect(effect: Effect): void;
  30931. /** @hidden */
  30932. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30933. /**
  30934. * Create a new effect (used to store vertex/fragment shaders)
  30935. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30936. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30937. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30938. * @param samplers defines an array of string used to represent textures
  30939. * @param defines defines the string containing the defines to use to compile the shaders
  30940. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30941. * @param onCompiled defines a function to call when the effect creation is successful
  30942. * @param onError defines a function to call when the effect creation has failed
  30943. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30944. * @returns the new Effect
  30945. */
  30946. 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;
  30947. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30948. private _compileShader;
  30949. private _compileRawShader;
  30950. /**
  30951. * Directly creates a webGL program
  30952. * @param pipelineContext defines the pipeline context to attach to
  30953. * @param vertexCode defines the vertex shader code to use
  30954. * @param fragmentCode defines the fragment shader code to use
  30955. * @param context defines the webGL context to use (if not set, the current one will be used)
  30956. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30957. * @returns the new webGL program
  30958. */
  30959. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30960. /**
  30961. * Creates a webGL program
  30962. * @param pipelineContext defines the pipeline context to attach to
  30963. * @param vertexCode defines the vertex shader code to use
  30964. * @param fragmentCode defines the fragment shader code to use
  30965. * @param defines defines the string containing the defines to use to compile the shaders
  30966. * @param context defines the webGL context to use (if not set, the current one will be used)
  30967. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30968. * @returns the new webGL program
  30969. */
  30970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30971. /**
  30972. * Creates a new pipeline context
  30973. * @returns the new pipeline
  30974. */
  30975. createPipelineContext(): IPipelineContext;
  30976. private _createShaderProgram;
  30977. private _finalizePipelineContext;
  30978. /** @hidden */
  30979. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30980. /** @hidden */
  30981. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30982. /** @hidden */
  30983. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30984. /**
  30985. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30986. * @param pipelineContext defines the pipeline context to use
  30987. * @param uniformsNames defines the list of uniform names
  30988. * @returns an array of webGL uniform locations
  30989. */
  30990. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30991. /**
  30992. * Gets the lsit of active attributes for a given webGL program
  30993. * @param pipelineContext defines the pipeline context to use
  30994. * @param attributesNames defines the list of attribute names to get
  30995. * @returns an array of indices indicating the offset of each attribute
  30996. */
  30997. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30998. /**
  30999. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31000. * @param effect defines the effect to activate
  31001. */
  31002. enableEffect(effect: Nullable<Effect>): void;
  31003. /**
  31004. * Set the value of an uniform to an array of int32
  31005. * @param uniform defines the webGL uniform location where to store the value
  31006. * @param array defines the array of int32 to store
  31007. */
  31008. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31009. /**
  31010. * Set the value of an uniform to an array of int32 (stored as vec2)
  31011. * @param uniform defines the webGL uniform location where to store the value
  31012. * @param array defines the array of int32 to store
  31013. */
  31014. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31015. /**
  31016. * Set the value of an uniform to an array of int32 (stored as vec3)
  31017. * @param uniform defines the webGL uniform location where to store the value
  31018. * @param array defines the array of int32 to store
  31019. */
  31020. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31021. /**
  31022. * Set the value of an uniform to an array of int32 (stored as vec4)
  31023. * @param uniform defines the webGL uniform location where to store the value
  31024. * @param array defines the array of int32 to store
  31025. */
  31026. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31027. /**
  31028. * Set the value of an uniform to an array of float32
  31029. * @param uniform defines the webGL uniform location where to store the value
  31030. * @param array defines the array of float32 to store
  31031. */
  31032. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31033. /**
  31034. * Set the value of an uniform to an array of float32 (stored as vec2)
  31035. * @param uniform defines the webGL uniform location where to store the value
  31036. * @param array defines the array of float32 to store
  31037. */
  31038. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31039. /**
  31040. * Set the value of an uniform to an array of float32 (stored as vec3)
  31041. * @param uniform defines the webGL uniform location where to store the value
  31042. * @param array defines the array of float32 to store
  31043. */
  31044. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31045. /**
  31046. * Set the value of an uniform to an array of float32 (stored as vec4)
  31047. * @param uniform defines the webGL uniform location where to store the value
  31048. * @param array defines the array of float32 to store
  31049. */
  31050. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31051. /**
  31052. * Set the value of an uniform to an array of number
  31053. * @param uniform defines the webGL uniform location where to store the value
  31054. * @param array defines the array of number to store
  31055. */
  31056. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31057. /**
  31058. * Set the value of an uniform to an array of number (stored as vec2)
  31059. * @param uniform defines the webGL uniform location where to store the value
  31060. * @param array defines the array of number to store
  31061. */
  31062. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31063. /**
  31064. * Set the value of an uniform to an array of number (stored as vec3)
  31065. * @param uniform defines the webGL uniform location where to store the value
  31066. * @param array defines the array of number to store
  31067. */
  31068. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31069. /**
  31070. * Set the value of an uniform to an array of number (stored as vec4)
  31071. * @param uniform defines the webGL uniform location where to store the value
  31072. * @param array defines the array of number to store
  31073. */
  31074. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31075. /**
  31076. * Set the value of an uniform to an array of float32 (stored as matrices)
  31077. * @param uniform defines the webGL uniform location where to store the value
  31078. * @param matrices defines the array of float32 to store
  31079. */
  31080. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31081. /**
  31082. * Set the value of an uniform to a matrix (3x3)
  31083. * @param uniform defines the webGL uniform location where to store the value
  31084. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31085. */
  31086. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31087. /**
  31088. * Set the value of an uniform to a matrix (2x2)
  31089. * @param uniform defines the webGL uniform location where to store the value
  31090. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31091. */
  31092. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31093. /**
  31094. * Set the value of an uniform to a number (int)
  31095. * @param uniform defines the webGL uniform location where to store the value
  31096. * @param value defines the int number to store
  31097. */
  31098. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31099. /**
  31100. * Set the value of an uniform to a number (float)
  31101. * @param uniform defines the webGL uniform location where to store the value
  31102. * @param value defines the float number to store
  31103. */
  31104. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31105. /**
  31106. * Set the value of an uniform to a vec2
  31107. * @param uniform defines the webGL uniform location where to store the value
  31108. * @param x defines the 1st component of the value
  31109. * @param y defines the 2nd component of the value
  31110. */
  31111. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31112. /**
  31113. * Set the value of an uniform to a vec3
  31114. * @param uniform defines the webGL uniform location where to store the value
  31115. * @param x defines the 1st component of the value
  31116. * @param y defines the 2nd component of the value
  31117. * @param z defines the 3rd component of the value
  31118. */
  31119. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31120. /**
  31121. * Set the value of an uniform to a boolean
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param bool defines the boolean to store
  31124. */
  31125. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31126. /**
  31127. * Set the value of an uniform to a vec4
  31128. * @param uniform defines the webGL uniform location where to store the value
  31129. * @param x defines the 1st component of the value
  31130. * @param y defines the 2nd component of the value
  31131. * @param z defines the 3rd component of the value
  31132. * @param w defines the 4th component of the value
  31133. */
  31134. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31135. /**
  31136. * Sets a Color4 on a uniform variable
  31137. * @param uniform defines the uniform location
  31138. * @param color4 defines the value to be set
  31139. */
  31140. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31141. /**
  31142. * Set various states to the webGL context
  31143. * @param culling defines backface culling state
  31144. * @param zOffset defines the value to apply to zOffset (0 by default)
  31145. * @param force defines if states must be applied even if cache is up to date
  31146. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31147. */
  31148. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31149. /**
  31150. * Set the z offset to apply to current rendering
  31151. * @param value defines the offset to apply
  31152. */
  31153. setZOffset(value: number): void;
  31154. /**
  31155. * Gets the current value of the zOffset
  31156. * @returns the current zOffset state
  31157. */
  31158. getZOffset(): number;
  31159. /**
  31160. * Enable or disable depth buffering
  31161. * @param enable defines the state to set
  31162. */
  31163. setDepthBuffer(enable: boolean): void;
  31164. /**
  31165. * Gets a boolean indicating if depth writing is enabled
  31166. * @returns the current depth writing state
  31167. */
  31168. getDepthWrite(): boolean;
  31169. /**
  31170. * Enable or disable depth writing
  31171. * @param enable defines the state to set
  31172. */
  31173. setDepthWrite(enable: boolean): void;
  31174. /**
  31175. * Enable or disable color writing
  31176. * @param enable defines the state to set
  31177. */
  31178. setColorWrite(enable: boolean): void;
  31179. /**
  31180. * Gets a boolean indicating if color writing is enabled
  31181. * @returns the current color writing state
  31182. */
  31183. getColorWrite(): boolean;
  31184. /**
  31185. * Sets alpha constants used by some alpha blending modes
  31186. * @param r defines the red component
  31187. * @param g defines the green component
  31188. * @param b defines the blue component
  31189. * @param a defines the alpha component
  31190. */
  31191. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31192. /**
  31193. * Sets the current alpha mode
  31194. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31195. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31196. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31197. */
  31198. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31199. /**
  31200. * Gets the current alpha mode
  31201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31202. * @returns the current alpha mode
  31203. */
  31204. getAlphaMode(): number;
  31205. /**
  31206. * Clears the list of texture accessible through engine.
  31207. * This can help preventing texture load conflict due to name collision.
  31208. */
  31209. clearInternalTexturesCache(): void;
  31210. /**
  31211. * Force the entire cache to be cleared
  31212. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31213. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31214. */
  31215. wipeCaches(bruteForce?: boolean): void;
  31216. /**
  31217. * Set the compressed texture format to use, based on the formats you have, and the formats
  31218. * supported by the hardware / browser.
  31219. *
  31220. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31221. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31222. * to API arguments needed to compressed textures. This puts the burden on the container
  31223. * generator to house the arcane code for determining these for current & future formats.
  31224. *
  31225. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31226. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31227. *
  31228. * Note: The result of this call is not taken into account when a texture is base64.
  31229. *
  31230. * @param formatsAvailable defines the list of those format families you have created
  31231. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31232. *
  31233. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31234. * @returns The extension selected.
  31235. */
  31236. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31237. /** @hidden */
  31238. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31239. min: number;
  31240. mag: number;
  31241. };
  31242. /** @hidden */
  31243. _createTexture(): WebGLTexture;
  31244. /**
  31245. * Usually called from Texture.ts.
  31246. * Passed information to create a WebGLTexture
  31247. * @param urlArg defines a value which contains one of the following:
  31248. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31249. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31250. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31251. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31252. * @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)
  31253. * @param scene needed for loading to the correct scene
  31254. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31255. * @param onLoad optional callback to be called upon successful completion
  31256. * @param onError optional callback to be called upon failure
  31257. * @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
  31258. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31259. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31260. * @param forcedExtension defines the extension to use to pick the right loader
  31261. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31262. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31263. */
  31264. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31265. /**
  31266. * @hidden
  31267. * Rescales a texture
  31268. * @param source input texutre
  31269. * @param destination destination texture
  31270. * @param scene scene to use to render the resize
  31271. * @param internalFormat format to use when resizing
  31272. * @param onComplete callback to be called when resize has completed
  31273. */
  31274. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31275. private _unpackFlipYCached;
  31276. /**
  31277. * In case you are sharing the context with other applications, it might
  31278. * be interested to not cache the unpack flip y state to ensure a consistent
  31279. * value would be set.
  31280. */
  31281. enableUnpackFlipYCached: boolean;
  31282. /** @hidden */
  31283. _unpackFlipY(value: boolean): void;
  31284. /** @hidden */
  31285. _getUnpackAlignement(): number;
  31286. /**
  31287. * Creates a dynamic texture
  31288. * @param width defines the width of the texture
  31289. * @param height defines the height of the texture
  31290. * @param generateMipMaps defines if the engine should generate the mip levels
  31291. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31292. * @returns the dynamic texture inside an InternalTexture
  31293. */
  31294. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31295. /**
  31296. * Update the sampling mode of a given texture
  31297. * @param samplingMode defines the required sampling mode
  31298. * @param texture defines the texture to update
  31299. */
  31300. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31301. /**
  31302. * Update the content of a dynamic texture
  31303. * @param texture defines the texture to update
  31304. * @param canvas defines the canvas containing the source
  31305. * @param invertY defines if data must be stored with Y axis inverted
  31306. * @param premulAlpha defines if alpha is stored as premultiplied
  31307. * @param format defines the format of the data
  31308. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31309. */
  31310. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31311. /**
  31312. * Update a video texture
  31313. * @param texture defines the texture to update
  31314. * @param video defines the video element to use
  31315. * @param invertY defines if data must be stored with Y axis inverted
  31316. */
  31317. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31318. /**
  31319. * Updates a depth texture Comparison Mode and Function.
  31320. * If the comparison Function is equal to 0, the mode will be set to none.
  31321. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31322. * @param texture The texture to set the comparison function for
  31323. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31324. */
  31325. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31326. /** @hidden */
  31327. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31328. width: number;
  31329. height: number;
  31330. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31331. /**
  31332. * Creates a depth stencil texture.
  31333. * This is only available in WebGL 2 or with the depth texture extension available.
  31334. * @param size The size of face edge in the texture.
  31335. * @param options The options defining the texture.
  31336. * @returns The texture
  31337. */
  31338. createDepthStencilTexture(size: number | {
  31339. width: number;
  31340. height: number;
  31341. }, options: DepthTextureCreationOptions): InternalTexture;
  31342. /**
  31343. * Creates a depth stencil texture.
  31344. * This is only available in WebGL 2 or with the depth texture extension available.
  31345. * @param size The size of face edge in the texture.
  31346. * @param options The options defining the texture.
  31347. * @returns The texture
  31348. */
  31349. private _createDepthStencilTexture;
  31350. /**
  31351. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31352. * @param renderTarget The render target to set the frame buffer for
  31353. */
  31354. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31355. /**
  31356. * Creates a new render target texture
  31357. * @param size defines the size of the texture
  31358. * @param options defines the options used to create the texture
  31359. * @returns a new render target texture stored in an InternalTexture
  31360. */
  31361. createRenderTargetTexture(size: number | {
  31362. width: number;
  31363. height: number;
  31364. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31365. /** @hidden */
  31366. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31367. /**
  31368. * Updates the sample count of a render target texture
  31369. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31370. * @param texture defines the texture to update
  31371. * @param samples defines the sample count to set
  31372. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31373. */
  31374. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31375. /** @hidden */
  31376. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31377. /** @hidden */
  31378. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31379. /** @hidden */
  31380. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31381. /** @hidden */
  31382. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31383. /**
  31384. * @hidden
  31385. */
  31386. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31387. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31388. private _prepareWebGLTexture;
  31389. /** @hidden */
  31390. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31391. /** @hidden */
  31392. _releaseFramebufferObjects(texture: InternalTexture): void;
  31393. /** @hidden */
  31394. _releaseTexture(texture: InternalTexture): void;
  31395. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31396. protected _setProgram(program: WebGLProgram): void;
  31397. protected _boundUniforms: {
  31398. [key: number]: WebGLUniformLocation;
  31399. };
  31400. /**
  31401. * Binds an effect to the webGL context
  31402. * @param effect defines the effect to bind
  31403. */
  31404. bindSamplers(effect: Effect): void;
  31405. private _activateCurrentTexture;
  31406. /** @hidden */
  31407. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31408. /** @hidden */
  31409. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31410. /**
  31411. * Sets a texture to the webGL context from a postprocess
  31412. * @param channel defines the channel to use
  31413. * @param postProcess defines the source postprocess
  31414. */
  31415. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31416. /**
  31417. * Binds the output of the passed in post process to the texture channel specified
  31418. * @param channel The channel the texture should be bound to
  31419. * @param postProcess The post process which's output should be bound
  31420. */
  31421. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31422. /**
  31423. * Unbind all textures from the webGL context
  31424. */
  31425. unbindAllTextures(): void;
  31426. /**
  31427. * Sets a texture to the according uniform.
  31428. * @param channel The texture channel
  31429. * @param uniform The uniform to set
  31430. * @param texture The texture to apply
  31431. */
  31432. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31433. /**
  31434. * Sets a depth stencil texture from a render target to the according uniform.
  31435. * @param channel The texture channel
  31436. * @param uniform The uniform to set
  31437. * @param texture The render target texture containing the depth stencil texture to apply
  31438. */
  31439. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31440. private _bindSamplerUniformToChannel;
  31441. private _getTextureWrapMode;
  31442. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31443. /**
  31444. * Sets an array of texture to the webGL context
  31445. * @param channel defines the channel where the texture array must be set
  31446. * @param uniform defines the associated uniform location
  31447. * @param textures defines the array of textures to bind
  31448. */
  31449. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31450. /** @hidden */
  31451. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31452. private _setTextureParameterFloat;
  31453. private _setTextureParameterInteger;
  31454. /**
  31455. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31456. * @param x defines the x coordinate of the rectangle where pixels must be read
  31457. * @param y defines the y coordinate of the rectangle where pixels must be read
  31458. * @param width defines the width of the rectangle where pixels must be read
  31459. * @param height defines the height of the rectangle where pixels must be read
  31460. * @returns a Uint8Array containing RGBA colors
  31461. */
  31462. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31463. /**
  31464. * Add an externaly attached data from its key.
  31465. * This method call will fail and return false, if such key already exists.
  31466. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31467. * @param key the unique key that identifies the data
  31468. * @param data the data object to associate to the key for this Engine instance
  31469. * @return true if no such key were already present and the data was added successfully, false otherwise
  31470. */
  31471. addExternalData<T>(key: string, data: T): boolean;
  31472. /**
  31473. * Get an externaly attached data from its key
  31474. * @param key the unique key that identifies the data
  31475. * @return the associated data, if present (can be null), or undefined if not present
  31476. */
  31477. getExternalData<T>(key: string): T;
  31478. /**
  31479. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31480. * @param key the unique key that identifies the data
  31481. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31482. * @return the associated data, can be null if the factory returned null.
  31483. */
  31484. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31485. /**
  31486. * Remove an externaly attached data from the Engine instance
  31487. * @param key the unique key that identifies the data
  31488. * @return true if the data was successfully removed, false if it doesn't exist
  31489. */
  31490. removeExternalData(key: string): boolean;
  31491. /**
  31492. * Unbind all vertex attributes from the webGL context
  31493. */
  31494. unbindAllAttributes(): void;
  31495. /**
  31496. * 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
  31497. */
  31498. releaseEffects(): void;
  31499. /**
  31500. * Dispose and release all associated resources
  31501. */
  31502. dispose(): void;
  31503. /**
  31504. * Display the loading screen
  31505. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31506. */
  31507. displayLoadingUI(): void;
  31508. /**
  31509. * Hide the loading screen
  31510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31511. */
  31512. hideLoadingUI(): void;
  31513. /**
  31514. * Gets the current loading screen object
  31515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31516. */
  31517. /**
  31518. * Sets the current loading screen object
  31519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31520. */
  31521. loadingScreen: ILoadingScreen;
  31522. /**
  31523. * Sets the current loading screen text
  31524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31525. */
  31526. loadingUIText: string;
  31527. /**
  31528. * Sets the current loading screen background color
  31529. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31530. */
  31531. loadingUIBackgroundColor: string;
  31532. /**
  31533. * Attach a new callback raised when context lost event is fired
  31534. * @param callback defines the callback to call
  31535. */
  31536. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31537. /**
  31538. * Attach a new callback raised when context restored event is fired
  31539. * @param callback defines the callback to call
  31540. */
  31541. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31542. /**
  31543. * Gets the source code of the vertex shader associated with a specific webGL program
  31544. * @param program defines the program to use
  31545. * @returns a string containing the source code of the vertex shader associated with the program
  31546. */
  31547. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31548. /**
  31549. * Gets the source code of the fragment shader associated with a specific webGL program
  31550. * @param program defines the program to use
  31551. * @returns a string containing the source code of the fragment shader associated with the program
  31552. */
  31553. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31554. /**
  31555. * Get the current error code of the webGL context
  31556. * @returns the error code
  31557. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31558. */
  31559. getError(): number;
  31560. /**
  31561. * Gets the current framerate
  31562. * @returns a number representing the framerate
  31563. */
  31564. getFps(): number;
  31565. /**
  31566. * Gets the time spent between current and previous frame
  31567. * @returns a number representing the delta time in ms
  31568. */
  31569. getDeltaTime(): number;
  31570. private _measureFps;
  31571. /** @hidden */
  31572. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31573. private _canRenderToFloatFramebuffer;
  31574. private _canRenderToHalfFloatFramebuffer;
  31575. private _canRenderToFramebuffer;
  31576. /** @hidden */
  31577. _getWebGLTextureType(type: number): number;
  31578. /** @hidden */
  31579. _getInternalFormat(format: number): number;
  31580. /** @hidden */
  31581. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31582. /** @hidden */
  31583. _getRGBAMultiSampleBufferFormat(type: number): number;
  31584. /** @hidden */
  31585. _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;
  31586. /** @hidden */
  31587. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31588. /**
  31589. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31590. * @returns true if the engine can be created
  31591. * @ignorenaming
  31592. */
  31593. static isSupported(): boolean;
  31594. /**
  31595. * Find the next highest power of two.
  31596. * @param x Number to start search from.
  31597. * @return Next highest power of two.
  31598. */
  31599. static CeilingPOT(x: number): number;
  31600. /**
  31601. * Find the next lowest power of two.
  31602. * @param x Number to start search from.
  31603. * @return Next lowest power of two.
  31604. */
  31605. static FloorPOT(x: number): number;
  31606. /**
  31607. * Find the nearest power of two.
  31608. * @param x Number to start search from.
  31609. * @return Next nearest power of two.
  31610. */
  31611. static NearestPOT(x: number): number;
  31612. /**
  31613. * Get the closest exponent of two
  31614. * @param value defines the value to approximate
  31615. * @param max defines the maximum value to return
  31616. * @param mode defines how to define the closest value
  31617. * @returns closest exponent of two of the given value
  31618. */
  31619. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31620. /**
  31621. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31622. * @param func - the function to be called
  31623. * @param requester - the object that will request the next frame. Falls back to window.
  31624. * @returns frame number
  31625. */
  31626. static QueueNewFrame(func: () => void, requester?: any): number;
  31627. /**
  31628. * Ask the browser to promote the current element to pointerlock mode
  31629. * @param element defines the DOM element to promote
  31630. */
  31631. static _RequestPointerlock(element: HTMLElement): void;
  31632. /**
  31633. * Asks the browser to exit pointerlock mode
  31634. */
  31635. static _ExitPointerlock(): void;
  31636. /**
  31637. * Ask the browser to promote the current element to fullscreen rendering mode
  31638. * @param element defines the DOM element to promote
  31639. */
  31640. static _RequestFullscreen(element: HTMLElement): void;
  31641. /**
  31642. * Asks the browser to exit fullscreen mode
  31643. */
  31644. static _ExitFullscreen(): void;
  31645. }
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31650. * during the life time of the application.
  31651. */
  31652. export class EngineStore {
  31653. /** Gets the list of created engines */
  31654. static Instances: Engine[];
  31655. /** @hidden */
  31656. static _LastCreatedScene: Nullable<Scene>;
  31657. /**
  31658. * Gets the latest created engine
  31659. */
  31660. static readonly LastCreatedEngine: Nullable<Engine>;
  31661. /**
  31662. * Gets the latest created scene
  31663. */
  31664. static readonly LastCreatedScene: Nullable<Scene>;
  31665. /**
  31666. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31667. * @ignorenaming
  31668. */
  31669. static UseFallbackTexture: boolean;
  31670. /**
  31671. * Texture content used if a texture cannot loaded
  31672. * @ignorenaming
  31673. */
  31674. static FallbackTexture: string;
  31675. }
  31676. }
  31677. declare module BABYLON {
  31678. /**
  31679. * Helper class that provides a small promise polyfill
  31680. */
  31681. export class PromisePolyfill {
  31682. /**
  31683. * Static function used to check if the polyfill is required
  31684. * If this is the case then the function will inject the polyfill to window.Promise
  31685. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31686. */
  31687. static Apply(force?: boolean): void;
  31688. }
  31689. }
  31690. declare module BABYLON {
  31691. /**
  31692. * Interface for screenshot methods with describe argument called `size` as object with options
  31693. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31694. */
  31695. export interface IScreenshotSize {
  31696. /**
  31697. * number in pixels for canvas height
  31698. */
  31699. height?: number;
  31700. /**
  31701. * multiplier allowing render at a higher or lower resolution
  31702. * If value is defined then height and width will be ignored and taken from camera
  31703. */
  31704. precision?: number;
  31705. /**
  31706. * number in pixels for canvas width
  31707. */
  31708. width?: number;
  31709. }
  31710. }
  31711. declare module BABYLON {
  31712. interface IColor4Like {
  31713. r: float;
  31714. g: float;
  31715. b: float;
  31716. a: float;
  31717. }
  31718. /**
  31719. * Class containing a set of static utilities functions
  31720. */
  31721. export class Tools {
  31722. /**
  31723. * Gets or sets the base URL to use to load assets
  31724. */
  31725. static BaseUrl: string;
  31726. /**
  31727. * Enable/Disable Custom HTTP Request Headers globally.
  31728. * default = false
  31729. * @see CustomRequestHeaders
  31730. */
  31731. static UseCustomRequestHeaders: boolean;
  31732. /**
  31733. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31734. * i.e. when loading files, where the server/service expects an Authorization header
  31735. */
  31736. static CustomRequestHeaders: {
  31737. [key: string]: string;
  31738. };
  31739. /**
  31740. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31741. */
  31742. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31743. /**
  31744. * Default behaviour for cors in the application.
  31745. * It can be a string if the expected behavior is identical in the entire app.
  31746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31747. */
  31748. static CorsBehavior: string | ((url: string | string[]) => string);
  31749. /**
  31750. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31751. * @ignorenaming
  31752. */
  31753. static UseFallbackTexture: boolean;
  31754. /**
  31755. * Use this object to register external classes like custom textures or material
  31756. * to allow the laoders to instantiate them
  31757. */
  31758. static RegisteredExternalClasses: {
  31759. [key: string]: Object;
  31760. };
  31761. /**
  31762. * Texture content used if a texture cannot loaded
  31763. * @ignorenaming
  31764. */
  31765. static fallbackTexture: string;
  31766. /**
  31767. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31768. * @param u defines the coordinate on X axis
  31769. * @param v defines the coordinate on Y axis
  31770. * @param width defines the width of the source data
  31771. * @param height defines the height of the source data
  31772. * @param pixels defines the source byte array
  31773. * @param color defines the output color
  31774. */
  31775. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31776. /**
  31777. * Interpolates between a and b via alpha
  31778. * @param a The lower value (returned when alpha = 0)
  31779. * @param b The upper value (returned when alpha = 1)
  31780. * @param alpha The interpolation-factor
  31781. * @return The mixed value
  31782. */
  31783. static Mix(a: number, b: number, alpha: number): number;
  31784. /**
  31785. * Tries to instantiate a new object from a given class name
  31786. * @param className defines the class name to instantiate
  31787. * @returns the new object or null if the system was not able to do the instantiation
  31788. */
  31789. static Instantiate(className: string): any;
  31790. /**
  31791. * Provides a slice function that will work even on IE
  31792. * @param data defines the array to slice
  31793. * @param start defines the start of the data (optional)
  31794. * @param end defines the end of the data (optional)
  31795. * @returns the new sliced array
  31796. */
  31797. static Slice<T>(data: T, start?: number, end?: number): T;
  31798. /**
  31799. * Polyfill for setImmediate
  31800. * @param action defines the action to execute after the current execution block
  31801. */
  31802. static SetImmediate(action: () => void): void;
  31803. /**
  31804. * Function indicating if a number is an exponent of 2
  31805. * @param value defines the value to test
  31806. * @returns true if the value is an exponent of 2
  31807. */
  31808. static IsExponentOfTwo(value: number): boolean;
  31809. private static _tmpFloatArray;
  31810. /**
  31811. * Returns the nearest 32-bit single precision float representation of a Number
  31812. * @param value A Number. If the parameter is of a different type, it will get converted
  31813. * to a number or to NaN if it cannot be converted
  31814. * @returns number
  31815. */
  31816. static FloatRound(value: number): number;
  31817. /**
  31818. * Extracts the filename from a path
  31819. * @param path defines the path to use
  31820. * @returns the filename
  31821. */
  31822. static GetFilename(path: string): string;
  31823. /**
  31824. * Extracts the "folder" part of a path (everything before the filename).
  31825. * @param uri The URI to extract the info from
  31826. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31827. * @returns The "folder" part of the path
  31828. */
  31829. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31830. /**
  31831. * Extracts text content from a DOM element hierarchy
  31832. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31833. */
  31834. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31835. /**
  31836. * Convert an angle in radians to degrees
  31837. * @param angle defines the angle to convert
  31838. * @returns the angle in degrees
  31839. */
  31840. static ToDegrees(angle: number): number;
  31841. /**
  31842. * Convert an angle in degrees to radians
  31843. * @param angle defines the angle to convert
  31844. * @returns the angle in radians
  31845. */
  31846. static ToRadians(angle: number): number;
  31847. /**
  31848. * Encode a buffer to a base64 string
  31849. * @param buffer defines the buffer to encode
  31850. * @returns the encoded string
  31851. */
  31852. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31853. /**
  31854. * Returns an array if obj is not an array
  31855. * @param obj defines the object to evaluate as an array
  31856. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31857. * @returns either obj directly if obj is an array or a new array containing obj
  31858. */
  31859. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31860. /**
  31861. * Gets the pointer prefix to use
  31862. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31863. */
  31864. static GetPointerPrefix(): string;
  31865. /**
  31866. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31867. * @param url define the url we are trying
  31868. * @param element define the dom element where to configure the cors policy
  31869. */
  31870. static SetCorsBehavior(url: string | string[], element: {
  31871. crossOrigin: string | null;
  31872. }): void;
  31873. /**
  31874. * Removes unwanted characters from an url
  31875. * @param url defines the url to clean
  31876. * @returns the cleaned url
  31877. */
  31878. static CleanUrl(url: string): string;
  31879. /**
  31880. * Gets or sets a function used to pre-process url before using them to load assets
  31881. */
  31882. static PreprocessUrl: (url: string) => string;
  31883. /**
  31884. * Loads an image as an HTMLImageElement.
  31885. * @param input url string, ArrayBuffer, or Blob to load
  31886. * @param onLoad callback called when the image successfully loads
  31887. * @param onError callback called when the image fails to load
  31888. * @param offlineProvider offline provider for caching
  31889. * @returns the HTMLImageElement of the loaded image
  31890. */
  31891. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31892. /**
  31893. * Loads a file
  31894. * @param url url string, ArrayBuffer, or Blob to load
  31895. * @param onSuccess callback called when the file successfully loads
  31896. * @param onProgress callback called while file is loading (if the server supports this mode)
  31897. * @param offlineProvider defines the offline provider for caching
  31898. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31899. * @param onError callback called when the file fails to load
  31900. * @returns a file request object
  31901. */
  31902. 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;
  31903. /**
  31904. * Loads a file from a url
  31905. * @param url the file url to load
  31906. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31907. */
  31908. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31909. /**
  31910. * Load a script (identified by an url). When the url returns, the
  31911. * content of this file is added into a new script element, attached to the DOM (body element)
  31912. * @param scriptUrl defines the url of the script to laod
  31913. * @param onSuccess defines the callback called when the script is loaded
  31914. * @param onError defines the callback to call if an error occurs
  31915. * @param scriptId defines the id of the script element
  31916. */
  31917. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31918. /**
  31919. * Load an asynchronous script (identified by an url). When the url returns, the
  31920. * content of this file is added into a new script element, attached to the DOM (body element)
  31921. * @param scriptUrl defines the url of the script to laod
  31922. * @param scriptId defines the id of the script element
  31923. * @returns a promise request object
  31924. */
  31925. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31926. /**
  31927. * Loads a file from a blob
  31928. * @param fileToLoad defines the blob to use
  31929. * @param callback defines the callback to call when data is loaded
  31930. * @param progressCallback defines the callback to call during loading process
  31931. * @returns a file request object
  31932. */
  31933. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31934. /**
  31935. * Loads a file
  31936. * @param fileToLoad defines the file to load
  31937. * @param callback defines the callback to call when data is loaded
  31938. * @param progressCallBack defines the callback to call during loading process
  31939. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31940. * @returns a file request object
  31941. */
  31942. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31943. /**
  31944. * Creates a data url from a given string content
  31945. * @param content defines the content to convert
  31946. * @returns the new data url link
  31947. */
  31948. static FileAsURL(content: string): string;
  31949. /**
  31950. * Format the given number to a specific decimal format
  31951. * @param value defines the number to format
  31952. * @param decimals defines the number of decimals to use
  31953. * @returns the formatted string
  31954. */
  31955. static Format(value: number, decimals?: number): string;
  31956. /**
  31957. * Tries to copy an object by duplicating every property
  31958. * @param source defines the source object
  31959. * @param destination defines the target object
  31960. * @param doNotCopyList defines a list of properties to avoid
  31961. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31962. */
  31963. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31964. /**
  31965. * Gets a boolean indicating if the given object has no own property
  31966. * @param obj defines the object to test
  31967. * @returns true if object has no own property
  31968. */
  31969. static IsEmpty(obj: any): boolean;
  31970. /**
  31971. * Function used to register events at window level
  31972. * @param windowElement defines the Window object to use
  31973. * @param events defines the events to register
  31974. */
  31975. static RegisterTopRootEvents(windowElement: Window, events: {
  31976. name: string;
  31977. handler: Nullable<(e: FocusEvent) => any>;
  31978. }[]): void;
  31979. /**
  31980. * Function used to unregister events from window level
  31981. * @param windowElement defines the Window object to use
  31982. * @param events defines the events to unregister
  31983. */
  31984. static UnregisterTopRootEvents(windowElement: Window, events: {
  31985. name: string;
  31986. handler: Nullable<(e: FocusEvent) => any>;
  31987. }[]): void;
  31988. /**
  31989. * @ignore
  31990. */
  31991. static _ScreenshotCanvas: HTMLCanvasElement;
  31992. /**
  31993. * Dumps the current bound framebuffer
  31994. * @param width defines the rendering width
  31995. * @param height defines the rendering height
  31996. * @param engine defines the hosting engine
  31997. * @param successCallback defines the callback triggered once the data are available
  31998. * @param mimeType defines the mime type of the result
  31999. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32000. */
  32001. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32002. /**
  32003. * Converts the canvas data to blob.
  32004. * This acts as a polyfill for browsers not supporting the to blob function.
  32005. * @param canvas Defines the canvas to extract the data from
  32006. * @param successCallback Defines the callback triggered once the data are available
  32007. * @param mimeType Defines the mime type of the result
  32008. */
  32009. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32010. /**
  32011. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32012. * @param successCallback defines the callback triggered once the data are available
  32013. * @param mimeType defines the mime type of the result
  32014. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32015. */
  32016. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32017. /**
  32018. * Downloads a blob in the browser
  32019. * @param blob defines the blob to download
  32020. * @param fileName defines the name of the downloaded file
  32021. */
  32022. static Download(blob: Blob, fileName: string): void;
  32023. /**
  32024. * Captures a screenshot of the current rendering
  32025. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32026. * @param engine defines the rendering engine
  32027. * @param camera defines the source camera
  32028. * @param size This parameter can be set to a single number or to an object with the
  32029. * following (optional) properties: precision, width, height. If a single number is passed,
  32030. * it will be used for both width and height. If an object is passed, the screenshot size
  32031. * will be derived from the parameters. The precision property is a multiplier allowing
  32032. * rendering at a higher or lower resolution
  32033. * @param successCallback defines the callback receives a single parameter which contains the
  32034. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32035. * src parameter of an <img> to display it
  32036. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32037. * Check your browser for supported MIME types
  32038. */
  32039. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32040. /**
  32041. * Captures a screenshot of the current rendering
  32042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32043. * @param engine defines the rendering engine
  32044. * @param camera defines the source camera
  32045. * @param size This parameter can be set to a single number or to an object with the
  32046. * following (optional) properties: precision, width, height. If a single number is passed,
  32047. * it will be used for both width and height. If an object is passed, the screenshot size
  32048. * will be derived from the parameters. The precision property is a multiplier allowing
  32049. * rendering at a higher or lower resolution
  32050. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32051. * Check your browser for supported MIME types
  32052. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32053. * to the src parameter of an <img> to display it
  32054. */
  32055. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32056. /**
  32057. * Generates an image screenshot from the specified camera.
  32058. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32059. * @param engine The engine to use for rendering
  32060. * @param camera The camera to use for rendering
  32061. * @param size This parameter can be set to a single number or to an object with the
  32062. * following (optional) properties: precision, width, height. If a single number is passed,
  32063. * it will be used for both width and height. If an object is passed, the screenshot size
  32064. * will be derived from the parameters. The precision property is a multiplier allowing
  32065. * rendering at a higher or lower resolution
  32066. * @param successCallback The callback receives a single parameter which contains the
  32067. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32068. * src parameter of an <img> to display it
  32069. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32070. * Check your browser for supported MIME types
  32071. * @param samples Texture samples (default: 1)
  32072. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32073. * @param fileName A name for for the downloaded file.
  32074. */
  32075. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32076. /**
  32077. * Generates an image screenshot from the specified camera.
  32078. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32079. * @param engine The engine to use for rendering
  32080. * @param camera The camera to use for rendering
  32081. * @param size This parameter can be set to a single number or to an object with the
  32082. * following (optional) properties: precision, width, height. If a single number is passed,
  32083. * it will be used for both width and height. If an object is passed, the screenshot size
  32084. * will be derived from the parameters. The precision property is a multiplier allowing
  32085. * rendering at a higher or lower resolution
  32086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32087. * Check your browser for supported MIME types
  32088. * @param samples Texture samples (default: 1)
  32089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32090. * @param fileName A name for for the downloaded file.
  32091. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32092. * to the src parameter of an <img> to display it
  32093. */
  32094. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32095. /**
  32096. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32097. * Be aware Math.random() could cause collisions, but:
  32098. * "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"
  32099. * @returns a pseudo random id
  32100. */
  32101. static RandomId(): string;
  32102. /**
  32103. * Test if the given uri is a base64 string
  32104. * @param uri The uri to test
  32105. * @return True if the uri is a base64 string or false otherwise
  32106. */
  32107. static IsBase64(uri: string): boolean;
  32108. /**
  32109. * Decode the given base64 uri.
  32110. * @param uri The uri to decode
  32111. * @return The decoded base64 data.
  32112. */
  32113. static DecodeBase64(uri: string): ArrayBuffer;
  32114. /**
  32115. * Gets the absolute url.
  32116. * @param url the input url
  32117. * @return the absolute url
  32118. */
  32119. static GetAbsoluteUrl(url: string): string;
  32120. /**
  32121. * No log
  32122. */
  32123. static readonly NoneLogLevel: number;
  32124. /**
  32125. * Only message logs
  32126. */
  32127. static readonly MessageLogLevel: number;
  32128. /**
  32129. * Only warning logs
  32130. */
  32131. static readonly WarningLogLevel: number;
  32132. /**
  32133. * Only error logs
  32134. */
  32135. static readonly ErrorLogLevel: number;
  32136. /**
  32137. * All logs
  32138. */
  32139. static readonly AllLogLevel: number;
  32140. /**
  32141. * Gets a value indicating the number of loading errors
  32142. * @ignorenaming
  32143. */
  32144. static readonly errorsCount: number;
  32145. /**
  32146. * Callback called when a new log is added
  32147. */
  32148. static OnNewCacheEntry: (entry: string) => void;
  32149. /**
  32150. * Log a message to the console
  32151. * @param message defines the message to log
  32152. */
  32153. static Log(message: string): void;
  32154. /**
  32155. * Write a warning message to the console
  32156. * @param message defines the message to log
  32157. */
  32158. static Warn(message: string): void;
  32159. /**
  32160. * Write an error message to the console
  32161. * @param message defines the message to log
  32162. */
  32163. static Error(message: string): void;
  32164. /**
  32165. * Gets current log cache (list of logs)
  32166. */
  32167. static readonly LogCache: string;
  32168. /**
  32169. * Clears the log cache
  32170. */
  32171. static ClearLogCache(): void;
  32172. /**
  32173. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32174. */
  32175. static LogLevels: number;
  32176. /**
  32177. * Checks if the window object exists
  32178. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32179. */
  32180. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32181. /**
  32182. * No performance log
  32183. */
  32184. static readonly PerformanceNoneLogLevel: number;
  32185. /**
  32186. * Use user marks to log performance
  32187. */
  32188. static readonly PerformanceUserMarkLogLevel: number;
  32189. /**
  32190. * Log performance to the console
  32191. */
  32192. static readonly PerformanceConsoleLogLevel: number;
  32193. private static _performance;
  32194. /**
  32195. * Sets the current performance log level
  32196. */
  32197. static PerformanceLogLevel: number;
  32198. private static _StartPerformanceCounterDisabled;
  32199. private static _EndPerformanceCounterDisabled;
  32200. private static _StartUserMark;
  32201. private static _EndUserMark;
  32202. private static _StartPerformanceConsole;
  32203. private static _EndPerformanceConsole;
  32204. /**
  32205. * Starts a performance counter
  32206. */
  32207. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32208. /**
  32209. * Ends a specific performance coutner
  32210. */
  32211. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32212. /**
  32213. * Gets either window.performance.now() if supported or Date.now() else
  32214. */
  32215. static readonly Now: number;
  32216. /**
  32217. * This method will return the name of the class used to create the instance of the given object.
  32218. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32219. * @param object the object to get the class name from
  32220. * @param isType defines if the object is actually a type
  32221. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32222. */
  32223. static GetClassName(object: any, isType?: boolean): string;
  32224. /**
  32225. * Gets the first element of an array satisfying a given predicate
  32226. * @param array defines the array to browse
  32227. * @param predicate defines the predicate to use
  32228. * @returns null if not found or the element
  32229. */
  32230. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32231. /**
  32232. * This method will return the name of the full name of the class, including its owning module (if any).
  32233. * 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).
  32234. * @param object the object to get the class name from
  32235. * @param isType defines if the object is actually a type
  32236. * @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.
  32237. * @ignorenaming
  32238. */
  32239. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32240. /**
  32241. * Returns a promise that resolves after the given amount of time.
  32242. * @param delay Number of milliseconds to delay
  32243. * @returns Promise that resolves after the given amount of time
  32244. */
  32245. static DelayAsync(delay: number): Promise<void>;
  32246. }
  32247. /**
  32248. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32249. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32250. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32251. * @param name The name of the class, case should be preserved
  32252. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32253. */
  32254. export function className(name: string, module?: string): (target: Object) => void;
  32255. /**
  32256. * An implementation of a loop for asynchronous functions.
  32257. */
  32258. export class AsyncLoop {
  32259. /**
  32260. * Defines the number of iterations for the loop
  32261. */
  32262. iterations: number;
  32263. /**
  32264. * Defines the current index of the loop.
  32265. */
  32266. index: number;
  32267. private _done;
  32268. private _fn;
  32269. private _successCallback;
  32270. /**
  32271. * Constructor.
  32272. * @param iterations the number of iterations.
  32273. * @param func the function to run each iteration
  32274. * @param successCallback the callback that will be called upon succesful execution
  32275. * @param offset starting offset.
  32276. */
  32277. constructor(
  32278. /**
  32279. * Defines the number of iterations for the loop
  32280. */
  32281. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32282. /**
  32283. * Execute the next iteration. Must be called after the last iteration was finished.
  32284. */
  32285. executeNext(): void;
  32286. /**
  32287. * Break the loop and run the success callback.
  32288. */
  32289. breakLoop(): void;
  32290. /**
  32291. * Create and run an async loop.
  32292. * @param iterations the number of iterations.
  32293. * @param fn the function to run each iteration
  32294. * @param successCallback the callback that will be called upon succesful execution
  32295. * @param offset starting offset.
  32296. * @returns the created async loop object
  32297. */
  32298. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32299. /**
  32300. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32301. * @param iterations total number of iterations
  32302. * @param syncedIterations number of synchronous iterations in each async iteration.
  32303. * @param fn the function to call each iteration.
  32304. * @param callback a success call back that will be called when iterating stops.
  32305. * @param breakFunction a break condition (optional)
  32306. * @param timeout timeout settings for the setTimeout function. default - 0.
  32307. * @returns the created async loop object
  32308. */
  32309. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32310. }
  32311. }
  32312. declare module BABYLON {
  32313. /** @hidden */
  32314. export interface ICollisionCoordinator {
  32315. createCollider(): Collider;
  32316. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32317. init(scene: Scene): void;
  32318. }
  32319. /** @hidden */
  32320. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32321. private _scene;
  32322. private _scaledPosition;
  32323. private _scaledVelocity;
  32324. private _finalPosition;
  32325. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32326. createCollider(): Collider;
  32327. init(scene: Scene): void;
  32328. private _collideWithWorld;
  32329. }
  32330. }
  32331. declare module BABYLON {
  32332. /**
  32333. * Class used to manage all inputs for the scene.
  32334. */
  32335. export class InputManager {
  32336. /** The distance in pixel that you have to move to prevent some events */
  32337. static DragMovementThreshold: number;
  32338. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32339. static LongPressDelay: number;
  32340. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32341. static DoubleClickDelay: number;
  32342. /** If you need to check double click without raising a single click at first click, enable this flag */
  32343. static ExclusiveDoubleClickMode: boolean;
  32344. private _wheelEventName;
  32345. private _onPointerMove;
  32346. private _onPointerDown;
  32347. private _onPointerUp;
  32348. private _initClickEvent;
  32349. private _initActionManager;
  32350. private _delayedSimpleClick;
  32351. private _delayedSimpleClickTimeout;
  32352. private _previousDelayedSimpleClickTimeout;
  32353. private _meshPickProceed;
  32354. private _previousButtonPressed;
  32355. private _currentPickResult;
  32356. private _previousPickResult;
  32357. private _totalPointersPressed;
  32358. private _doubleClickOccured;
  32359. private _pointerOverMesh;
  32360. private _pickedDownMesh;
  32361. private _pickedUpMesh;
  32362. private _pointerX;
  32363. private _pointerY;
  32364. private _unTranslatedPointerX;
  32365. private _unTranslatedPointerY;
  32366. private _startingPointerPosition;
  32367. private _previousStartingPointerPosition;
  32368. private _startingPointerTime;
  32369. private _previousStartingPointerTime;
  32370. private _pointerCaptures;
  32371. private _onKeyDown;
  32372. private _onKeyUp;
  32373. private _onCanvasFocusObserver;
  32374. private _onCanvasBlurObserver;
  32375. private _scene;
  32376. /**
  32377. * Creates a new InputManager
  32378. * @param scene defines the hosting scene
  32379. */
  32380. constructor(scene: Scene);
  32381. /**
  32382. * Gets the mesh that is currently under the pointer
  32383. */
  32384. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32385. /**
  32386. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32387. */
  32388. readonly unTranslatedPointer: Vector2;
  32389. /**
  32390. * Gets or sets the current on-screen X position of the pointer
  32391. */
  32392. pointerX: number;
  32393. /**
  32394. * Gets or sets the current on-screen Y position of the pointer
  32395. */
  32396. pointerY: number;
  32397. private _updatePointerPosition;
  32398. private _processPointerMove;
  32399. private _setRayOnPointerInfo;
  32400. private _checkPrePointerObservable;
  32401. /**
  32402. * Use this method to simulate a pointer move on a mesh
  32403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32406. */
  32407. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32408. /**
  32409. * Use this method to simulate a pointer down on a mesh
  32410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32413. */
  32414. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32415. private _processPointerDown;
  32416. /** @hidden */
  32417. _isPointerSwiping(): boolean;
  32418. /**
  32419. * Use this method to simulate a pointer up on a mesh
  32420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32423. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32424. */
  32425. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32426. private _processPointerUp;
  32427. /**
  32428. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32429. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32430. * @returns true if the pointer was captured
  32431. */
  32432. isPointerCaptured(pointerId?: number): boolean;
  32433. /**
  32434. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32435. * @param attachUp defines if you want to attach events to pointerup
  32436. * @param attachDown defines if you want to attach events to pointerdown
  32437. * @param attachMove defines if you want to attach events to pointermove
  32438. */
  32439. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32440. /**
  32441. * Detaches all event handlers
  32442. */
  32443. detachControl(): void;
  32444. /**
  32445. * Force the value of meshUnderPointer
  32446. * @param mesh defines the mesh to use
  32447. */
  32448. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32449. /**
  32450. * Gets the mesh under the pointer
  32451. * @returns a Mesh or null if no mesh is under the pointer
  32452. */
  32453. getPointerOverMesh(): Nullable<AbstractMesh>;
  32454. }
  32455. }
  32456. declare module BABYLON {
  32457. /**
  32458. * Helper class used to generate session unique ID
  32459. */
  32460. export class UniqueIdGenerator {
  32461. private static _UniqueIdCounter;
  32462. /**
  32463. * Gets an unique (relatively to the current scene) Id
  32464. */
  32465. static readonly UniqueId: number;
  32466. }
  32467. }
  32468. declare module BABYLON {
  32469. /**
  32470. * This class defines the direct association between an animation and a target
  32471. */
  32472. export class TargetedAnimation {
  32473. /**
  32474. * Animation to perform
  32475. */
  32476. animation: Animation;
  32477. /**
  32478. * Target to animate
  32479. */
  32480. target: any;
  32481. /**
  32482. * Serialize the object
  32483. * @returns the JSON object representing the current entity
  32484. */
  32485. serialize(): any;
  32486. }
  32487. /**
  32488. * Use this class to create coordinated animations on multiple targets
  32489. */
  32490. export class AnimationGroup implements IDisposable {
  32491. /** The name of the animation group */
  32492. name: string;
  32493. private _scene;
  32494. private _targetedAnimations;
  32495. private _animatables;
  32496. private _from;
  32497. private _to;
  32498. private _isStarted;
  32499. private _isPaused;
  32500. private _speedRatio;
  32501. private _loopAnimation;
  32502. /**
  32503. * Gets or sets the unique id of the node
  32504. */
  32505. uniqueId: number;
  32506. /**
  32507. * This observable will notify when one animation have ended
  32508. */
  32509. onAnimationEndObservable: Observable<TargetedAnimation>;
  32510. /**
  32511. * Observer raised when one animation loops
  32512. */
  32513. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32514. /**
  32515. * This observable will notify when all animations have ended.
  32516. */
  32517. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32518. /**
  32519. * This observable will notify when all animations have paused.
  32520. */
  32521. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32522. /**
  32523. * This observable will notify when all animations are playing.
  32524. */
  32525. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32526. /**
  32527. * Gets the first frame
  32528. */
  32529. readonly from: number;
  32530. /**
  32531. * Gets the last frame
  32532. */
  32533. readonly to: number;
  32534. /**
  32535. * Define if the animations are started
  32536. */
  32537. readonly isStarted: boolean;
  32538. /**
  32539. * Gets a value indicating that the current group is playing
  32540. */
  32541. readonly isPlaying: boolean;
  32542. /**
  32543. * Gets or sets the speed ratio to use for all animations
  32544. */
  32545. /**
  32546. * Gets or sets the speed ratio to use for all animations
  32547. */
  32548. speedRatio: number;
  32549. /**
  32550. * Gets or sets if all animations should loop or not
  32551. */
  32552. loopAnimation: boolean;
  32553. /**
  32554. * Gets the targeted animations for this animation group
  32555. */
  32556. readonly targetedAnimations: Array<TargetedAnimation>;
  32557. /**
  32558. * returning the list of animatables controlled by this animation group.
  32559. */
  32560. readonly animatables: Array<Animatable>;
  32561. /**
  32562. * Instantiates a new Animation Group.
  32563. * This helps managing several animations at once.
  32564. * @see http://doc.babylonjs.com/how_to/group
  32565. * @param name Defines the name of the group
  32566. * @param scene Defines the scene the group belongs to
  32567. */
  32568. constructor(
  32569. /** The name of the animation group */
  32570. name: string, scene?: Nullable<Scene>);
  32571. /**
  32572. * Add an animation (with its target) in the group
  32573. * @param animation defines the animation we want to add
  32574. * @param target defines the target of the animation
  32575. * @returns the TargetedAnimation object
  32576. */
  32577. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32578. /**
  32579. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32580. * It can add constant keys at begin or end
  32581. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32582. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32583. * @returns the animation group
  32584. */
  32585. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32586. /**
  32587. * Start all animations on given targets
  32588. * @param loop defines if animations must loop
  32589. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32590. * @param from defines the from key (optional)
  32591. * @param to defines the to key (optional)
  32592. * @returns the current animation group
  32593. */
  32594. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32595. /**
  32596. * Pause all animations
  32597. * @returns the animation group
  32598. */
  32599. pause(): AnimationGroup;
  32600. /**
  32601. * Play all animations to initial state
  32602. * This function will start() the animations if they were not started or will restart() them if they were paused
  32603. * @param loop defines if animations must loop
  32604. * @returns the animation group
  32605. */
  32606. play(loop?: boolean): AnimationGroup;
  32607. /**
  32608. * Reset all animations to initial state
  32609. * @returns the animation group
  32610. */
  32611. reset(): AnimationGroup;
  32612. /**
  32613. * Restart animations from key 0
  32614. * @returns the animation group
  32615. */
  32616. restart(): AnimationGroup;
  32617. /**
  32618. * Stop all animations
  32619. * @returns the animation group
  32620. */
  32621. stop(): AnimationGroup;
  32622. /**
  32623. * Set animation weight for all animatables
  32624. * @param weight defines the weight to use
  32625. * @return the animationGroup
  32626. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32627. */
  32628. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32629. /**
  32630. * Synchronize and normalize all animatables with a source animatable
  32631. * @param root defines the root animatable to synchronize with
  32632. * @return the animationGroup
  32633. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32634. */
  32635. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32636. /**
  32637. * Goes to a specific frame in this animation group
  32638. * @param frame the frame number to go to
  32639. * @return the animationGroup
  32640. */
  32641. goToFrame(frame: number): AnimationGroup;
  32642. /**
  32643. * Dispose all associated resources
  32644. */
  32645. dispose(): void;
  32646. private _checkAnimationGroupEnded;
  32647. /**
  32648. * Clone the current animation group and returns a copy
  32649. * @param newName defines the name of the new group
  32650. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32651. * @returns the new aniamtion group
  32652. */
  32653. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32654. /**
  32655. * Serializes the animationGroup to an object
  32656. * @returns Serialized object
  32657. */
  32658. serialize(): any;
  32659. /**
  32660. * Returns a new AnimationGroup object parsed from the source provided.
  32661. * @param parsedAnimationGroup defines the source
  32662. * @param scene defines the scene that will receive the animationGroup
  32663. * @returns a new AnimationGroup
  32664. */
  32665. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32666. /**
  32667. * Returns the string "AnimationGroup"
  32668. * @returns "AnimationGroup"
  32669. */
  32670. getClassName(): string;
  32671. /**
  32672. * Creates a detailled string about the object
  32673. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32674. * @returns a string representing the object
  32675. */
  32676. toString(fullDetails?: boolean): string;
  32677. }
  32678. }
  32679. declare module BABYLON {
  32680. /**
  32681. * Define an interface for all classes that will hold resources
  32682. */
  32683. export interface IDisposable {
  32684. /**
  32685. * Releases all held resources
  32686. */
  32687. dispose(): void;
  32688. }
  32689. /** Interface defining initialization parameters for Scene class */
  32690. export interface SceneOptions {
  32691. /**
  32692. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32693. * It will improve performance when the number of geometries becomes important.
  32694. */
  32695. useGeometryUniqueIdsMap?: boolean;
  32696. /**
  32697. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32698. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32699. */
  32700. useMaterialMeshMap?: boolean;
  32701. /**
  32702. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32703. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32704. */
  32705. useClonedMeshhMap?: boolean;
  32706. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32707. virtual?: boolean;
  32708. }
  32709. /**
  32710. * Represents a scene to be rendered by the engine.
  32711. * @see http://doc.babylonjs.com/features/scene
  32712. */
  32713. export class Scene extends AbstractScene implements IAnimatable {
  32714. /** The fog is deactivated */
  32715. static readonly FOGMODE_NONE: number;
  32716. /** The fog density is following an exponential function */
  32717. static readonly FOGMODE_EXP: number;
  32718. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32719. static readonly FOGMODE_EXP2: number;
  32720. /** The fog density is following a linear function. */
  32721. static readonly FOGMODE_LINEAR: number;
  32722. /**
  32723. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32725. */
  32726. static MinDeltaTime: number;
  32727. /**
  32728. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32730. */
  32731. static MaxDeltaTime: number;
  32732. /**
  32733. * Factory used to create the default material.
  32734. * @param name The name of the material to create
  32735. * @param scene The scene to create the material for
  32736. * @returns The default material
  32737. */
  32738. static DefaultMaterialFactory(scene: Scene): Material;
  32739. /**
  32740. * Factory used to create the a collision coordinator.
  32741. * @returns The collision coordinator
  32742. */
  32743. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32744. /** @hidden */
  32745. _inputManager: InputManager;
  32746. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32747. cameraToUseForPointers: Nullable<Camera>;
  32748. /** @hidden */
  32749. readonly _isScene: boolean;
  32750. /**
  32751. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32752. */
  32753. autoClear: boolean;
  32754. /**
  32755. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32756. */
  32757. autoClearDepthAndStencil: boolean;
  32758. /**
  32759. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32760. */
  32761. clearColor: Color4;
  32762. /**
  32763. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32764. */
  32765. ambientColor: Color3;
  32766. /**
  32767. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32768. * It should only be one of the following (if not the default embedded one):
  32769. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32770. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32771. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32772. * The material properties need to be setup according to the type of texture in use.
  32773. */
  32774. environmentBRDFTexture: BaseTexture;
  32775. /** @hidden */
  32776. protected _environmentTexture: Nullable<BaseTexture>;
  32777. /**
  32778. * Texture used in all pbr material as the reflection texture.
  32779. * As in the majority of the scene they are the same (exception for multi room and so on),
  32780. * this is easier to reference from here than from all the materials.
  32781. */
  32782. /**
  32783. * Texture used in all pbr material as the reflection texture.
  32784. * As in the majority of the scene they are the same (exception for multi room and so on),
  32785. * this is easier to set here than in all the materials.
  32786. */
  32787. environmentTexture: Nullable<BaseTexture>;
  32788. /** @hidden */
  32789. protected _environmentIntensity: number;
  32790. /**
  32791. * Intensity of the environment in all pbr material.
  32792. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32793. * As in the majority of the scene they are the same (exception for multi room and so on),
  32794. * this is easier to reference from here than from all the materials.
  32795. */
  32796. /**
  32797. * Intensity of the environment in all pbr material.
  32798. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32799. * As in the majority of the scene they are the same (exception for multi room and so on),
  32800. * this is easier to set here than in all the materials.
  32801. */
  32802. environmentIntensity: number;
  32803. /** @hidden */
  32804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32805. /**
  32806. * Default image processing configuration used either in the rendering
  32807. * Forward main pass or through the imageProcessingPostProcess if present.
  32808. * As in the majority of the scene they are the same (exception for multi camera),
  32809. * this is easier to reference from here than from all the materials and post process.
  32810. *
  32811. * No setter as we it is a shared configuration, you can set the values instead.
  32812. */
  32813. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32814. private _forceWireframe;
  32815. /**
  32816. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32817. */
  32818. forceWireframe: boolean;
  32819. private _forcePointsCloud;
  32820. /**
  32821. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32822. */
  32823. forcePointsCloud: boolean;
  32824. /**
  32825. * Gets or sets the active clipplane 1
  32826. */
  32827. clipPlane: Nullable<Plane>;
  32828. /**
  32829. * Gets or sets the active clipplane 2
  32830. */
  32831. clipPlane2: Nullable<Plane>;
  32832. /**
  32833. * Gets or sets the active clipplane 3
  32834. */
  32835. clipPlane3: Nullable<Plane>;
  32836. /**
  32837. * Gets or sets the active clipplane 4
  32838. */
  32839. clipPlane4: Nullable<Plane>;
  32840. /**
  32841. * Gets or sets a boolean indicating if animations are enabled
  32842. */
  32843. animationsEnabled: boolean;
  32844. private _animationPropertiesOverride;
  32845. /**
  32846. * Gets or sets the animation properties override
  32847. */
  32848. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32849. /**
  32850. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32851. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32852. */
  32853. useConstantAnimationDeltaTime: boolean;
  32854. /**
  32855. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32856. * Please note that it requires to run a ray cast through the scene on every frame
  32857. */
  32858. constantlyUpdateMeshUnderPointer: boolean;
  32859. /**
  32860. * Defines the HTML cursor to use when hovering over interactive elements
  32861. */
  32862. hoverCursor: string;
  32863. /**
  32864. * Defines the HTML default cursor to use (empty by default)
  32865. */
  32866. defaultCursor: string;
  32867. /**
  32868. * This is used to call preventDefault() on pointer down
  32869. * in order to block unwanted artifacts like system double clicks
  32870. */
  32871. preventDefaultOnPointerDown: boolean;
  32872. /**
  32873. * This is used to call preventDefault() on pointer up
  32874. * in order to block unwanted artifacts like system double clicks
  32875. */
  32876. preventDefaultOnPointerUp: boolean;
  32877. /**
  32878. * Gets or sets user defined metadata
  32879. */
  32880. metadata: any;
  32881. /**
  32882. * For internal use only. Please do not use.
  32883. */
  32884. reservedDataStore: any;
  32885. /**
  32886. * Gets the name of the plugin used to load this scene (null by default)
  32887. */
  32888. loadingPluginName: string;
  32889. /**
  32890. * Use this array to add regular expressions used to disable offline support for specific urls
  32891. */
  32892. disableOfflineSupportExceptionRules: RegExp[];
  32893. /**
  32894. * An event triggered when the scene is disposed.
  32895. */
  32896. onDisposeObservable: Observable<Scene>;
  32897. private _onDisposeObserver;
  32898. /** Sets a function to be executed when this scene is disposed. */
  32899. onDispose: () => void;
  32900. /**
  32901. * An event triggered before rendering the scene (right after animations and physics)
  32902. */
  32903. onBeforeRenderObservable: Observable<Scene>;
  32904. private _onBeforeRenderObserver;
  32905. /** Sets a function to be executed before rendering this scene */
  32906. beforeRender: Nullable<() => void>;
  32907. /**
  32908. * An event triggered after rendering the scene
  32909. */
  32910. onAfterRenderObservable: Observable<Scene>;
  32911. /**
  32912. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32913. */
  32914. onAfterRenderCameraObservable: Observable<Camera>;
  32915. private _onAfterRenderObserver;
  32916. /** Sets a function to be executed after rendering this scene */
  32917. afterRender: Nullable<() => void>;
  32918. /**
  32919. * An event triggered before animating the scene
  32920. */
  32921. onBeforeAnimationsObservable: Observable<Scene>;
  32922. /**
  32923. * An event triggered after animations processing
  32924. */
  32925. onAfterAnimationsObservable: Observable<Scene>;
  32926. /**
  32927. * An event triggered before draw calls are ready to be sent
  32928. */
  32929. onBeforeDrawPhaseObservable: Observable<Scene>;
  32930. /**
  32931. * An event triggered after draw calls have been sent
  32932. */
  32933. onAfterDrawPhaseObservable: Observable<Scene>;
  32934. /**
  32935. * An event triggered when the scene is ready
  32936. */
  32937. onReadyObservable: Observable<Scene>;
  32938. /**
  32939. * An event triggered before rendering a camera
  32940. */
  32941. onBeforeCameraRenderObservable: Observable<Camera>;
  32942. private _onBeforeCameraRenderObserver;
  32943. /** Sets a function to be executed before rendering a camera*/
  32944. beforeCameraRender: () => void;
  32945. /**
  32946. * An event triggered after rendering a camera
  32947. */
  32948. onAfterCameraRenderObservable: Observable<Camera>;
  32949. private _onAfterCameraRenderObserver;
  32950. /** Sets a function to be executed after rendering a camera*/
  32951. afterCameraRender: () => void;
  32952. /**
  32953. * An event triggered when active meshes evaluation is about to start
  32954. */
  32955. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32956. /**
  32957. * An event triggered when active meshes evaluation is done
  32958. */
  32959. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32960. /**
  32961. * An event triggered when particles rendering is about to start
  32962. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32963. */
  32964. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32965. /**
  32966. * An event triggered when particles rendering is done
  32967. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32968. */
  32969. onAfterParticlesRenderingObservable: Observable<Scene>;
  32970. /**
  32971. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32972. */
  32973. onDataLoadedObservable: Observable<Scene>;
  32974. /**
  32975. * An event triggered when a camera is created
  32976. */
  32977. onNewCameraAddedObservable: Observable<Camera>;
  32978. /**
  32979. * An event triggered when a camera is removed
  32980. */
  32981. onCameraRemovedObservable: Observable<Camera>;
  32982. /**
  32983. * An event triggered when a light is created
  32984. */
  32985. onNewLightAddedObservable: Observable<Light>;
  32986. /**
  32987. * An event triggered when a light is removed
  32988. */
  32989. onLightRemovedObservable: Observable<Light>;
  32990. /**
  32991. * An event triggered when a geometry is created
  32992. */
  32993. onNewGeometryAddedObservable: Observable<Geometry>;
  32994. /**
  32995. * An event triggered when a geometry is removed
  32996. */
  32997. onGeometryRemovedObservable: Observable<Geometry>;
  32998. /**
  32999. * An event triggered when a transform node is created
  33000. */
  33001. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33002. /**
  33003. * An event triggered when a transform node is removed
  33004. */
  33005. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33006. /**
  33007. * An event triggered when a mesh is created
  33008. */
  33009. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33010. /**
  33011. * An event triggered when a mesh is removed
  33012. */
  33013. onMeshRemovedObservable: Observable<AbstractMesh>;
  33014. /**
  33015. * An event triggered when a skeleton is created
  33016. */
  33017. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33018. /**
  33019. * An event triggered when a skeleton is removed
  33020. */
  33021. onSkeletonRemovedObservable: Observable<Skeleton>;
  33022. /**
  33023. * An event triggered when a material is created
  33024. */
  33025. onNewMaterialAddedObservable: Observable<Material>;
  33026. /**
  33027. * An event triggered when a material is removed
  33028. */
  33029. onMaterialRemovedObservable: Observable<Material>;
  33030. /**
  33031. * An event triggered when a texture is created
  33032. */
  33033. onNewTextureAddedObservable: Observable<BaseTexture>;
  33034. /**
  33035. * An event triggered when a texture is removed
  33036. */
  33037. onTextureRemovedObservable: Observable<BaseTexture>;
  33038. /**
  33039. * An event triggered when render targets are about to be rendered
  33040. * Can happen multiple times per frame.
  33041. */
  33042. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33043. /**
  33044. * An event triggered when render targets were rendered.
  33045. * Can happen multiple times per frame.
  33046. */
  33047. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33048. /**
  33049. * An event triggered before calculating deterministic simulation step
  33050. */
  33051. onBeforeStepObservable: Observable<Scene>;
  33052. /**
  33053. * An event triggered after calculating deterministic simulation step
  33054. */
  33055. onAfterStepObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered when the activeCamera property is updated
  33058. */
  33059. onActiveCameraChanged: Observable<Scene>;
  33060. /**
  33061. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33062. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33063. * 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)
  33064. */
  33065. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33066. /**
  33067. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33068. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33069. * 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)
  33070. */
  33071. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33072. /**
  33073. * This Observable will when a mesh has been imported into the scene.
  33074. */
  33075. onMeshImportedObservable: Observable<AbstractMesh>;
  33076. /**
  33077. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33078. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33079. */
  33080. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33081. /** @hidden */
  33082. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33083. /**
  33084. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33085. */
  33086. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33087. /**
  33088. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33089. */
  33090. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33091. /**
  33092. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33093. */
  33094. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33095. /** Callback called when a pointer move is detected */
  33096. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33097. /** Callback called when a pointer down is detected */
  33098. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33099. /** Callback called when a pointer up is detected */
  33100. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33101. /** Callback called when a pointer pick is detected */
  33102. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33103. /**
  33104. * 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).
  33105. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33106. */
  33107. onPrePointerObservable: Observable<PointerInfoPre>;
  33108. /**
  33109. * Observable event triggered each time an input event is received from the rendering canvas
  33110. */
  33111. onPointerObservable: Observable<PointerInfo>;
  33112. /**
  33113. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33114. */
  33115. readonly unTranslatedPointer: Vector2;
  33116. /**
  33117. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33118. */
  33119. static DragMovementThreshold: number;
  33120. /**
  33121. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33122. */
  33123. static LongPressDelay: number;
  33124. /**
  33125. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33126. */
  33127. static DoubleClickDelay: number;
  33128. /** If you need to check double click without raising a single click at first click, enable this flag */
  33129. static ExclusiveDoubleClickMode: boolean;
  33130. /** @hidden */
  33131. _mirroredCameraPosition: Nullable<Vector3>;
  33132. /**
  33133. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33134. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33135. */
  33136. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33137. /**
  33138. * Observable event triggered each time an keyboard event is received from the hosting window
  33139. */
  33140. onKeyboardObservable: Observable<KeyboardInfo>;
  33141. private _useRightHandedSystem;
  33142. /**
  33143. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33144. */
  33145. useRightHandedSystem: boolean;
  33146. private _timeAccumulator;
  33147. private _currentStepId;
  33148. private _currentInternalStep;
  33149. /**
  33150. * Sets the step Id used by deterministic lock step
  33151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33152. * @param newStepId defines the step Id
  33153. */
  33154. setStepId(newStepId: number): void;
  33155. /**
  33156. * Gets the step Id used by deterministic lock step
  33157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33158. * @returns the step Id
  33159. */
  33160. getStepId(): number;
  33161. /**
  33162. * Gets the internal step used by deterministic lock step
  33163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33164. * @returns the internal step
  33165. */
  33166. getInternalStep(): number;
  33167. private _fogEnabled;
  33168. /**
  33169. * Gets or sets a boolean indicating if fog is enabled on this scene
  33170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33171. * (Default is true)
  33172. */
  33173. fogEnabled: boolean;
  33174. private _fogMode;
  33175. /**
  33176. * Gets or sets the fog mode to use
  33177. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33178. * | mode | value |
  33179. * | --- | --- |
  33180. * | FOGMODE_NONE | 0 |
  33181. * | FOGMODE_EXP | 1 |
  33182. * | FOGMODE_EXP2 | 2 |
  33183. * | FOGMODE_LINEAR | 3 |
  33184. */
  33185. fogMode: number;
  33186. /**
  33187. * Gets or sets the fog color to use
  33188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33189. * (Default is Color3(0.2, 0.2, 0.3))
  33190. */
  33191. fogColor: Color3;
  33192. /**
  33193. * Gets or sets the fog density to use
  33194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33195. * (Default is 0.1)
  33196. */
  33197. fogDensity: number;
  33198. /**
  33199. * Gets or sets the fog start distance to use
  33200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33201. * (Default is 0)
  33202. */
  33203. fogStart: number;
  33204. /**
  33205. * Gets or sets the fog end distance to use
  33206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33207. * (Default is 1000)
  33208. */
  33209. fogEnd: number;
  33210. private _shadowsEnabled;
  33211. /**
  33212. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33213. */
  33214. shadowsEnabled: boolean;
  33215. private _lightsEnabled;
  33216. /**
  33217. * Gets or sets a boolean indicating if lights are enabled on this scene
  33218. */
  33219. lightsEnabled: boolean;
  33220. /** All of the active cameras added to this scene. */
  33221. activeCameras: Camera[];
  33222. /** @hidden */
  33223. _activeCamera: Nullable<Camera>;
  33224. /** Gets or sets the current active camera */
  33225. activeCamera: Nullable<Camera>;
  33226. private _defaultMaterial;
  33227. /** The default material used on meshes when no material is affected */
  33228. /** The default material used on meshes when no material is affected */
  33229. defaultMaterial: Material;
  33230. private _texturesEnabled;
  33231. /**
  33232. * Gets or sets a boolean indicating if textures are enabled on this scene
  33233. */
  33234. texturesEnabled: boolean;
  33235. /**
  33236. * Gets or sets a boolean indicating if particles are enabled on this scene
  33237. */
  33238. particlesEnabled: boolean;
  33239. /**
  33240. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33241. */
  33242. spritesEnabled: boolean;
  33243. private _skeletonsEnabled;
  33244. /**
  33245. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33246. */
  33247. skeletonsEnabled: boolean;
  33248. /**
  33249. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33250. */
  33251. lensFlaresEnabled: boolean;
  33252. /**
  33253. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33255. */
  33256. collisionsEnabled: boolean;
  33257. private _collisionCoordinator;
  33258. /** @hidden */
  33259. readonly collisionCoordinator: ICollisionCoordinator;
  33260. /**
  33261. * Defines the gravity applied to this scene (used only for collisions)
  33262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33263. */
  33264. gravity: Vector3;
  33265. /**
  33266. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33267. */
  33268. postProcessesEnabled: boolean;
  33269. /**
  33270. * The list of postprocesses added to the scene
  33271. */
  33272. postProcesses: PostProcess[];
  33273. /**
  33274. * Gets the current postprocess manager
  33275. */
  33276. postProcessManager: PostProcessManager;
  33277. /**
  33278. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33279. */
  33280. renderTargetsEnabled: boolean;
  33281. /**
  33282. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33283. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33284. */
  33285. dumpNextRenderTargets: boolean;
  33286. /**
  33287. * The list of user defined render targets added to the scene
  33288. */
  33289. customRenderTargets: RenderTargetTexture[];
  33290. /**
  33291. * Defines if texture loading must be delayed
  33292. * If true, textures will only be loaded when they need to be rendered
  33293. */
  33294. useDelayedTextureLoading: boolean;
  33295. /**
  33296. * Gets the list of meshes imported to the scene through SceneLoader
  33297. */
  33298. importedMeshesFiles: String[];
  33299. /**
  33300. * Gets or sets a boolean indicating if probes are enabled on this scene
  33301. */
  33302. probesEnabled: boolean;
  33303. /**
  33304. * Gets or sets the current offline provider to use to store scene data
  33305. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33306. */
  33307. offlineProvider: IOfflineProvider;
  33308. /**
  33309. * Gets or sets the action manager associated with the scene
  33310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33311. */
  33312. actionManager: AbstractActionManager;
  33313. private _meshesForIntersections;
  33314. /**
  33315. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33316. */
  33317. proceduralTexturesEnabled: boolean;
  33318. private _engine;
  33319. private _totalVertices;
  33320. /** @hidden */
  33321. _activeIndices: PerfCounter;
  33322. /** @hidden */
  33323. _activeParticles: PerfCounter;
  33324. /** @hidden */
  33325. _activeBones: PerfCounter;
  33326. private _animationRatio;
  33327. /** @hidden */
  33328. _animationTimeLast: number;
  33329. /** @hidden */
  33330. _animationTime: number;
  33331. /**
  33332. * Gets or sets a general scale for animation speed
  33333. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33334. */
  33335. animationTimeScale: number;
  33336. /** @hidden */
  33337. _cachedMaterial: Nullable<Material>;
  33338. /** @hidden */
  33339. _cachedEffect: Nullable<Effect>;
  33340. /** @hidden */
  33341. _cachedVisibility: Nullable<number>;
  33342. private _renderId;
  33343. private _frameId;
  33344. private _executeWhenReadyTimeoutId;
  33345. private _intermediateRendering;
  33346. private _viewUpdateFlag;
  33347. private _projectionUpdateFlag;
  33348. /** @hidden */
  33349. _toBeDisposed: Nullable<IDisposable>[];
  33350. private _activeRequests;
  33351. /** @hidden */
  33352. _pendingData: any[];
  33353. private _isDisposed;
  33354. /**
  33355. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33356. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33357. */
  33358. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33359. private _activeMeshes;
  33360. private _processedMaterials;
  33361. private _renderTargets;
  33362. /** @hidden */
  33363. _activeParticleSystems: SmartArray<IParticleSystem>;
  33364. private _activeSkeletons;
  33365. private _softwareSkinnedMeshes;
  33366. private _renderingManager;
  33367. /** @hidden */
  33368. _activeAnimatables: Animatable[];
  33369. private _transformMatrix;
  33370. private _sceneUbo;
  33371. /** @hidden */
  33372. _viewMatrix: Matrix;
  33373. private _projectionMatrix;
  33374. /** @hidden */
  33375. _forcedViewPosition: Nullable<Vector3>;
  33376. /** @hidden */
  33377. _frustumPlanes: Plane[];
  33378. /**
  33379. * Gets the list of frustum planes (built from the active camera)
  33380. */
  33381. readonly frustumPlanes: Plane[];
  33382. /**
  33383. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33384. * This is useful if there are more lights that the maximum simulteanous authorized
  33385. */
  33386. requireLightSorting: boolean;
  33387. /** @hidden */
  33388. readonly useMaterialMeshMap: boolean;
  33389. /** @hidden */
  33390. readonly useClonedMeshhMap: boolean;
  33391. private _externalData;
  33392. private _uid;
  33393. /**
  33394. * @hidden
  33395. * Backing store of defined scene components.
  33396. */
  33397. _components: ISceneComponent[];
  33398. /**
  33399. * @hidden
  33400. * Backing store of defined scene components.
  33401. */
  33402. _serializableComponents: ISceneSerializableComponent[];
  33403. /**
  33404. * List of components to register on the next registration step.
  33405. */
  33406. private _transientComponents;
  33407. /**
  33408. * Registers the transient components if needed.
  33409. */
  33410. private _registerTransientComponents;
  33411. /**
  33412. * @hidden
  33413. * Add a component to the scene.
  33414. * Note that the ccomponent could be registered on th next frame if this is called after
  33415. * the register component stage.
  33416. * @param component Defines the component to add to the scene
  33417. */
  33418. _addComponent(component: ISceneComponent): void;
  33419. /**
  33420. * @hidden
  33421. * Gets a component from the scene.
  33422. * @param name defines the name of the component to retrieve
  33423. * @returns the component or null if not present
  33424. */
  33425. _getComponent(name: string): Nullable<ISceneComponent>;
  33426. /**
  33427. * @hidden
  33428. * Defines the actions happening before camera updates.
  33429. */
  33430. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33431. /**
  33432. * @hidden
  33433. * Defines the actions happening before clear the canvas.
  33434. */
  33435. _beforeClearStage: Stage<SimpleStageAction>;
  33436. /**
  33437. * @hidden
  33438. * Defines the actions when collecting render targets for the frame.
  33439. */
  33440. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33441. /**
  33442. * @hidden
  33443. * Defines the actions happening for one camera in the frame.
  33444. */
  33445. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33446. /**
  33447. * @hidden
  33448. * Defines the actions happening during the per mesh ready checks.
  33449. */
  33450. _isReadyForMeshStage: Stage<MeshStageAction>;
  33451. /**
  33452. * @hidden
  33453. * Defines the actions happening before evaluate active mesh checks.
  33454. */
  33455. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33456. /**
  33457. * @hidden
  33458. * Defines the actions happening during the evaluate sub mesh checks.
  33459. */
  33460. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33461. /**
  33462. * @hidden
  33463. * Defines the actions happening during the active mesh stage.
  33464. */
  33465. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33466. /**
  33467. * @hidden
  33468. * Defines the actions happening during the per camera render target step.
  33469. */
  33470. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33471. /**
  33472. * @hidden
  33473. * Defines the actions happening just before the active camera is drawing.
  33474. */
  33475. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33476. /**
  33477. * @hidden
  33478. * Defines the actions happening just before a render target is drawing.
  33479. */
  33480. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33481. /**
  33482. * @hidden
  33483. * Defines the actions happening just before a rendering group is drawing.
  33484. */
  33485. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33486. /**
  33487. * @hidden
  33488. * Defines the actions happening just before a mesh is drawing.
  33489. */
  33490. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33491. /**
  33492. * @hidden
  33493. * Defines the actions happening just after a mesh has been drawn.
  33494. */
  33495. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33496. /**
  33497. * @hidden
  33498. * Defines the actions happening just after a rendering group has been drawn.
  33499. */
  33500. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33501. /**
  33502. * @hidden
  33503. * Defines the actions happening just after the active camera has been drawn.
  33504. */
  33505. _afterCameraDrawStage: Stage<CameraStageAction>;
  33506. /**
  33507. * @hidden
  33508. * Defines the actions happening just after a render target has been drawn.
  33509. */
  33510. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33511. /**
  33512. * @hidden
  33513. * Defines the actions happening just after rendering all cameras and computing intersections.
  33514. */
  33515. _afterRenderStage: Stage<SimpleStageAction>;
  33516. /**
  33517. * @hidden
  33518. * Defines the actions happening when a pointer move event happens.
  33519. */
  33520. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33521. /**
  33522. * @hidden
  33523. * Defines the actions happening when a pointer down event happens.
  33524. */
  33525. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening when a pointer up event happens.
  33529. */
  33530. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33531. /**
  33532. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33533. */
  33534. private geometriesByUniqueId;
  33535. /**
  33536. * Creates a new Scene
  33537. * @param engine defines the engine to use to render this scene
  33538. * @param options defines the scene options
  33539. */
  33540. constructor(engine: Engine, options?: SceneOptions);
  33541. /**
  33542. * Gets a string idenfifying the name of the class
  33543. * @returns "Scene" string
  33544. */
  33545. getClassName(): string;
  33546. private _defaultMeshCandidates;
  33547. /**
  33548. * @hidden
  33549. */
  33550. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33551. private _defaultSubMeshCandidates;
  33552. /**
  33553. * @hidden
  33554. */
  33555. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33556. /**
  33557. * Sets the default candidate providers for the scene.
  33558. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33559. * and getCollidingSubMeshCandidates to their default function
  33560. */
  33561. setDefaultCandidateProviders(): void;
  33562. /**
  33563. * Gets the mesh that is currently under the pointer
  33564. */
  33565. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33566. /**
  33567. * Gets or sets the current on-screen X position of the pointer
  33568. */
  33569. pointerX: number;
  33570. /**
  33571. * Gets or sets the current on-screen Y position of the pointer
  33572. */
  33573. pointerY: number;
  33574. /**
  33575. * Gets the cached material (ie. the latest rendered one)
  33576. * @returns the cached material
  33577. */
  33578. getCachedMaterial(): Nullable<Material>;
  33579. /**
  33580. * Gets the cached effect (ie. the latest rendered one)
  33581. * @returns the cached effect
  33582. */
  33583. getCachedEffect(): Nullable<Effect>;
  33584. /**
  33585. * Gets the cached visibility state (ie. the latest rendered one)
  33586. * @returns the cached visibility state
  33587. */
  33588. getCachedVisibility(): Nullable<number>;
  33589. /**
  33590. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33591. * @param material defines the current material
  33592. * @param effect defines the current effect
  33593. * @param visibility defines the current visibility state
  33594. * @returns true if one parameter is not cached
  33595. */
  33596. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33597. /**
  33598. * Gets the engine associated with the scene
  33599. * @returns an Engine
  33600. */
  33601. getEngine(): Engine;
  33602. /**
  33603. * Gets the total number of vertices rendered per frame
  33604. * @returns the total number of vertices rendered per frame
  33605. */
  33606. getTotalVertices(): number;
  33607. /**
  33608. * Gets the performance counter for total vertices
  33609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33610. */
  33611. readonly totalVerticesPerfCounter: PerfCounter;
  33612. /**
  33613. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33614. * @returns the total number of active indices rendered per frame
  33615. */
  33616. getActiveIndices(): number;
  33617. /**
  33618. * Gets the performance counter for active indices
  33619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33620. */
  33621. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33622. /**
  33623. * Gets the total number of active particles rendered per frame
  33624. * @returns the total number of active particles rendered per frame
  33625. */
  33626. getActiveParticles(): number;
  33627. /**
  33628. * Gets the performance counter for active particles
  33629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33630. */
  33631. readonly activeParticlesPerfCounter: PerfCounter;
  33632. /**
  33633. * Gets the total number of active bones rendered per frame
  33634. * @returns the total number of active bones rendered per frame
  33635. */
  33636. getActiveBones(): number;
  33637. /**
  33638. * Gets the performance counter for active bones
  33639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33640. */
  33641. readonly activeBonesPerfCounter: PerfCounter;
  33642. /**
  33643. * Gets the array of active meshes
  33644. * @returns an array of AbstractMesh
  33645. */
  33646. getActiveMeshes(): SmartArray<AbstractMesh>;
  33647. /**
  33648. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33649. * @returns a number
  33650. */
  33651. getAnimationRatio(): number;
  33652. /**
  33653. * Gets an unique Id for the current render phase
  33654. * @returns a number
  33655. */
  33656. getRenderId(): number;
  33657. /**
  33658. * Gets an unique Id for the current frame
  33659. * @returns a number
  33660. */
  33661. getFrameId(): number;
  33662. /** Call this function if you want to manually increment the render Id*/
  33663. incrementRenderId(): void;
  33664. private _createUbo;
  33665. /**
  33666. * Use this method to simulate a pointer move on a mesh
  33667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33670. * @returns the current scene
  33671. */
  33672. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33673. /**
  33674. * Use this method to simulate a pointer down on a mesh
  33675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33678. * @returns the current scene
  33679. */
  33680. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33681. /**
  33682. * Use this method to simulate a pointer up on a mesh
  33683. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33684. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33685. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33686. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33687. * @returns the current scene
  33688. */
  33689. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33690. /**
  33691. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33692. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33693. * @returns true if the pointer was captured
  33694. */
  33695. isPointerCaptured(pointerId?: number): boolean;
  33696. /**
  33697. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33698. * @param attachUp defines if you want to attach events to pointerup
  33699. * @param attachDown defines if you want to attach events to pointerdown
  33700. * @param attachMove defines if you want to attach events to pointermove
  33701. */
  33702. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33703. /** Detaches all event handlers*/
  33704. detachControl(): void;
  33705. /**
  33706. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33707. * Delay loaded resources are not taking in account
  33708. * @return true if all required resources are ready
  33709. */
  33710. isReady(): boolean;
  33711. /** Resets all cached information relative to material (including effect and visibility) */
  33712. resetCachedMaterial(): void;
  33713. /**
  33714. * Registers a function to be called before every frame render
  33715. * @param func defines the function to register
  33716. */
  33717. registerBeforeRender(func: () => void): void;
  33718. /**
  33719. * Unregisters a function called before every frame render
  33720. * @param func defines the function to unregister
  33721. */
  33722. unregisterBeforeRender(func: () => void): void;
  33723. /**
  33724. * Registers a function to be called after every frame render
  33725. * @param func defines the function to register
  33726. */
  33727. registerAfterRender(func: () => void): void;
  33728. /**
  33729. * Unregisters a function called after every frame render
  33730. * @param func defines the function to unregister
  33731. */
  33732. unregisterAfterRender(func: () => void): void;
  33733. private _executeOnceBeforeRender;
  33734. /**
  33735. * The provided function will run before render once and will be disposed afterwards.
  33736. * A timeout delay can be provided so that the function will be executed in N ms.
  33737. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33738. * @param func The function to be executed.
  33739. * @param timeout optional delay in ms
  33740. */
  33741. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33742. /** @hidden */
  33743. _addPendingData(data: any): void;
  33744. /** @hidden */
  33745. _removePendingData(data: any): void;
  33746. /**
  33747. * Returns the number of items waiting to be loaded
  33748. * @returns the number of items waiting to be loaded
  33749. */
  33750. getWaitingItemsCount(): number;
  33751. /**
  33752. * Returns a boolean indicating if the scene is still loading data
  33753. */
  33754. readonly isLoading: boolean;
  33755. /**
  33756. * Registers a function to be executed when the scene is ready
  33757. * @param {Function} func - the function to be executed
  33758. */
  33759. executeWhenReady(func: () => void): void;
  33760. /**
  33761. * Returns a promise that resolves when the scene is ready
  33762. * @returns A promise that resolves when the scene is ready
  33763. */
  33764. whenReadyAsync(): Promise<void>;
  33765. /** @hidden */
  33766. _checkIsReady(): void;
  33767. /**
  33768. * Gets all animatable attached to the scene
  33769. */
  33770. readonly animatables: Animatable[];
  33771. /**
  33772. * Resets the last animation time frame.
  33773. * Useful to override when animations start running when loading a scene for the first time.
  33774. */
  33775. resetLastAnimationTimeFrame(): void;
  33776. /**
  33777. * Gets the current view matrix
  33778. * @returns a Matrix
  33779. */
  33780. getViewMatrix(): Matrix;
  33781. /**
  33782. * Gets the current projection matrix
  33783. * @returns a Matrix
  33784. */
  33785. getProjectionMatrix(): Matrix;
  33786. /**
  33787. * Gets the current transform matrix
  33788. * @returns a Matrix made of View * Projection
  33789. */
  33790. getTransformMatrix(): Matrix;
  33791. /**
  33792. * Sets the current transform matrix
  33793. * @param viewL defines the View matrix to use
  33794. * @param projectionL defines the Projection matrix to use
  33795. * @param viewR defines the right View matrix to use (if provided)
  33796. * @param projectionR defines the right Projection matrix to use (if provided)
  33797. */
  33798. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33799. /**
  33800. * Gets the uniform buffer used to store scene data
  33801. * @returns a UniformBuffer
  33802. */
  33803. getSceneUniformBuffer(): UniformBuffer;
  33804. /**
  33805. * Gets an unique (relatively to the current scene) Id
  33806. * @returns an unique number for the scene
  33807. */
  33808. getUniqueId(): number;
  33809. /**
  33810. * Add a mesh to the list of scene's meshes
  33811. * @param newMesh defines the mesh to add
  33812. * @param recursive if all child meshes should also be added to the scene
  33813. */
  33814. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33815. /**
  33816. * Remove a mesh for the list of scene's meshes
  33817. * @param toRemove defines the mesh to remove
  33818. * @param recursive if all child meshes should also be removed from the scene
  33819. * @returns the index where the mesh was in the mesh list
  33820. */
  33821. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33822. /**
  33823. * Add a transform node to the list of scene's transform nodes
  33824. * @param newTransformNode defines the transform node to add
  33825. */
  33826. addTransformNode(newTransformNode: TransformNode): void;
  33827. /**
  33828. * Remove a transform node for the list of scene's transform nodes
  33829. * @param toRemove defines the transform node to remove
  33830. * @returns the index where the transform node was in the transform node list
  33831. */
  33832. removeTransformNode(toRemove: TransformNode): number;
  33833. /**
  33834. * Remove a skeleton for the list of scene's skeletons
  33835. * @param toRemove defines the skeleton to remove
  33836. * @returns the index where the skeleton was in the skeleton list
  33837. */
  33838. removeSkeleton(toRemove: Skeleton): number;
  33839. /**
  33840. * Remove a morph target for the list of scene's morph targets
  33841. * @param toRemove defines the morph target to remove
  33842. * @returns the index where the morph target was in the morph target list
  33843. */
  33844. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33845. /**
  33846. * Remove a light for the list of scene's lights
  33847. * @param toRemove defines the light to remove
  33848. * @returns the index where the light was in the light list
  33849. */
  33850. removeLight(toRemove: Light): number;
  33851. /**
  33852. * Remove a camera for the list of scene's cameras
  33853. * @param toRemove defines the camera to remove
  33854. * @returns the index where the camera was in the camera list
  33855. */
  33856. removeCamera(toRemove: Camera): number;
  33857. /**
  33858. * Remove a particle system for the list of scene's particle systems
  33859. * @param toRemove defines the particle system to remove
  33860. * @returns the index where the particle system was in the particle system list
  33861. */
  33862. removeParticleSystem(toRemove: IParticleSystem): number;
  33863. /**
  33864. * Remove a animation for the list of scene's animations
  33865. * @param toRemove defines the animation to remove
  33866. * @returns the index where the animation was in the animation list
  33867. */
  33868. removeAnimation(toRemove: Animation): number;
  33869. /**
  33870. * Will stop the animation of the given target
  33871. * @param target - the target
  33872. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33873. * @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)
  33874. */
  33875. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33876. /**
  33877. * Removes the given animation group from this scene.
  33878. * @param toRemove The animation group to remove
  33879. * @returns The index of the removed animation group
  33880. */
  33881. removeAnimationGroup(toRemove: AnimationGroup): number;
  33882. /**
  33883. * Removes the given multi-material from this scene.
  33884. * @param toRemove The multi-material to remove
  33885. * @returns The index of the removed multi-material
  33886. */
  33887. removeMultiMaterial(toRemove: MultiMaterial): number;
  33888. /**
  33889. * Removes the given material from this scene.
  33890. * @param toRemove The material to remove
  33891. * @returns The index of the removed material
  33892. */
  33893. removeMaterial(toRemove: Material): number;
  33894. /**
  33895. * Removes the given action manager from this scene.
  33896. * @param toRemove The action manager to remove
  33897. * @returns The index of the removed action manager
  33898. */
  33899. removeActionManager(toRemove: AbstractActionManager): number;
  33900. /**
  33901. * Removes the given texture from this scene.
  33902. * @param toRemove The texture to remove
  33903. * @returns The index of the removed texture
  33904. */
  33905. removeTexture(toRemove: BaseTexture): number;
  33906. /**
  33907. * Adds the given light to this scene
  33908. * @param newLight The light to add
  33909. */
  33910. addLight(newLight: Light): void;
  33911. /**
  33912. * Sorts the list list based on light priorities
  33913. */
  33914. sortLightsByPriority(): void;
  33915. /**
  33916. * Adds the given camera to this scene
  33917. * @param newCamera The camera to add
  33918. */
  33919. addCamera(newCamera: Camera): void;
  33920. /**
  33921. * Adds the given skeleton to this scene
  33922. * @param newSkeleton The skeleton to add
  33923. */
  33924. addSkeleton(newSkeleton: Skeleton): void;
  33925. /**
  33926. * Adds the given particle system to this scene
  33927. * @param newParticleSystem The particle system to add
  33928. */
  33929. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33930. /**
  33931. * Adds the given animation to this scene
  33932. * @param newAnimation The animation to add
  33933. */
  33934. addAnimation(newAnimation: Animation): void;
  33935. /**
  33936. * Adds the given animation group to this scene.
  33937. * @param newAnimationGroup The animation group to add
  33938. */
  33939. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33940. /**
  33941. * Adds the given multi-material to this scene
  33942. * @param newMultiMaterial The multi-material to add
  33943. */
  33944. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33945. /**
  33946. * Adds the given material to this scene
  33947. * @param newMaterial The material to add
  33948. */
  33949. addMaterial(newMaterial: Material): void;
  33950. /**
  33951. * Adds the given morph target to this scene
  33952. * @param newMorphTargetManager The morph target to add
  33953. */
  33954. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33955. /**
  33956. * Adds the given geometry to this scene
  33957. * @param newGeometry The geometry to add
  33958. */
  33959. addGeometry(newGeometry: Geometry): void;
  33960. /**
  33961. * Adds the given action manager to this scene
  33962. * @param newActionManager The action manager to add
  33963. */
  33964. addActionManager(newActionManager: AbstractActionManager): void;
  33965. /**
  33966. * Adds the given texture to this scene.
  33967. * @param newTexture The texture to add
  33968. */
  33969. addTexture(newTexture: BaseTexture): void;
  33970. /**
  33971. * Switch active camera
  33972. * @param newCamera defines the new active camera
  33973. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33974. */
  33975. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33976. /**
  33977. * sets the active camera of the scene using its ID
  33978. * @param id defines the camera's ID
  33979. * @return the new active camera or null if none found.
  33980. */
  33981. setActiveCameraByID(id: string): Nullable<Camera>;
  33982. /**
  33983. * sets the active camera of the scene using its name
  33984. * @param name defines the camera's name
  33985. * @returns the new active camera or null if none found.
  33986. */
  33987. setActiveCameraByName(name: string): Nullable<Camera>;
  33988. /**
  33989. * get an animation group using its name
  33990. * @param name defines the material's name
  33991. * @return the animation group or null if none found.
  33992. */
  33993. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33994. /**
  33995. * Get a material using its unique id
  33996. * @param uniqueId defines the material's unique id
  33997. * @return the material or null if none found.
  33998. */
  33999. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34000. /**
  34001. * get a material using its id
  34002. * @param id defines the material's ID
  34003. * @return the material or null if none found.
  34004. */
  34005. getMaterialByID(id: string): Nullable<Material>;
  34006. /**
  34007. * Gets a the last added material using a given id
  34008. * @param id defines the material's ID
  34009. * @return the last material with the given id or null if none found.
  34010. */
  34011. getLastMaterialByID(id: string): Nullable<Material>;
  34012. /**
  34013. * Gets a material using its name
  34014. * @param name defines the material's name
  34015. * @return the material or null if none found.
  34016. */
  34017. getMaterialByName(name: string): Nullable<Material>;
  34018. /**
  34019. * Get a texture using its unique id
  34020. * @param uniqueId defines the texture's unique id
  34021. * @return the texture or null if none found.
  34022. */
  34023. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34024. /**
  34025. * Gets a camera using its id
  34026. * @param id defines the id to look for
  34027. * @returns the camera or null if not found
  34028. */
  34029. getCameraByID(id: string): Nullable<Camera>;
  34030. /**
  34031. * Gets a camera using its unique id
  34032. * @param uniqueId defines the unique id to look for
  34033. * @returns the camera or null if not found
  34034. */
  34035. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34036. /**
  34037. * Gets a camera using its name
  34038. * @param name defines the camera's name
  34039. * @return the camera or null if none found.
  34040. */
  34041. getCameraByName(name: string): Nullable<Camera>;
  34042. /**
  34043. * Gets a bone using its id
  34044. * @param id defines the bone's id
  34045. * @return the bone or null if not found
  34046. */
  34047. getBoneByID(id: string): Nullable<Bone>;
  34048. /**
  34049. * Gets a bone using its id
  34050. * @param name defines the bone's name
  34051. * @return the bone or null if not found
  34052. */
  34053. getBoneByName(name: string): Nullable<Bone>;
  34054. /**
  34055. * Gets a light node using its name
  34056. * @param name defines the the light's name
  34057. * @return the light or null if none found.
  34058. */
  34059. getLightByName(name: string): Nullable<Light>;
  34060. /**
  34061. * Gets a light node using its id
  34062. * @param id defines the light's id
  34063. * @return the light or null if none found.
  34064. */
  34065. getLightByID(id: string): Nullable<Light>;
  34066. /**
  34067. * Gets a light node using its scene-generated unique ID
  34068. * @param uniqueId defines the light's unique id
  34069. * @return the light or null if none found.
  34070. */
  34071. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34072. /**
  34073. * Gets a particle system by id
  34074. * @param id defines the particle system id
  34075. * @return the corresponding system or null if none found
  34076. */
  34077. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34078. /**
  34079. * Gets a geometry using its ID
  34080. * @param id defines the geometry's id
  34081. * @return the geometry or null if none found.
  34082. */
  34083. getGeometryByID(id: string): Nullable<Geometry>;
  34084. private _getGeometryByUniqueID;
  34085. /**
  34086. * Add a new geometry to this scene
  34087. * @param geometry defines the geometry to be added to the scene.
  34088. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34089. * @return a boolean defining if the geometry was added or not
  34090. */
  34091. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34092. /**
  34093. * Removes an existing geometry
  34094. * @param geometry defines the geometry to be removed from the scene
  34095. * @return a boolean defining if the geometry was removed or not
  34096. */
  34097. removeGeometry(geometry: Geometry): boolean;
  34098. /**
  34099. * Gets the list of geometries attached to the scene
  34100. * @returns an array of Geometry
  34101. */
  34102. getGeometries(): Geometry[];
  34103. /**
  34104. * Gets the first added mesh found of a given ID
  34105. * @param id defines the id to search for
  34106. * @return the mesh found or null if not found at all
  34107. */
  34108. getMeshByID(id: string): Nullable<AbstractMesh>;
  34109. /**
  34110. * Gets a list of meshes using their id
  34111. * @param id defines the id to search for
  34112. * @returns a list of meshes
  34113. */
  34114. getMeshesByID(id: string): Array<AbstractMesh>;
  34115. /**
  34116. * Gets the first added transform node found of a given ID
  34117. * @param id defines the id to search for
  34118. * @return the found transform node or null if not found at all.
  34119. */
  34120. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34121. /**
  34122. * Gets a transform node with its auto-generated unique id
  34123. * @param uniqueId efines the unique id to search for
  34124. * @return the found transform node or null if not found at all.
  34125. */
  34126. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34127. /**
  34128. * Gets a list of transform nodes using their id
  34129. * @param id defines the id to search for
  34130. * @returns a list of transform nodes
  34131. */
  34132. getTransformNodesByID(id: string): Array<TransformNode>;
  34133. /**
  34134. * Gets a mesh with its auto-generated unique id
  34135. * @param uniqueId defines the unique id to search for
  34136. * @return the found mesh or null if not found at all.
  34137. */
  34138. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34139. /**
  34140. * Gets a the last added mesh using a given id
  34141. * @param id defines the id to search for
  34142. * @return the found mesh or null if not found at all.
  34143. */
  34144. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34145. /**
  34146. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34147. * @param id defines the id to search for
  34148. * @return the found node or null if not found at all
  34149. */
  34150. getLastEntryByID(id: string): Nullable<Node>;
  34151. /**
  34152. * Gets a node (Mesh, Camera, Light) using a given id
  34153. * @param id defines the id to search for
  34154. * @return the found node or null if not found at all
  34155. */
  34156. getNodeByID(id: string): Nullable<Node>;
  34157. /**
  34158. * Gets a node (Mesh, Camera, Light) using a given name
  34159. * @param name defines the name to search for
  34160. * @return the found node or null if not found at all.
  34161. */
  34162. getNodeByName(name: string): Nullable<Node>;
  34163. /**
  34164. * Gets a mesh using a given name
  34165. * @param name defines the name to search for
  34166. * @return the found mesh or null if not found at all.
  34167. */
  34168. getMeshByName(name: string): Nullable<AbstractMesh>;
  34169. /**
  34170. * Gets a transform node using a given name
  34171. * @param name defines the name to search for
  34172. * @return the found transform node or null if not found at all.
  34173. */
  34174. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34175. /**
  34176. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34177. * @param id defines the id to search for
  34178. * @return the found skeleton or null if not found at all.
  34179. */
  34180. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34181. /**
  34182. * Gets a skeleton using a given auto generated unique id
  34183. * @param uniqueId defines the unique id to search for
  34184. * @return the found skeleton or null if not found at all.
  34185. */
  34186. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34187. /**
  34188. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34189. * @param id defines the id to search for
  34190. * @return the found skeleton or null if not found at all.
  34191. */
  34192. getSkeletonById(id: string): Nullable<Skeleton>;
  34193. /**
  34194. * Gets a skeleton using a given name
  34195. * @param name defines the name to search for
  34196. * @return the found skeleton or null if not found at all.
  34197. */
  34198. getSkeletonByName(name: string): Nullable<Skeleton>;
  34199. /**
  34200. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34201. * @param id defines the id to search for
  34202. * @return the found morph target manager or null if not found at all.
  34203. */
  34204. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34205. /**
  34206. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34207. * @param id defines the id to search for
  34208. * @return the found morph target or null if not found at all.
  34209. */
  34210. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34211. /**
  34212. * Gets a boolean indicating if the given mesh is active
  34213. * @param mesh defines the mesh to look for
  34214. * @returns true if the mesh is in the active list
  34215. */
  34216. isActiveMesh(mesh: AbstractMesh): boolean;
  34217. /**
  34218. * Return a unique id as a string which can serve as an identifier for the scene
  34219. */
  34220. readonly uid: string;
  34221. /**
  34222. * Add an externaly attached data from its key.
  34223. * This method call will fail and return false, if such key already exists.
  34224. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34225. * @param key the unique key that identifies the data
  34226. * @param data the data object to associate to the key for this Engine instance
  34227. * @return true if no such key were already present and the data was added successfully, false otherwise
  34228. */
  34229. addExternalData<T>(key: string, data: T): boolean;
  34230. /**
  34231. * Get an externaly attached data from its key
  34232. * @param key the unique key that identifies the data
  34233. * @return the associated data, if present (can be null), or undefined if not present
  34234. */
  34235. getExternalData<T>(key: string): Nullable<T>;
  34236. /**
  34237. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34238. * @param key the unique key that identifies the data
  34239. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34240. * @return the associated data, can be null if the factory returned null.
  34241. */
  34242. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34243. /**
  34244. * Remove an externaly attached data from the Engine instance
  34245. * @param key the unique key that identifies the data
  34246. * @return true if the data was successfully removed, false if it doesn't exist
  34247. */
  34248. removeExternalData(key: string): boolean;
  34249. private _evaluateSubMesh;
  34250. /**
  34251. * Clear the processed materials smart array preventing retention point in material dispose.
  34252. */
  34253. freeProcessedMaterials(): void;
  34254. private _preventFreeActiveMeshesAndRenderingGroups;
  34255. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34256. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34257. * when disposing several meshes in a row or a hierarchy of meshes.
  34258. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34259. */
  34260. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34261. /**
  34262. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34263. */
  34264. freeActiveMeshes(): void;
  34265. /**
  34266. * Clear the info related to rendering groups preventing retention points during dispose.
  34267. */
  34268. freeRenderingGroups(): void;
  34269. /** @hidden */
  34270. _isInIntermediateRendering(): boolean;
  34271. /**
  34272. * Lambda returning the list of potentially active meshes.
  34273. */
  34274. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34275. /**
  34276. * Lambda returning the list of potentially active sub meshes.
  34277. */
  34278. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34279. /**
  34280. * Lambda returning the list of potentially intersecting sub meshes.
  34281. */
  34282. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34283. /**
  34284. * Lambda returning the list of potentially colliding sub meshes.
  34285. */
  34286. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34287. private _activeMeshesFrozen;
  34288. /**
  34289. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34290. * @returns the current scene
  34291. */
  34292. freezeActiveMeshes(): Scene;
  34293. /**
  34294. * Use this function to restart evaluating active meshes on every frame
  34295. * @returns the current scene
  34296. */
  34297. unfreezeActiveMeshes(): Scene;
  34298. private _evaluateActiveMeshes;
  34299. private _activeMesh;
  34300. /**
  34301. * Update the transform matrix to update from the current active camera
  34302. * @param force defines a boolean used to force the update even if cache is up to date
  34303. */
  34304. updateTransformMatrix(force?: boolean): void;
  34305. private _bindFrameBuffer;
  34306. /** @hidden */
  34307. _allowPostProcessClearColor: boolean;
  34308. /** @hidden */
  34309. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34310. private _processSubCameras;
  34311. private _checkIntersections;
  34312. /** @hidden */
  34313. _advancePhysicsEngineStep(step: number): void;
  34314. /**
  34315. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34316. */
  34317. getDeterministicFrameTime: () => number;
  34318. /** @hidden */
  34319. _animate(): void;
  34320. /** Execute all animations (for a frame) */
  34321. animate(): void;
  34322. /**
  34323. * Render the scene
  34324. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34325. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34326. */
  34327. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34328. /**
  34329. * Freeze all materials
  34330. * A frozen material will not be updatable but should be faster to render
  34331. */
  34332. freezeMaterials(): void;
  34333. /**
  34334. * Unfreeze all materials
  34335. * A frozen material will not be updatable but should be faster to render
  34336. */
  34337. unfreezeMaterials(): void;
  34338. /**
  34339. * Releases all held ressources
  34340. */
  34341. dispose(): void;
  34342. /**
  34343. * Gets if the scene is already disposed
  34344. */
  34345. readonly isDisposed: boolean;
  34346. /**
  34347. * Call this function to reduce memory footprint of the scene.
  34348. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34349. */
  34350. clearCachedVertexData(): void;
  34351. /**
  34352. * This function will remove the local cached buffer data from texture.
  34353. * It will save memory but will prevent the texture from being rebuilt
  34354. */
  34355. cleanCachedTextureBuffer(): void;
  34356. /**
  34357. * Get the world extend vectors with an optional filter
  34358. *
  34359. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34360. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34361. */
  34362. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34363. min: Vector3;
  34364. max: Vector3;
  34365. };
  34366. /**
  34367. * Creates a ray that can be used to pick in the scene
  34368. * @param x defines the x coordinate of the origin (on-screen)
  34369. * @param y defines the y coordinate of the origin (on-screen)
  34370. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34371. * @param camera defines the camera to use for the picking
  34372. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34373. * @returns a Ray
  34374. */
  34375. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34376. /**
  34377. * Creates a ray that can be used to pick in the scene
  34378. * @param x defines the x coordinate of the origin (on-screen)
  34379. * @param y defines the y coordinate of the origin (on-screen)
  34380. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34381. * @param result defines the ray where to store the picking ray
  34382. * @param camera defines the camera to use for the picking
  34383. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34384. * @returns the current scene
  34385. */
  34386. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34387. /**
  34388. * Creates a ray that can be used to pick in the scene
  34389. * @param x defines the x coordinate of the origin (on-screen)
  34390. * @param y defines the y coordinate of the origin (on-screen)
  34391. * @param camera defines the camera to use for the picking
  34392. * @returns a Ray
  34393. */
  34394. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34395. /**
  34396. * Creates a ray that can be used to pick in the scene
  34397. * @param x defines the x coordinate of the origin (on-screen)
  34398. * @param y defines the y coordinate of the origin (on-screen)
  34399. * @param result defines the ray where to store the picking ray
  34400. * @param camera defines the camera to use for the picking
  34401. * @returns the current scene
  34402. */
  34403. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34404. /** Launch a ray to try to pick a mesh in the scene
  34405. * @param x position on screen
  34406. * @param y position on screen
  34407. * @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
  34408. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34409. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34411. * @returns a PickingInfo
  34412. */
  34413. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34414. /** Use the given ray to pick a mesh in the scene
  34415. * @param ray The ray to use to pick meshes
  34416. * @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
  34417. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34419. * @returns a PickingInfo
  34420. */
  34421. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34422. /**
  34423. * Launch a ray to try to pick a mesh in the scene
  34424. * @param x X position on screen
  34425. * @param y Y position on screen
  34426. * @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
  34427. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34429. * @returns an array of PickingInfo
  34430. */
  34431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34432. /**
  34433. * Launch a ray to try to pick a mesh in the scene
  34434. * @param ray Ray to use
  34435. * @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
  34436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34437. * @returns an array of PickingInfo
  34438. */
  34439. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34440. /**
  34441. * Force the value of meshUnderPointer
  34442. * @param mesh defines the mesh to use
  34443. */
  34444. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34445. /**
  34446. * Gets the mesh under the pointer
  34447. * @returns a Mesh or null if no mesh is under the pointer
  34448. */
  34449. getPointerOverMesh(): Nullable<AbstractMesh>;
  34450. /** @hidden */
  34451. _rebuildGeometries(): void;
  34452. /** @hidden */
  34453. _rebuildTextures(): void;
  34454. private _getByTags;
  34455. /**
  34456. * Get a list of meshes by tags
  34457. * @param tagsQuery defines the tags query to use
  34458. * @param forEach defines a predicate used to filter results
  34459. * @returns an array of Mesh
  34460. */
  34461. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34462. /**
  34463. * Get a list of cameras by tags
  34464. * @param tagsQuery defines the tags query to use
  34465. * @param forEach defines a predicate used to filter results
  34466. * @returns an array of Camera
  34467. */
  34468. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34469. /**
  34470. * Get a list of lights by tags
  34471. * @param tagsQuery defines the tags query to use
  34472. * @param forEach defines a predicate used to filter results
  34473. * @returns an array of Light
  34474. */
  34475. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34476. /**
  34477. * Get a list of materials by tags
  34478. * @param tagsQuery defines the tags query to use
  34479. * @param forEach defines a predicate used to filter results
  34480. * @returns an array of Material
  34481. */
  34482. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34483. /**
  34484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34485. * This allowed control for front to back rendering or reversly depending of the special needs.
  34486. *
  34487. * @param renderingGroupId The rendering group id corresponding to its index
  34488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34491. */
  34492. 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;
  34493. /**
  34494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34495. *
  34496. * @param renderingGroupId The rendering group id corresponding to its index
  34497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34500. */
  34501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34502. /**
  34503. * Gets the current auto clear configuration for one rendering group of the rendering
  34504. * manager.
  34505. * @param index the rendering group index to get the information for
  34506. * @returns The auto clear setup for the requested rendering group
  34507. */
  34508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34509. private _blockMaterialDirtyMechanism;
  34510. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34511. blockMaterialDirtyMechanism: boolean;
  34512. /**
  34513. * Will flag all materials as dirty to trigger new shader compilation
  34514. * @param flag defines the flag used to specify which material part must be marked as dirty
  34515. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34516. */
  34517. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34518. /** @hidden */
  34519. _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;
  34520. /** @hidden */
  34521. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34522. }
  34523. }
  34524. declare module BABYLON {
  34525. /**
  34526. * Set of assets to keep when moving a scene into an asset container.
  34527. */
  34528. export class KeepAssets extends AbstractScene {
  34529. }
  34530. /**
  34531. * Container with a set of assets that can be added or removed from a scene.
  34532. */
  34533. export class AssetContainer extends AbstractScene {
  34534. /**
  34535. * The scene the AssetContainer belongs to.
  34536. */
  34537. scene: Scene;
  34538. /**
  34539. * Instantiates an AssetContainer.
  34540. * @param scene The scene the AssetContainer belongs to.
  34541. */
  34542. constructor(scene: Scene);
  34543. /**
  34544. * Adds all the assets from the container to the scene.
  34545. */
  34546. addAllToScene(): void;
  34547. /**
  34548. * Removes all the assets in the container from the scene
  34549. */
  34550. removeAllFromScene(): void;
  34551. /**
  34552. * Disposes all the assets in the container
  34553. */
  34554. dispose(): void;
  34555. private _moveAssets;
  34556. /**
  34557. * Removes all the assets contained in the scene and adds them to the container.
  34558. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34559. */
  34560. moveAllFromScene(keepAssets?: KeepAssets): void;
  34561. /**
  34562. * 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.
  34563. * @returns the root mesh
  34564. */
  34565. createRootMesh(): Mesh;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * Defines how the parser contract is defined.
  34571. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34572. */
  34573. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34574. /**
  34575. * Defines how the individual parser contract is defined.
  34576. * These parser can parse an individual asset
  34577. */
  34578. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34579. /**
  34580. * Base class of the scene acting as a container for the different elements composing a scene.
  34581. * This class is dynamically extended by the different components of the scene increasing
  34582. * flexibility and reducing coupling
  34583. */
  34584. export abstract class AbstractScene {
  34585. /**
  34586. * Stores the list of available parsers in the application.
  34587. */
  34588. private static _BabylonFileParsers;
  34589. /**
  34590. * Stores the list of available individual parsers in the application.
  34591. */
  34592. private static _IndividualBabylonFileParsers;
  34593. /**
  34594. * Adds a parser in the list of available ones
  34595. * @param name Defines the name of the parser
  34596. * @param parser Defines the parser to add
  34597. */
  34598. static AddParser(name: string, parser: BabylonFileParser): void;
  34599. /**
  34600. * Gets a general parser from the list of avaialble ones
  34601. * @param name Defines the name of the parser
  34602. * @returns the requested parser or null
  34603. */
  34604. static GetParser(name: string): Nullable<BabylonFileParser>;
  34605. /**
  34606. * Adds n individual parser in the list of available ones
  34607. * @param name Defines the name of the parser
  34608. * @param parser Defines the parser to add
  34609. */
  34610. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34611. /**
  34612. * Gets an individual parser from the list of avaialble ones
  34613. * @param name Defines the name of the parser
  34614. * @returns the requested parser or null
  34615. */
  34616. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34617. /**
  34618. * Parser json data and populate both a scene and its associated container object
  34619. * @param jsonData Defines the data to parse
  34620. * @param scene Defines the scene to parse the data for
  34621. * @param container Defines the container attached to the parsing sequence
  34622. * @param rootUrl Defines the root url of the data
  34623. */
  34624. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34625. /**
  34626. * Gets the list of root nodes (ie. nodes with no parent)
  34627. */
  34628. rootNodes: Node[];
  34629. /** All of the cameras added to this scene
  34630. * @see http://doc.babylonjs.com/babylon101/cameras
  34631. */
  34632. cameras: Camera[];
  34633. /**
  34634. * All of the lights added to this scene
  34635. * @see http://doc.babylonjs.com/babylon101/lights
  34636. */
  34637. lights: Light[];
  34638. /**
  34639. * All of the (abstract) meshes added to this scene
  34640. */
  34641. meshes: AbstractMesh[];
  34642. /**
  34643. * The list of skeletons added to the scene
  34644. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34645. */
  34646. skeletons: Skeleton[];
  34647. /**
  34648. * All of the particle systems added to this scene
  34649. * @see http://doc.babylonjs.com/babylon101/particles
  34650. */
  34651. particleSystems: IParticleSystem[];
  34652. /**
  34653. * Gets a list of Animations associated with the scene
  34654. */
  34655. animations: Animation[];
  34656. /**
  34657. * All of the animation groups added to this scene
  34658. * @see http://doc.babylonjs.com/how_to/group
  34659. */
  34660. animationGroups: AnimationGroup[];
  34661. /**
  34662. * All of the multi-materials added to this scene
  34663. * @see http://doc.babylonjs.com/how_to/multi_materials
  34664. */
  34665. multiMaterials: MultiMaterial[];
  34666. /**
  34667. * All of the materials added to this scene
  34668. * In the context of a Scene, it is not supposed to be modified manually.
  34669. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34670. * Note also that the order of the Material wihin the array is not significant and might change.
  34671. * @see http://doc.babylonjs.com/babylon101/materials
  34672. */
  34673. materials: Material[];
  34674. /**
  34675. * The list of morph target managers added to the scene
  34676. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34677. */
  34678. morphTargetManagers: MorphTargetManager[];
  34679. /**
  34680. * The list of geometries used in the scene.
  34681. */
  34682. geometries: Geometry[];
  34683. /**
  34684. * All of the tranform nodes added to this scene
  34685. * In the context of a Scene, it is not supposed to be modified manually.
  34686. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34687. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34688. * @see http://doc.babylonjs.com/how_to/transformnode
  34689. */
  34690. transformNodes: TransformNode[];
  34691. /**
  34692. * ActionManagers available on the scene.
  34693. */
  34694. actionManagers: AbstractActionManager[];
  34695. /**
  34696. * Textures to keep.
  34697. */
  34698. textures: BaseTexture[];
  34699. /**
  34700. * Environment texture for the scene
  34701. */
  34702. environmentTexture: Nullable<BaseTexture>;
  34703. }
  34704. }
  34705. declare module BABYLON {
  34706. /**
  34707. * Interface used to define options for Sound class
  34708. */
  34709. export interface ISoundOptions {
  34710. /**
  34711. * Does the sound autoplay once loaded.
  34712. */
  34713. autoplay?: boolean;
  34714. /**
  34715. * Does the sound loop after it finishes playing once.
  34716. */
  34717. loop?: boolean;
  34718. /**
  34719. * Sound's volume
  34720. */
  34721. volume?: number;
  34722. /**
  34723. * Is it a spatial sound?
  34724. */
  34725. spatialSound?: boolean;
  34726. /**
  34727. * Maximum distance to hear that sound
  34728. */
  34729. maxDistance?: number;
  34730. /**
  34731. * Uses user defined attenuation function
  34732. */
  34733. useCustomAttenuation?: boolean;
  34734. /**
  34735. * Define the roll off factor of spatial sounds.
  34736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34737. */
  34738. rolloffFactor?: number;
  34739. /**
  34740. * Define the reference distance the sound should be heard perfectly.
  34741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34742. */
  34743. refDistance?: number;
  34744. /**
  34745. * Define the distance attenuation model the sound will follow.
  34746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34747. */
  34748. distanceModel?: string;
  34749. /**
  34750. * Defines the playback speed (1 by default)
  34751. */
  34752. playbackRate?: number;
  34753. /**
  34754. * Defines if the sound is from a streaming source
  34755. */
  34756. streaming?: boolean;
  34757. /**
  34758. * Defines an optional length (in seconds) inside the sound file
  34759. */
  34760. length?: number;
  34761. /**
  34762. * Defines an optional offset (in seconds) inside the sound file
  34763. */
  34764. offset?: number;
  34765. /**
  34766. * If true, URLs will not be required to state the audio file codec to use.
  34767. */
  34768. skipCodecCheck?: boolean;
  34769. }
  34770. /**
  34771. * Defines a sound that can be played in the application.
  34772. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34774. */
  34775. export class Sound {
  34776. /**
  34777. * The name of the sound in the scene.
  34778. */
  34779. name: string;
  34780. /**
  34781. * Does the sound autoplay once loaded.
  34782. */
  34783. autoplay: boolean;
  34784. /**
  34785. * Does the sound loop after it finishes playing once.
  34786. */
  34787. loop: boolean;
  34788. /**
  34789. * Does the sound use a custom attenuation curve to simulate the falloff
  34790. * happening when the source gets further away from the camera.
  34791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34792. */
  34793. useCustomAttenuation: boolean;
  34794. /**
  34795. * The sound track id this sound belongs to.
  34796. */
  34797. soundTrackId: number;
  34798. /**
  34799. * Is this sound currently played.
  34800. */
  34801. isPlaying: boolean;
  34802. /**
  34803. * Is this sound currently paused.
  34804. */
  34805. isPaused: boolean;
  34806. /**
  34807. * Does this sound enables spatial sound.
  34808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34809. */
  34810. spatialSound: boolean;
  34811. /**
  34812. * Define the reference distance the sound should be heard perfectly.
  34813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34814. */
  34815. refDistance: number;
  34816. /**
  34817. * Define the roll off factor of spatial sounds.
  34818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34819. */
  34820. rolloffFactor: number;
  34821. /**
  34822. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34824. */
  34825. maxDistance: number;
  34826. /**
  34827. * Define the distance attenuation model the sound will follow.
  34828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34829. */
  34830. distanceModel: string;
  34831. /**
  34832. * @hidden
  34833. * Back Compat
  34834. **/
  34835. onended: () => any;
  34836. /**
  34837. * Observable event when the current playing sound finishes.
  34838. */
  34839. onEndedObservable: Observable<Sound>;
  34840. private _panningModel;
  34841. private _playbackRate;
  34842. private _streaming;
  34843. private _startTime;
  34844. private _startOffset;
  34845. private _position;
  34846. /** @hidden */
  34847. _positionInEmitterSpace: boolean;
  34848. private _localDirection;
  34849. private _volume;
  34850. private _isReadyToPlay;
  34851. private _isDirectional;
  34852. private _readyToPlayCallback;
  34853. private _audioBuffer;
  34854. private _soundSource;
  34855. private _streamingSource;
  34856. private _soundPanner;
  34857. private _soundGain;
  34858. private _inputAudioNode;
  34859. private _outputAudioNode;
  34860. private _coneInnerAngle;
  34861. private _coneOuterAngle;
  34862. private _coneOuterGain;
  34863. private _scene;
  34864. private _connectedTransformNode;
  34865. private _customAttenuationFunction;
  34866. private _registerFunc;
  34867. private _isOutputConnected;
  34868. private _htmlAudioElement;
  34869. private _urlType;
  34870. private _length?;
  34871. private _offset?;
  34872. /** @hidden */
  34873. static _SceneComponentInitialization: (scene: Scene) => void;
  34874. /**
  34875. * Create a sound and attach it to a scene
  34876. * @param name Name of your sound
  34877. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34878. * @param scene defines the scene the sound belongs to
  34879. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34880. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34881. */
  34882. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34883. /**
  34884. * Release the sound and its associated resources
  34885. */
  34886. dispose(): void;
  34887. /**
  34888. * Gets if the sounds is ready to be played or not.
  34889. * @returns true if ready, otherwise false
  34890. */
  34891. isReady(): boolean;
  34892. private _soundLoaded;
  34893. /**
  34894. * Sets the data of the sound from an audiobuffer
  34895. * @param audioBuffer The audioBuffer containing the data
  34896. */
  34897. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34898. /**
  34899. * Updates the current sounds options such as maxdistance, loop...
  34900. * @param options A JSON object containing values named as the object properties
  34901. */
  34902. updateOptions(options: ISoundOptions): void;
  34903. private _createSpatialParameters;
  34904. private _updateSpatialParameters;
  34905. /**
  34906. * Switch the panning model to HRTF:
  34907. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34909. */
  34910. switchPanningModelToHRTF(): void;
  34911. /**
  34912. * Switch the panning model to Equal Power:
  34913. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34915. */
  34916. switchPanningModelToEqualPower(): void;
  34917. private _switchPanningModel;
  34918. /**
  34919. * Connect this sound to a sound track audio node like gain...
  34920. * @param soundTrackAudioNode the sound track audio node to connect to
  34921. */
  34922. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34923. /**
  34924. * Transform this sound into a directional source
  34925. * @param coneInnerAngle Size of the inner cone in degree
  34926. * @param coneOuterAngle Size of the outer cone in degree
  34927. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34928. */
  34929. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34930. /**
  34931. * Gets or sets the inner angle for the directional cone.
  34932. */
  34933. /**
  34934. * Gets or sets the inner angle for the directional cone.
  34935. */
  34936. directionalConeInnerAngle: number;
  34937. /**
  34938. * Gets or sets the outer angle for the directional cone.
  34939. */
  34940. /**
  34941. * Gets or sets the outer angle for the directional cone.
  34942. */
  34943. directionalConeOuterAngle: number;
  34944. /**
  34945. * Sets the position of the emitter if spatial sound is enabled
  34946. * @param newPosition Defines the new posisiton
  34947. */
  34948. setPosition(newPosition: Vector3): void;
  34949. /**
  34950. * Sets the local direction of the emitter if spatial sound is enabled
  34951. * @param newLocalDirection Defines the new local direction
  34952. */
  34953. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34954. private _updateDirection;
  34955. /** @hidden */
  34956. updateDistanceFromListener(): void;
  34957. /**
  34958. * Sets a new custom attenuation function for the sound.
  34959. * @param callback Defines the function used for the attenuation
  34960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34961. */
  34962. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34963. /**
  34964. * Play the sound
  34965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34966. * @param offset (optional) Start the sound at a specific time in seconds
  34967. * @param length (optional) Sound duration (in seconds)
  34968. */
  34969. play(time?: number, offset?: number, length?: number): void;
  34970. private _onended;
  34971. /**
  34972. * Stop the sound
  34973. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34974. */
  34975. stop(time?: number): void;
  34976. /**
  34977. * Put the sound in pause
  34978. */
  34979. pause(): void;
  34980. /**
  34981. * Sets a dedicated volume for this sounds
  34982. * @param newVolume Define the new volume of the sound
  34983. * @param time Define time for gradual change to new volume
  34984. */
  34985. setVolume(newVolume: number, time?: number): void;
  34986. /**
  34987. * Set the sound play back rate
  34988. * @param newPlaybackRate Define the playback rate the sound should be played at
  34989. */
  34990. setPlaybackRate(newPlaybackRate: number): void;
  34991. /**
  34992. * Gets the volume of the sound.
  34993. * @returns the volume of the sound
  34994. */
  34995. getVolume(): number;
  34996. /**
  34997. * Attach the sound to a dedicated mesh
  34998. * @param transformNode The transform node to connect the sound with
  34999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35000. */
  35001. attachToMesh(transformNode: TransformNode): void;
  35002. /**
  35003. * Detach the sound from the previously attached mesh
  35004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35005. */
  35006. detachFromMesh(): void;
  35007. private _onRegisterAfterWorldMatrixUpdate;
  35008. /**
  35009. * Clone the current sound in the scene.
  35010. * @returns the new sound clone
  35011. */
  35012. clone(): Nullable<Sound>;
  35013. /**
  35014. * Gets the current underlying audio buffer containing the data
  35015. * @returns the audio buffer
  35016. */
  35017. getAudioBuffer(): Nullable<AudioBuffer>;
  35018. /**
  35019. * Serializes the Sound in a JSON representation
  35020. * @returns the JSON representation of the sound
  35021. */
  35022. serialize(): any;
  35023. /**
  35024. * Parse a JSON representation of a sound to innstantiate in a given scene
  35025. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35026. * @param scene Define the scene the new parsed sound should be created in
  35027. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35028. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35029. * @returns the newly parsed sound
  35030. */
  35031. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * This defines an action helpful to play a defined sound on a triggered action.
  35037. */
  35038. export class PlaySoundAction extends Action {
  35039. private _sound;
  35040. /**
  35041. * Instantiate the action
  35042. * @param triggerOptions defines the trigger options
  35043. * @param sound defines the sound to play
  35044. * @param condition defines the trigger related conditions
  35045. */
  35046. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35047. /** @hidden */
  35048. _prepare(): void;
  35049. /**
  35050. * Execute the action and play the sound.
  35051. */
  35052. execute(): void;
  35053. /**
  35054. * Serializes the actions and its related information.
  35055. * @param parent defines the object to serialize in
  35056. * @returns the serialized object
  35057. */
  35058. serialize(parent: any): any;
  35059. }
  35060. /**
  35061. * This defines an action helpful to stop a defined sound on a triggered action.
  35062. */
  35063. export class StopSoundAction extends Action {
  35064. private _sound;
  35065. /**
  35066. * Instantiate the action
  35067. * @param triggerOptions defines the trigger options
  35068. * @param sound defines the sound to stop
  35069. * @param condition defines the trigger related conditions
  35070. */
  35071. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35072. /** @hidden */
  35073. _prepare(): void;
  35074. /**
  35075. * Execute the action and stop the sound.
  35076. */
  35077. execute(): void;
  35078. /**
  35079. * Serializes the actions and its related information.
  35080. * @param parent defines the object to serialize in
  35081. * @returns the serialized object
  35082. */
  35083. serialize(parent: any): any;
  35084. }
  35085. }
  35086. declare module BABYLON {
  35087. /**
  35088. * This defines an action responsible to change the value of a property
  35089. * by interpolating between its current value and the newly set one once triggered.
  35090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35091. */
  35092. export class InterpolateValueAction extends Action {
  35093. /**
  35094. * Defines the path of the property where the value should be interpolated
  35095. */
  35096. propertyPath: string;
  35097. /**
  35098. * Defines the target value at the end of the interpolation.
  35099. */
  35100. value: any;
  35101. /**
  35102. * Defines the time it will take for the property to interpolate to the value.
  35103. */
  35104. duration: number;
  35105. /**
  35106. * Defines if the other scene animations should be stopped when the action has been triggered
  35107. */
  35108. stopOtherAnimations?: boolean;
  35109. /**
  35110. * Defines a callback raised once the interpolation animation has been done.
  35111. */
  35112. onInterpolationDone?: () => void;
  35113. /**
  35114. * Observable triggered once the interpolation animation has been done.
  35115. */
  35116. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35117. private _target;
  35118. private _effectiveTarget;
  35119. private _property;
  35120. /**
  35121. * Instantiate the action
  35122. * @param triggerOptions defines the trigger options
  35123. * @param target defines the object containing the value to interpolate
  35124. * @param propertyPath defines the path to the property in the target object
  35125. * @param value defines the target value at the end of the interpolation
  35126. * @param duration deines the time it will take for the property to interpolate to the value.
  35127. * @param condition defines the trigger related conditions
  35128. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35129. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35130. */
  35131. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35132. /** @hidden */
  35133. _prepare(): void;
  35134. /**
  35135. * Execute the action starts the value interpolation.
  35136. */
  35137. execute(): void;
  35138. /**
  35139. * Serializes the actions and its related information.
  35140. * @param parent defines the object to serialize in
  35141. * @returns the serialized object
  35142. */
  35143. serialize(parent: any): any;
  35144. }
  35145. }
  35146. declare module BABYLON {
  35147. /**
  35148. * Options allowed during the creation of a sound track.
  35149. */
  35150. export interface ISoundTrackOptions {
  35151. /**
  35152. * The volume the sound track should take during creation
  35153. */
  35154. volume?: number;
  35155. /**
  35156. * Define if the sound track is the main sound track of the scene
  35157. */
  35158. mainTrack?: boolean;
  35159. }
  35160. /**
  35161. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35162. * It will be also used in a future release to apply effects on a specific track.
  35163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35164. */
  35165. export class SoundTrack {
  35166. /**
  35167. * The unique identifier of the sound track in the scene.
  35168. */
  35169. id: number;
  35170. /**
  35171. * The list of sounds included in the sound track.
  35172. */
  35173. soundCollection: Array<Sound>;
  35174. private _outputAudioNode;
  35175. private _scene;
  35176. private _isMainTrack;
  35177. private _connectedAnalyser;
  35178. private _options;
  35179. private _isInitialized;
  35180. /**
  35181. * Creates a new sound track.
  35182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35183. * @param scene Define the scene the sound track belongs to
  35184. * @param options
  35185. */
  35186. constructor(scene: Scene, options?: ISoundTrackOptions);
  35187. private _initializeSoundTrackAudioGraph;
  35188. /**
  35189. * Release the sound track and its associated resources
  35190. */
  35191. dispose(): void;
  35192. /**
  35193. * Adds a sound to this sound track
  35194. * @param sound define the cound to add
  35195. * @ignoreNaming
  35196. */
  35197. AddSound(sound: Sound): void;
  35198. /**
  35199. * Removes a sound to this sound track
  35200. * @param sound define the cound to remove
  35201. * @ignoreNaming
  35202. */
  35203. RemoveSound(sound: Sound): void;
  35204. /**
  35205. * Set a global volume for the full sound track.
  35206. * @param newVolume Define the new volume of the sound track
  35207. */
  35208. setVolume(newVolume: number): void;
  35209. /**
  35210. * Switch the panning model to HRTF:
  35211. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35213. */
  35214. switchPanningModelToHRTF(): void;
  35215. /**
  35216. * Switch the panning model to Equal Power:
  35217. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35219. */
  35220. switchPanningModelToEqualPower(): void;
  35221. /**
  35222. * Connect the sound track to an audio analyser allowing some amazing
  35223. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35225. * @param analyser The analyser to connect to the engine
  35226. */
  35227. connectToAnalyser(analyser: Analyser): void;
  35228. }
  35229. }
  35230. declare module BABYLON {
  35231. interface AbstractScene {
  35232. /**
  35233. * The list of sounds used in the scene.
  35234. */
  35235. sounds: Nullable<Array<Sound>>;
  35236. }
  35237. interface Scene {
  35238. /**
  35239. * @hidden
  35240. * Backing field
  35241. */
  35242. _mainSoundTrack: SoundTrack;
  35243. /**
  35244. * The main sound track played by the scene.
  35245. * It cotains your primary collection of sounds.
  35246. */
  35247. mainSoundTrack: SoundTrack;
  35248. /**
  35249. * The list of sound tracks added to the scene
  35250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35251. */
  35252. soundTracks: Nullable<Array<SoundTrack>>;
  35253. /**
  35254. * Gets a sound using a given name
  35255. * @param name defines the name to search for
  35256. * @return the found sound or null if not found at all.
  35257. */
  35258. getSoundByName(name: string): Nullable<Sound>;
  35259. /**
  35260. * Gets or sets if audio support is enabled
  35261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35262. */
  35263. audioEnabled: boolean;
  35264. /**
  35265. * Gets or sets if audio will be output to headphones
  35266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35267. */
  35268. headphone: boolean;
  35269. /**
  35270. * Gets or sets custom audio listener position provider
  35271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35272. */
  35273. audioListenerPositionProvider: Nullable<() => Vector3>;
  35274. }
  35275. /**
  35276. * Defines the sound scene component responsible to manage any sounds
  35277. * in a given scene.
  35278. */
  35279. export class AudioSceneComponent implements ISceneSerializableComponent {
  35280. /**
  35281. * The component name helpfull to identify the component in the list of scene components.
  35282. */
  35283. readonly name: string;
  35284. /**
  35285. * The scene the component belongs to.
  35286. */
  35287. scene: Scene;
  35288. private _audioEnabled;
  35289. /**
  35290. * Gets whether audio is enabled or not.
  35291. * Please use related enable/disable method to switch state.
  35292. */
  35293. readonly audioEnabled: boolean;
  35294. private _headphone;
  35295. /**
  35296. * Gets whether audio is outputing to headphone or not.
  35297. * Please use the according Switch methods to change output.
  35298. */
  35299. readonly headphone: boolean;
  35300. private _audioListenerPositionProvider;
  35301. /**
  35302. * Gets the current audio listener position provider
  35303. */
  35304. /**
  35305. * Sets a custom listener position for all sounds in the scene
  35306. * By default, this is the position of the first active camera
  35307. */
  35308. audioListenerPositionProvider: Nullable<() => Vector3>;
  35309. /**
  35310. * Creates a new instance of the component for the given scene
  35311. * @param scene Defines the scene to register the component in
  35312. */
  35313. constructor(scene: Scene);
  35314. /**
  35315. * Registers the component in a given scene
  35316. */
  35317. register(): void;
  35318. /**
  35319. * Rebuilds the elements related to this component in case of
  35320. * context lost for instance.
  35321. */
  35322. rebuild(): void;
  35323. /**
  35324. * Serializes the component data to the specified json object
  35325. * @param serializationObject The object to serialize to
  35326. */
  35327. serialize(serializationObject: any): void;
  35328. /**
  35329. * Adds all the elements from the container to the scene
  35330. * @param container the container holding the elements
  35331. */
  35332. addFromContainer(container: AbstractScene): void;
  35333. /**
  35334. * Removes all the elements in the container from the scene
  35335. * @param container contains the elements to remove
  35336. * @param dispose if the removed element should be disposed (default: false)
  35337. */
  35338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35339. /**
  35340. * Disposes the component and the associated ressources.
  35341. */
  35342. dispose(): void;
  35343. /**
  35344. * Disables audio in the associated scene.
  35345. */
  35346. disableAudio(): void;
  35347. /**
  35348. * Enables audio in the associated scene.
  35349. */
  35350. enableAudio(): void;
  35351. /**
  35352. * Switch audio to headphone output.
  35353. */
  35354. switchAudioModeForHeadphones(): void;
  35355. /**
  35356. * Switch audio to normal speakers.
  35357. */
  35358. switchAudioModeForNormalSpeakers(): void;
  35359. private _afterRender;
  35360. }
  35361. }
  35362. declare module BABYLON {
  35363. /**
  35364. * Wraps one or more Sound objects and selects one with random weight for playback.
  35365. */
  35366. export class WeightedSound {
  35367. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35368. loop: boolean;
  35369. private _coneInnerAngle;
  35370. private _coneOuterAngle;
  35371. private _volume;
  35372. /** A Sound is currently playing. */
  35373. isPlaying: boolean;
  35374. /** A Sound is currently paused. */
  35375. isPaused: boolean;
  35376. private _sounds;
  35377. private _weights;
  35378. private _currentIndex?;
  35379. /**
  35380. * Creates a new WeightedSound from the list of sounds given.
  35381. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35382. * @param sounds Array of Sounds that will be selected from.
  35383. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35384. */
  35385. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35386. /**
  35387. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35388. */
  35389. /**
  35390. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35391. */
  35392. directionalConeInnerAngle: number;
  35393. /**
  35394. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35395. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35396. */
  35397. /**
  35398. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35399. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35400. */
  35401. directionalConeOuterAngle: number;
  35402. /**
  35403. * Playback volume.
  35404. */
  35405. /**
  35406. * Playback volume.
  35407. */
  35408. volume: number;
  35409. private _onended;
  35410. /**
  35411. * Suspend playback
  35412. */
  35413. pause(): void;
  35414. /**
  35415. * Stop playback
  35416. */
  35417. stop(): void;
  35418. /**
  35419. * Start playback.
  35420. * @param startOffset Position the clip head at a specific time in seconds.
  35421. */
  35422. play(startOffset?: number): void;
  35423. }
  35424. }
  35425. declare module BABYLON {
  35426. /**
  35427. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35429. */
  35430. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35431. /**
  35432. * Gets the name of the behavior.
  35433. */
  35434. readonly name: string;
  35435. /**
  35436. * The easing function used by animations
  35437. */
  35438. static EasingFunction: BackEase;
  35439. /**
  35440. * The easing mode used by animations
  35441. */
  35442. static EasingMode: number;
  35443. /**
  35444. * The duration of the animation, in milliseconds
  35445. */
  35446. transitionDuration: number;
  35447. /**
  35448. * Length of the distance animated by the transition when lower radius is reached
  35449. */
  35450. lowerRadiusTransitionRange: number;
  35451. /**
  35452. * Length of the distance animated by the transition when upper radius is reached
  35453. */
  35454. upperRadiusTransitionRange: number;
  35455. private _autoTransitionRange;
  35456. /**
  35457. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35458. */
  35459. /**
  35460. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35461. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35462. */
  35463. autoTransitionRange: boolean;
  35464. private _attachedCamera;
  35465. private _onAfterCheckInputsObserver;
  35466. private _onMeshTargetChangedObserver;
  35467. /**
  35468. * Initializes the behavior.
  35469. */
  35470. init(): void;
  35471. /**
  35472. * Attaches the behavior to its arc rotate camera.
  35473. * @param camera Defines the camera to attach the behavior to
  35474. */
  35475. attach(camera: ArcRotateCamera): void;
  35476. /**
  35477. * Detaches the behavior from its current arc rotate camera.
  35478. */
  35479. detach(): void;
  35480. private _radiusIsAnimating;
  35481. private _radiusBounceTransition;
  35482. private _animatables;
  35483. private _cachedWheelPrecision;
  35484. /**
  35485. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35486. * @param radiusLimit The limit to check against.
  35487. * @return Bool to indicate if at limit.
  35488. */
  35489. private _isRadiusAtLimit;
  35490. /**
  35491. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35492. * @param radiusDelta The delta by which to animate to. Can be negative.
  35493. */
  35494. private _applyBoundRadiusAnimation;
  35495. /**
  35496. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35497. */
  35498. protected _clearAnimationLocks(): void;
  35499. /**
  35500. * Stops and removes all animations that have been applied to the camera
  35501. */
  35502. stopAllAnimations(): void;
  35503. }
  35504. }
  35505. declare module BABYLON {
  35506. /**
  35507. * 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.
  35508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35509. */
  35510. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35511. /**
  35512. * Gets the name of the behavior.
  35513. */
  35514. readonly name: string;
  35515. private _mode;
  35516. private _radiusScale;
  35517. private _positionScale;
  35518. private _defaultElevation;
  35519. private _elevationReturnTime;
  35520. private _elevationReturnWaitTime;
  35521. private _zoomStopsAnimation;
  35522. private _framingTime;
  35523. /**
  35524. * The easing function used by animations
  35525. */
  35526. static EasingFunction: ExponentialEase;
  35527. /**
  35528. * The easing mode used by animations
  35529. */
  35530. static EasingMode: number;
  35531. /**
  35532. * Sets the current mode used by the behavior
  35533. */
  35534. /**
  35535. * Gets current mode used by the behavior.
  35536. */
  35537. mode: number;
  35538. /**
  35539. * Sets the scale applied to the radius (1 by default)
  35540. */
  35541. /**
  35542. * Gets the scale applied to the radius
  35543. */
  35544. radiusScale: number;
  35545. /**
  35546. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35547. */
  35548. /**
  35549. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35550. */
  35551. positionScale: number;
  35552. /**
  35553. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35554. * behaviour is triggered, in radians.
  35555. */
  35556. /**
  35557. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35558. * behaviour is triggered, in radians.
  35559. */
  35560. defaultElevation: number;
  35561. /**
  35562. * Sets the time (in milliseconds) taken to return to the default beta position.
  35563. * Negative value indicates camera should not return to default.
  35564. */
  35565. /**
  35566. * Gets the time (in milliseconds) taken to return to the default beta position.
  35567. * Negative value indicates camera should not return to default.
  35568. */
  35569. elevationReturnTime: number;
  35570. /**
  35571. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35572. */
  35573. /**
  35574. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35575. */
  35576. elevationReturnWaitTime: number;
  35577. /**
  35578. * Sets the flag that indicates if user zooming should stop animation.
  35579. */
  35580. /**
  35581. * Gets the flag that indicates if user zooming should stop animation.
  35582. */
  35583. zoomStopsAnimation: boolean;
  35584. /**
  35585. * Sets the transition time when framing the mesh, in milliseconds
  35586. */
  35587. /**
  35588. * Gets the transition time when framing the mesh, in milliseconds
  35589. */
  35590. framingTime: number;
  35591. /**
  35592. * Define if the behavior should automatically change the configured
  35593. * camera limits and sensibilities.
  35594. */
  35595. autoCorrectCameraLimitsAndSensibility: boolean;
  35596. private _onPrePointerObservableObserver;
  35597. private _onAfterCheckInputsObserver;
  35598. private _onMeshTargetChangedObserver;
  35599. private _attachedCamera;
  35600. private _isPointerDown;
  35601. private _lastInteractionTime;
  35602. /**
  35603. * Initializes the behavior.
  35604. */
  35605. init(): void;
  35606. /**
  35607. * Attaches the behavior to its arc rotate camera.
  35608. * @param camera Defines the camera to attach the behavior to
  35609. */
  35610. attach(camera: ArcRotateCamera): void;
  35611. /**
  35612. * Detaches the behavior from its current arc rotate camera.
  35613. */
  35614. detach(): void;
  35615. private _animatables;
  35616. private _betaIsAnimating;
  35617. private _betaTransition;
  35618. private _radiusTransition;
  35619. private _vectorTransition;
  35620. /**
  35621. * Targets the given mesh and updates zoom level accordingly.
  35622. * @param mesh The mesh to target.
  35623. * @param radius Optional. If a cached radius position already exists, overrides default.
  35624. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35627. */
  35628. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35629. /**
  35630. * Targets the given mesh with its children and updates zoom level accordingly.
  35631. * @param mesh The mesh to target.
  35632. * @param radius Optional. If a cached radius position already exists, overrides default.
  35633. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35636. */
  35637. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35638. /**
  35639. * Targets the given meshes with their children and updates zoom level accordingly.
  35640. * @param meshes The mesh to target.
  35641. * @param radius Optional. If a cached radius position already exists, overrides default.
  35642. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35643. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35644. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35645. */
  35646. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35647. /**
  35648. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35649. * @param minimumWorld Determines the smaller position of the bounding box extend
  35650. * @param maximumWorld Determines the bigger position of the bounding box extend
  35651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35653. */
  35654. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35655. /**
  35656. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35657. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35658. * frustum width.
  35659. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35660. * to fully enclose the mesh in the viewing frustum.
  35661. */
  35662. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35663. /**
  35664. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35665. * is automatically returned to its default position (expected to be above ground plane).
  35666. */
  35667. private _maintainCameraAboveGround;
  35668. /**
  35669. * Returns the frustum slope based on the canvas ratio and camera FOV
  35670. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35671. */
  35672. private _getFrustumSlope;
  35673. /**
  35674. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35675. */
  35676. private _clearAnimationLocks;
  35677. /**
  35678. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35679. */
  35680. private _applyUserInteraction;
  35681. /**
  35682. * Stops and removes all animations that have been applied to the camera
  35683. */
  35684. stopAllAnimations(): void;
  35685. /**
  35686. * Gets a value indicating if the user is moving the camera
  35687. */
  35688. readonly isUserIsMoving: boolean;
  35689. /**
  35690. * The camera can move all the way towards the mesh.
  35691. */
  35692. static IgnoreBoundsSizeMode: number;
  35693. /**
  35694. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35695. */
  35696. static FitFrustumSidesMode: number;
  35697. }
  35698. }
  35699. declare module BABYLON {
  35700. /**
  35701. * Base class for Camera Pointer Inputs.
  35702. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35703. * for example usage.
  35704. */
  35705. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35706. /**
  35707. * Defines the camera the input is attached to.
  35708. */
  35709. abstract camera: Camera;
  35710. /**
  35711. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35712. */
  35713. protected _altKey: boolean;
  35714. protected _ctrlKey: boolean;
  35715. protected _metaKey: boolean;
  35716. protected _shiftKey: boolean;
  35717. /**
  35718. * Which mouse buttons were pressed at time of last mouse event.
  35719. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35720. */
  35721. protected _buttonsPressed: number;
  35722. /**
  35723. * Defines the buttons associated with the input to handle camera move.
  35724. */
  35725. buttons: number[];
  35726. /**
  35727. * Attach the input controls to a specific dom element to get the input from.
  35728. * @param element Defines the element the controls should be listened from
  35729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35730. */
  35731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35732. /**
  35733. * Detach the current controls from the specified dom element.
  35734. * @param element Defines the element to stop listening the inputs from
  35735. */
  35736. detachControl(element: Nullable<HTMLElement>): void;
  35737. /**
  35738. * Gets the class name of the current input.
  35739. * @returns the class name
  35740. */
  35741. getClassName(): string;
  35742. /**
  35743. * Get the friendly name associated with the input class.
  35744. * @returns the input friendly name
  35745. */
  35746. getSimpleName(): string;
  35747. /**
  35748. * Called on pointer POINTERDOUBLETAP event.
  35749. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35750. */
  35751. protected onDoubleTap(type: string): void;
  35752. /**
  35753. * Called on pointer POINTERMOVE event if only a single touch is active.
  35754. * Override this method to provide functionality.
  35755. */
  35756. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35757. /**
  35758. * Called on pointer POINTERMOVE event if multiple touches are active.
  35759. * Override this method to provide functionality.
  35760. */
  35761. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35762. /**
  35763. * Called on JS contextmenu event.
  35764. * Override this method to provide functionality.
  35765. */
  35766. protected onContextMenu(evt: PointerEvent): void;
  35767. /**
  35768. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35769. * press.
  35770. * Override this method to provide functionality.
  35771. */
  35772. protected onButtonDown(evt: PointerEvent): void;
  35773. /**
  35774. * Called each time a new POINTERUP event occurs. Ie, for each button
  35775. * release.
  35776. * Override this method to provide functionality.
  35777. */
  35778. protected onButtonUp(evt: PointerEvent): void;
  35779. /**
  35780. * Called when window becomes inactive.
  35781. * Override this method to provide functionality.
  35782. */
  35783. protected onLostFocus(): void;
  35784. private _pointerInput;
  35785. private _observer;
  35786. private _onLostFocus;
  35787. private pointA;
  35788. private pointB;
  35789. }
  35790. }
  35791. declare module BABYLON {
  35792. /**
  35793. * Manage the pointers inputs to control an arc rotate camera.
  35794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35795. */
  35796. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35797. /**
  35798. * Defines the camera the input is attached to.
  35799. */
  35800. camera: ArcRotateCamera;
  35801. /**
  35802. * Gets the class name of the current input.
  35803. * @returns the class name
  35804. */
  35805. getClassName(): string;
  35806. /**
  35807. * Defines the buttons associated with the input to handle camera move.
  35808. */
  35809. buttons: number[];
  35810. /**
  35811. * Defines the pointer angular sensibility along the X axis or how fast is
  35812. * the camera rotating.
  35813. */
  35814. angularSensibilityX: number;
  35815. /**
  35816. * Defines the pointer angular sensibility along the Y axis or how fast is
  35817. * the camera rotating.
  35818. */
  35819. angularSensibilityY: number;
  35820. /**
  35821. * Defines the pointer pinch precision or how fast is the camera zooming.
  35822. */
  35823. pinchPrecision: number;
  35824. /**
  35825. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35826. * from 0.
  35827. * It defines the percentage of current camera.radius to use as delta when
  35828. * pinch zoom is used.
  35829. */
  35830. pinchDeltaPercentage: number;
  35831. /**
  35832. * Defines the pointer panning sensibility or how fast is the camera moving.
  35833. */
  35834. panningSensibility: number;
  35835. /**
  35836. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35837. */
  35838. multiTouchPanning: boolean;
  35839. /**
  35840. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35841. * zoom (pinch) through multitouch.
  35842. */
  35843. multiTouchPanAndZoom: boolean;
  35844. /**
  35845. * Revers pinch action direction.
  35846. */
  35847. pinchInwards: boolean;
  35848. private _isPanClick;
  35849. private _twoFingerActivityCount;
  35850. private _isPinching;
  35851. /**
  35852. * Called on pointer POINTERMOVE event if only a single touch is active.
  35853. */
  35854. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35855. /**
  35856. * Called on pointer POINTERDOUBLETAP event.
  35857. */
  35858. protected onDoubleTap(type: string): void;
  35859. /**
  35860. * Called on pointer POINTERMOVE event if multiple touches are active.
  35861. */
  35862. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35863. /**
  35864. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35865. * press.
  35866. */
  35867. protected onButtonDown(evt: PointerEvent): void;
  35868. /**
  35869. * Called each time a new POINTERUP event occurs. Ie, for each button
  35870. * release.
  35871. */
  35872. protected onButtonUp(evt: PointerEvent): void;
  35873. /**
  35874. * Called when window becomes inactive.
  35875. */
  35876. protected onLostFocus(): void;
  35877. }
  35878. }
  35879. declare module BABYLON {
  35880. /**
  35881. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35883. */
  35884. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35885. /**
  35886. * Defines the camera the input is attached to.
  35887. */
  35888. camera: ArcRotateCamera;
  35889. /**
  35890. * Defines the list of key codes associated with the up action (increase alpha)
  35891. */
  35892. keysUp: number[];
  35893. /**
  35894. * Defines the list of key codes associated with the down action (decrease alpha)
  35895. */
  35896. keysDown: number[];
  35897. /**
  35898. * Defines the list of key codes associated with the left action (increase beta)
  35899. */
  35900. keysLeft: number[];
  35901. /**
  35902. * Defines the list of key codes associated with the right action (decrease beta)
  35903. */
  35904. keysRight: number[];
  35905. /**
  35906. * Defines the list of key codes associated with the reset action.
  35907. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35908. */
  35909. keysReset: number[];
  35910. /**
  35911. * Defines the panning sensibility of the inputs.
  35912. * (How fast is the camera paning)
  35913. */
  35914. panningSensibility: number;
  35915. /**
  35916. * Defines the zooming sensibility of the inputs.
  35917. * (How fast is the camera zooming)
  35918. */
  35919. zoomingSensibility: number;
  35920. /**
  35921. * Defines wether maintaining the alt key down switch the movement mode from
  35922. * orientation to zoom.
  35923. */
  35924. useAltToZoom: boolean;
  35925. /**
  35926. * Rotation speed of the camera
  35927. */
  35928. angularSpeed: number;
  35929. private _keys;
  35930. private _ctrlPressed;
  35931. private _altPressed;
  35932. private _onCanvasBlurObserver;
  35933. private _onKeyboardObserver;
  35934. private _engine;
  35935. private _scene;
  35936. /**
  35937. * Attach the input controls to a specific dom element to get the input from.
  35938. * @param element Defines the element the controls should be listened from
  35939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35940. */
  35941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35942. /**
  35943. * Detach the current controls from the specified dom element.
  35944. * @param element Defines the element to stop listening the inputs from
  35945. */
  35946. detachControl(element: Nullable<HTMLElement>): void;
  35947. /**
  35948. * Update the current camera state depending on the inputs that have been used this frame.
  35949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35950. */
  35951. checkInputs(): void;
  35952. /**
  35953. * Gets the class name of the current intput.
  35954. * @returns the class name
  35955. */
  35956. getClassName(): string;
  35957. /**
  35958. * Get the friendly name associated with the input class.
  35959. * @returns the input friendly name
  35960. */
  35961. getSimpleName(): string;
  35962. }
  35963. }
  35964. declare module BABYLON {
  35965. /**
  35966. * Manage the mouse wheel inputs to control an arc rotate camera.
  35967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35968. */
  35969. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35970. /**
  35971. * Defines the camera the input is attached to.
  35972. */
  35973. camera: ArcRotateCamera;
  35974. /**
  35975. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35976. */
  35977. wheelPrecision: number;
  35978. /**
  35979. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35980. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35981. */
  35982. wheelDeltaPercentage: number;
  35983. private _wheel;
  35984. private _observer;
  35985. private computeDeltaFromMouseWheelLegacyEvent;
  35986. /**
  35987. * Attach the input controls to a specific dom element to get the input from.
  35988. * @param element Defines the element the controls should be listened from
  35989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35990. */
  35991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35992. /**
  35993. * Detach the current controls from the specified dom element.
  35994. * @param element Defines the element to stop listening the inputs from
  35995. */
  35996. detachControl(element: Nullable<HTMLElement>): void;
  35997. /**
  35998. * Gets the class name of the current intput.
  35999. * @returns the class name
  36000. */
  36001. getClassName(): string;
  36002. /**
  36003. * Get the friendly name associated with the input class.
  36004. * @returns the input friendly name
  36005. */
  36006. getSimpleName(): string;
  36007. }
  36008. }
  36009. declare module BABYLON {
  36010. /**
  36011. * Default Inputs manager for the ArcRotateCamera.
  36012. * It groups all the default supported inputs for ease of use.
  36013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36014. */
  36015. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36016. /**
  36017. * Instantiates a new ArcRotateCameraInputsManager.
  36018. * @param camera Defines the camera the inputs belong to
  36019. */
  36020. constructor(camera: ArcRotateCamera);
  36021. /**
  36022. * Add mouse wheel input support to the input manager.
  36023. * @returns the current input manager
  36024. */
  36025. addMouseWheel(): ArcRotateCameraInputsManager;
  36026. /**
  36027. * Add pointers input support to the input manager.
  36028. * @returns the current input manager
  36029. */
  36030. addPointers(): ArcRotateCameraInputsManager;
  36031. /**
  36032. * Add keyboard input support to the input manager.
  36033. * @returns the current input manager
  36034. */
  36035. addKeyboard(): ArcRotateCameraInputsManager;
  36036. }
  36037. }
  36038. declare module BABYLON {
  36039. /**
  36040. * This represents an orbital type of camera.
  36041. *
  36042. * 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.
  36043. * 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.
  36044. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36045. */
  36046. export class ArcRotateCamera extends TargetCamera {
  36047. /**
  36048. * Defines the rotation angle of the camera along the longitudinal axis.
  36049. */
  36050. alpha: number;
  36051. /**
  36052. * Defines the rotation angle of the camera along the latitudinal axis.
  36053. */
  36054. beta: number;
  36055. /**
  36056. * Defines the radius of the camera from it s target point.
  36057. */
  36058. radius: number;
  36059. protected _target: Vector3;
  36060. protected _targetHost: Nullable<AbstractMesh>;
  36061. /**
  36062. * Defines the target point of the camera.
  36063. * The camera looks towards it form the radius distance.
  36064. */
  36065. target: Vector3;
  36066. /**
  36067. * Define the current local position of the camera in the scene
  36068. */
  36069. position: Vector3;
  36070. protected _upVector: Vector3;
  36071. protected _upToYMatrix: Matrix;
  36072. protected _YToUpMatrix: Matrix;
  36073. /**
  36074. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36075. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36076. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36077. */
  36078. upVector: Vector3;
  36079. /**
  36080. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36081. */
  36082. setMatUp(): void;
  36083. /**
  36084. * Current inertia value on the longitudinal axis.
  36085. * The bigger this number the longer it will take for the camera to stop.
  36086. */
  36087. inertialAlphaOffset: number;
  36088. /**
  36089. * Current inertia value on the latitudinal axis.
  36090. * The bigger this number the longer it will take for the camera to stop.
  36091. */
  36092. inertialBetaOffset: number;
  36093. /**
  36094. * Current inertia value on the radius axis.
  36095. * The bigger this number the longer it will take for the camera to stop.
  36096. */
  36097. inertialRadiusOffset: number;
  36098. /**
  36099. * Minimum allowed angle on the longitudinal axis.
  36100. * This can help limiting how the Camera is able to move in the scene.
  36101. */
  36102. lowerAlphaLimit: Nullable<number>;
  36103. /**
  36104. * Maximum allowed angle on the longitudinal axis.
  36105. * This can help limiting how the Camera is able to move in the scene.
  36106. */
  36107. upperAlphaLimit: Nullable<number>;
  36108. /**
  36109. * Minimum allowed angle on the latitudinal axis.
  36110. * This can help limiting how the Camera is able to move in the scene.
  36111. */
  36112. lowerBetaLimit: number;
  36113. /**
  36114. * Maximum allowed angle on the latitudinal axis.
  36115. * This can help limiting how the Camera is able to move in the scene.
  36116. */
  36117. upperBetaLimit: number;
  36118. /**
  36119. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36120. * This can help limiting how the Camera is able to move in the scene.
  36121. */
  36122. lowerRadiusLimit: Nullable<number>;
  36123. /**
  36124. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36125. * This can help limiting how the Camera is able to move in the scene.
  36126. */
  36127. upperRadiusLimit: Nullable<number>;
  36128. /**
  36129. * Defines the current inertia value used during panning of the camera along the X axis.
  36130. */
  36131. inertialPanningX: number;
  36132. /**
  36133. * Defines the current inertia value used during panning of the camera along the Y axis.
  36134. */
  36135. inertialPanningY: number;
  36136. /**
  36137. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36138. * Basically if your fingers moves away from more than this distance you will be considered
  36139. * in pinch mode.
  36140. */
  36141. pinchToPanMaxDistance: number;
  36142. /**
  36143. * Defines the maximum distance the camera can pan.
  36144. * This could help keeping the cammera always in your scene.
  36145. */
  36146. panningDistanceLimit: Nullable<number>;
  36147. /**
  36148. * Defines the target of the camera before paning.
  36149. */
  36150. panningOriginTarget: Vector3;
  36151. /**
  36152. * Defines the value of the inertia used during panning.
  36153. * 0 would mean stop inertia and one would mean no decelleration at all.
  36154. */
  36155. panningInertia: number;
  36156. /**
  36157. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36158. */
  36159. angularSensibilityX: number;
  36160. /**
  36161. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36162. */
  36163. angularSensibilityY: number;
  36164. /**
  36165. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36166. */
  36167. pinchPrecision: number;
  36168. /**
  36169. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36170. * It will be used instead of pinchDeltaPrecision if different from 0.
  36171. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36172. */
  36173. pinchDeltaPercentage: number;
  36174. /**
  36175. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36176. */
  36177. panningSensibility: number;
  36178. /**
  36179. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36180. */
  36181. keysUp: number[];
  36182. /**
  36183. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36184. */
  36185. keysDown: number[];
  36186. /**
  36187. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36188. */
  36189. keysLeft: number[];
  36190. /**
  36191. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36192. */
  36193. keysRight: number[];
  36194. /**
  36195. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36196. */
  36197. wheelPrecision: number;
  36198. /**
  36199. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36200. * It will be used instead of pinchDeltaPrecision if different from 0.
  36201. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36202. */
  36203. wheelDeltaPercentage: number;
  36204. /**
  36205. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36206. */
  36207. zoomOnFactor: number;
  36208. /**
  36209. * Defines a screen offset for the camera position.
  36210. */
  36211. targetScreenOffset: Vector2;
  36212. /**
  36213. * Allows the camera to be completely reversed.
  36214. * If false the camera can not arrive upside down.
  36215. */
  36216. allowUpsideDown: boolean;
  36217. /**
  36218. * Define if double tap/click is used to restore the previously saved state of the camera.
  36219. */
  36220. useInputToRestoreState: boolean;
  36221. /** @hidden */
  36222. _viewMatrix: Matrix;
  36223. /** @hidden */
  36224. _useCtrlForPanning: boolean;
  36225. /** @hidden */
  36226. _panningMouseButton: number;
  36227. /**
  36228. * Defines the input associated to the camera.
  36229. */
  36230. inputs: ArcRotateCameraInputsManager;
  36231. /** @hidden */
  36232. _reset: () => void;
  36233. /**
  36234. * Defines the allowed panning axis.
  36235. */
  36236. panningAxis: Vector3;
  36237. protected _localDirection: Vector3;
  36238. protected _transformedDirection: Vector3;
  36239. private _bouncingBehavior;
  36240. /**
  36241. * Gets the bouncing behavior of the camera if it has been enabled.
  36242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36243. */
  36244. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36245. /**
  36246. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36247. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36248. */
  36249. useBouncingBehavior: boolean;
  36250. private _framingBehavior;
  36251. /**
  36252. * Gets the framing behavior of the camera if it has been enabled.
  36253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36254. */
  36255. readonly framingBehavior: Nullable<FramingBehavior>;
  36256. /**
  36257. * Defines if the framing behavior of the camera is enabled on the camera.
  36258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36259. */
  36260. useFramingBehavior: boolean;
  36261. private _autoRotationBehavior;
  36262. /**
  36263. * Gets the auto rotation behavior of the camera if it has been enabled.
  36264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36265. */
  36266. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36267. /**
  36268. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36269. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36270. */
  36271. useAutoRotationBehavior: boolean;
  36272. /**
  36273. * Observable triggered when the mesh target has been changed on the camera.
  36274. */
  36275. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36276. /**
  36277. * Event raised when the camera is colliding with a mesh.
  36278. */
  36279. onCollide: (collidedMesh: AbstractMesh) => void;
  36280. /**
  36281. * Defines whether the camera should check collision with the objects oh the scene.
  36282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36283. */
  36284. checkCollisions: boolean;
  36285. /**
  36286. * Defines the collision radius of the camera.
  36287. * This simulates a sphere around the camera.
  36288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36289. */
  36290. collisionRadius: Vector3;
  36291. protected _collider: Collider;
  36292. protected _previousPosition: Vector3;
  36293. protected _collisionVelocity: Vector3;
  36294. protected _newPosition: Vector3;
  36295. protected _previousAlpha: number;
  36296. protected _previousBeta: number;
  36297. protected _previousRadius: number;
  36298. protected _collisionTriggered: boolean;
  36299. protected _targetBoundingCenter: Nullable<Vector3>;
  36300. private _computationVector;
  36301. /**
  36302. * Instantiates a new ArcRotateCamera in a given scene
  36303. * @param name Defines the name of the camera
  36304. * @param alpha Defines the camera rotation along the logitudinal axis
  36305. * @param beta Defines the camera rotation along the latitudinal axis
  36306. * @param radius Defines the camera distance from its target
  36307. * @param target Defines the camera target
  36308. * @param scene Defines the scene the camera belongs to
  36309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36310. */
  36311. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36312. /** @hidden */
  36313. _initCache(): void;
  36314. /** @hidden */
  36315. _updateCache(ignoreParentClass?: boolean): void;
  36316. protected _getTargetPosition(): Vector3;
  36317. private _storedAlpha;
  36318. private _storedBeta;
  36319. private _storedRadius;
  36320. private _storedTarget;
  36321. private _storedTargetScreenOffset;
  36322. /**
  36323. * Stores the current state of the camera (alpha, beta, radius and target)
  36324. * @returns the camera itself
  36325. */
  36326. storeState(): Camera;
  36327. /**
  36328. * @hidden
  36329. * Restored camera state. You must call storeState() first
  36330. */
  36331. _restoreStateValues(): boolean;
  36332. /** @hidden */
  36333. _isSynchronizedViewMatrix(): boolean;
  36334. /**
  36335. * Attached controls to the current camera.
  36336. * @param element Defines the element the controls should be listened from
  36337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36338. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36339. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36340. */
  36341. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36342. /**
  36343. * Detach the current controls from the camera.
  36344. * The camera will stop reacting to inputs.
  36345. * @param element Defines the element to stop listening the inputs from
  36346. */
  36347. detachControl(element: HTMLElement): void;
  36348. /** @hidden */
  36349. _checkInputs(): void;
  36350. protected _checkLimits(): void;
  36351. /**
  36352. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36353. */
  36354. rebuildAnglesAndRadius(): void;
  36355. /**
  36356. * Use a position to define the current camera related information like aplha, beta and radius
  36357. * @param position Defines the position to set the camera at
  36358. */
  36359. setPosition(position: Vector3): void;
  36360. /**
  36361. * Defines the target the camera should look at.
  36362. * This will automatically adapt alpha beta and radius to fit within the new target.
  36363. * @param target Defines the new target as a Vector or a mesh
  36364. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36365. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36366. */
  36367. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36368. /** @hidden */
  36369. _getViewMatrix(): Matrix;
  36370. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36371. /**
  36372. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36373. * @param meshes Defines the mesh to zoom on
  36374. * @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)
  36375. */
  36376. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36377. /**
  36378. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36379. * The target will be changed but the radius
  36380. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36381. * @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)
  36382. */
  36383. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36384. min: Vector3;
  36385. max: Vector3;
  36386. distance: number;
  36387. }, doNotUpdateMaxZ?: boolean): void;
  36388. /**
  36389. * @override
  36390. * Override Camera.createRigCamera
  36391. */
  36392. createRigCamera(name: string, cameraIndex: number): Camera;
  36393. /**
  36394. * @hidden
  36395. * @override
  36396. * Override Camera._updateRigCameras
  36397. */
  36398. _updateRigCameras(): void;
  36399. /**
  36400. * Destroy the camera and release the current resources hold by it.
  36401. */
  36402. dispose(): void;
  36403. /**
  36404. * Gets the current object class name.
  36405. * @return the class name
  36406. */
  36407. getClassName(): string;
  36408. }
  36409. }
  36410. declare module BABYLON {
  36411. /**
  36412. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36414. */
  36415. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36416. /**
  36417. * Gets the name of the behavior.
  36418. */
  36419. readonly name: string;
  36420. private _zoomStopsAnimation;
  36421. private _idleRotationSpeed;
  36422. private _idleRotationWaitTime;
  36423. private _idleRotationSpinupTime;
  36424. /**
  36425. * Sets the flag that indicates if user zooming should stop animation.
  36426. */
  36427. /**
  36428. * Gets the flag that indicates if user zooming should stop animation.
  36429. */
  36430. zoomStopsAnimation: boolean;
  36431. /**
  36432. * Sets the default speed at which the camera rotates around the model.
  36433. */
  36434. /**
  36435. * Gets the default speed at which the camera rotates around the model.
  36436. */
  36437. idleRotationSpeed: number;
  36438. /**
  36439. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36440. */
  36441. /**
  36442. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36443. */
  36444. idleRotationWaitTime: number;
  36445. /**
  36446. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36447. */
  36448. /**
  36449. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36450. */
  36451. idleRotationSpinupTime: number;
  36452. /**
  36453. * Gets a value indicating if the camera is currently rotating because of this behavior
  36454. */
  36455. readonly rotationInProgress: boolean;
  36456. private _onPrePointerObservableObserver;
  36457. private _onAfterCheckInputsObserver;
  36458. private _attachedCamera;
  36459. private _isPointerDown;
  36460. private _lastFrameTime;
  36461. private _lastInteractionTime;
  36462. private _cameraRotationSpeed;
  36463. /**
  36464. * Initializes the behavior.
  36465. */
  36466. init(): void;
  36467. /**
  36468. * Attaches the behavior to its arc rotate camera.
  36469. * @param camera Defines the camera to attach the behavior to
  36470. */
  36471. attach(camera: ArcRotateCamera): void;
  36472. /**
  36473. * Detaches the behavior from its current arc rotate camera.
  36474. */
  36475. detach(): void;
  36476. /**
  36477. * Returns true if user is scrolling.
  36478. * @return true if user is scrolling.
  36479. */
  36480. private _userIsZooming;
  36481. private _lastFrameRadius;
  36482. private _shouldAnimationStopForInteraction;
  36483. /**
  36484. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36485. */
  36486. private _applyUserInteraction;
  36487. private _userIsMoving;
  36488. }
  36489. }
  36490. declare module BABYLON {
  36491. /**
  36492. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36493. */
  36494. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36495. private ui;
  36496. /**
  36497. * The name of the behavior
  36498. */
  36499. name: string;
  36500. /**
  36501. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36502. */
  36503. distanceAwayFromFace: number;
  36504. /**
  36505. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36506. */
  36507. distanceAwayFromBottomOfFace: number;
  36508. private _faceVectors;
  36509. private _target;
  36510. private _scene;
  36511. private _onRenderObserver;
  36512. private _tmpMatrix;
  36513. private _tmpVector;
  36514. /**
  36515. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36516. * @param ui The transform node that should be attched to the mesh
  36517. */
  36518. constructor(ui: TransformNode);
  36519. /**
  36520. * Initializes the behavior
  36521. */
  36522. init(): void;
  36523. private _closestFace;
  36524. private _zeroVector;
  36525. private _lookAtTmpMatrix;
  36526. private _lookAtToRef;
  36527. /**
  36528. * Attaches the AttachToBoxBehavior to the passed in mesh
  36529. * @param target The mesh that the specified node will be attached to
  36530. */
  36531. attach(target: Mesh): void;
  36532. /**
  36533. * Detaches the behavior from the mesh
  36534. */
  36535. detach(): void;
  36536. }
  36537. }
  36538. declare module BABYLON {
  36539. /**
  36540. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36541. */
  36542. export class FadeInOutBehavior implements Behavior<Mesh> {
  36543. /**
  36544. * Time in milliseconds to delay before fading in (Default: 0)
  36545. */
  36546. delay: number;
  36547. /**
  36548. * Time in milliseconds for the mesh to fade in (Default: 300)
  36549. */
  36550. fadeInTime: number;
  36551. private _millisecondsPerFrame;
  36552. private _hovered;
  36553. private _hoverValue;
  36554. private _ownerNode;
  36555. /**
  36556. * Instatiates the FadeInOutBehavior
  36557. */
  36558. constructor();
  36559. /**
  36560. * The name of the behavior
  36561. */
  36562. readonly name: string;
  36563. /**
  36564. * Initializes the behavior
  36565. */
  36566. init(): void;
  36567. /**
  36568. * Attaches the fade behavior on the passed in mesh
  36569. * @param ownerNode The mesh that will be faded in/out once attached
  36570. */
  36571. attach(ownerNode: Mesh): void;
  36572. /**
  36573. * Detaches the behavior from the mesh
  36574. */
  36575. detach(): void;
  36576. /**
  36577. * Triggers the mesh to begin fading in or out
  36578. * @param value if the object should fade in or out (true to fade in)
  36579. */
  36580. fadeIn(value: boolean): void;
  36581. private _update;
  36582. private _setAllVisibility;
  36583. }
  36584. }
  36585. declare module BABYLON {
  36586. /**
  36587. * Class containing a set of static utilities functions for managing Pivots
  36588. * @hidden
  36589. */
  36590. export class PivotTools {
  36591. private static _PivotCached;
  36592. private static _OldPivotPoint;
  36593. private static _PivotTranslation;
  36594. private static _PivotTmpVector;
  36595. /** @hidden */
  36596. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36597. /** @hidden */
  36598. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36599. }
  36600. }
  36601. declare module BABYLON {
  36602. /**
  36603. * Class containing static functions to help procedurally build meshes
  36604. */
  36605. export class PlaneBuilder {
  36606. /**
  36607. * Creates a plane mesh
  36608. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36609. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36610. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36612. * * 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
  36613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36614. * @param name defines the name of the mesh
  36615. * @param options defines the options used to create the mesh
  36616. * @param scene defines the hosting scene
  36617. * @returns the plane mesh
  36618. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36619. */
  36620. static CreatePlane(name: string, options: {
  36621. size?: number;
  36622. width?: number;
  36623. height?: number;
  36624. sideOrientation?: number;
  36625. frontUVs?: Vector4;
  36626. backUVs?: Vector4;
  36627. updatable?: boolean;
  36628. sourcePlane?: Plane;
  36629. }, scene?: Nullable<Scene>): Mesh;
  36630. }
  36631. }
  36632. declare module BABYLON {
  36633. /**
  36634. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36635. */
  36636. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36637. private static _AnyMouseID;
  36638. /**
  36639. * Abstract mesh the behavior is set on
  36640. */
  36641. attachedNode: AbstractMesh;
  36642. private _dragPlane;
  36643. private _scene;
  36644. private _pointerObserver;
  36645. private _beforeRenderObserver;
  36646. private static _planeScene;
  36647. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36648. /**
  36649. * 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)
  36650. */
  36651. maxDragAngle: number;
  36652. /**
  36653. * @hidden
  36654. */
  36655. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36656. /**
  36657. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36658. */
  36659. currentDraggingPointerID: number;
  36660. /**
  36661. * The last position where the pointer hit the drag plane in world space
  36662. */
  36663. lastDragPosition: Vector3;
  36664. /**
  36665. * If the behavior is currently in a dragging state
  36666. */
  36667. dragging: boolean;
  36668. /**
  36669. * 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)
  36670. */
  36671. dragDeltaRatio: number;
  36672. /**
  36673. * If the drag plane orientation should be updated during the dragging (Default: true)
  36674. */
  36675. updateDragPlane: boolean;
  36676. private _debugMode;
  36677. private _moving;
  36678. /**
  36679. * Fires each time the attached mesh is dragged with the pointer
  36680. * * delta between last drag position and current drag position in world space
  36681. * * dragDistance along the drag axis
  36682. * * dragPlaneNormal normal of the current drag plane used during the drag
  36683. * * dragPlanePoint in world space where the drag intersects the drag plane
  36684. */
  36685. onDragObservable: Observable<{
  36686. delta: Vector3;
  36687. dragPlanePoint: Vector3;
  36688. dragPlaneNormal: Vector3;
  36689. dragDistance: number;
  36690. pointerId: number;
  36691. }>;
  36692. /**
  36693. * Fires each time a drag begins (eg. mouse down on mesh)
  36694. */
  36695. onDragStartObservable: Observable<{
  36696. dragPlanePoint: Vector3;
  36697. pointerId: number;
  36698. }>;
  36699. /**
  36700. * Fires each time a drag ends (eg. mouse release after drag)
  36701. */
  36702. onDragEndObservable: Observable<{
  36703. dragPlanePoint: Vector3;
  36704. pointerId: number;
  36705. }>;
  36706. /**
  36707. * If the attached mesh should be moved when dragged
  36708. */
  36709. moveAttached: boolean;
  36710. /**
  36711. * If the drag behavior will react to drag events (Default: true)
  36712. */
  36713. enabled: boolean;
  36714. /**
  36715. * If pointer events should start and release the drag (Default: true)
  36716. */
  36717. startAndReleaseDragOnPointerEvents: boolean;
  36718. /**
  36719. * If camera controls should be detached during the drag
  36720. */
  36721. detachCameraControls: boolean;
  36722. /**
  36723. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36724. */
  36725. useObjectOrienationForDragging: boolean;
  36726. private _options;
  36727. /**
  36728. * Creates a pointer drag behavior that can be attached to a mesh
  36729. * @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)
  36730. */
  36731. constructor(options?: {
  36732. dragAxis?: Vector3;
  36733. dragPlaneNormal?: Vector3;
  36734. });
  36735. /**
  36736. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36737. */
  36738. validateDrag: (targetPosition: Vector3) => boolean;
  36739. /**
  36740. * The name of the behavior
  36741. */
  36742. readonly name: string;
  36743. /**
  36744. * Initializes the behavior
  36745. */
  36746. init(): void;
  36747. private _tmpVector;
  36748. private _alternatePickedPoint;
  36749. private _worldDragAxis;
  36750. private _targetPosition;
  36751. private _attachedElement;
  36752. /**
  36753. * Attaches the drag behavior the passed in mesh
  36754. * @param ownerNode The mesh that will be dragged around once attached
  36755. * @param predicate Predicate to use for pick filtering
  36756. */
  36757. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36758. /**
  36759. * Force relase the drag action by code.
  36760. */
  36761. releaseDrag(): void;
  36762. private _startDragRay;
  36763. private _lastPointerRay;
  36764. /**
  36765. * Simulates the start of a pointer drag event on the behavior
  36766. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36767. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36768. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36769. */
  36770. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36771. private _startDrag;
  36772. private _dragDelta;
  36773. private _moveDrag;
  36774. private _pickWithRayOnDragPlane;
  36775. private _pointA;
  36776. private _pointB;
  36777. private _pointC;
  36778. private _lineA;
  36779. private _lineB;
  36780. private _localAxis;
  36781. private _lookAt;
  36782. private _updateDragPlanePosition;
  36783. /**
  36784. * Detaches the behavior from the mesh
  36785. */
  36786. detach(): void;
  36787. }
  36788. }
  36789. declare module BABYLON {
  36790. /**
  36791. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36792. */
  36793. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36794. private _dragBehaviorA;
  36795. private _dragBehaviorB;
  36796. private _startDistance;
  36797. private _initialScale;
  36798. private _targetScale;
  36799. private _ownerNode;
  36800. private _sceneRenderObserver;
  36801. /**
  36802. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36803. */
  36804. constructor();
  36805. /**
  36806. * The name of the behavior
  36807. */
  36808. readonly name: string;
  36809. /**
  36810. * Initializes the behavior
  36811. */
  36812. init(): void;
  36813. private _getCurrentDistance;
  36814. /**
  36815. * Attaches the scale behavior the passed in mesh
  36816. * @param ownerNode The mesh that will be scaled around once attached
  36817. */
  36818. attach(ownerNode: Mesh): void;
  36819. /**
  36820. * Detaches the behavior from the mesh
  36821. */
  36822. detach(): void;
  36823. }
  36824. }
  36825. declare module BABYLON {
  36826. /**
  36827. * 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
  36828. */
  36829. export class SixDofDragBehavior implements Behavior<Mesh> {
  36830. private static _virtualScene;
  36831. private _ownerNode;
  36832. private _sceneRenderObserver;
  36833. private _scene;
  36834. private _targetPosition;
  36835. private _virtualOriginMesh;
  36836. private _virtualDragMesh;
  36837. private _pointerObserver;
  36838. private _moving;
  36839. private _startingOrientation;
  36840. /**
  36841. * 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)
  36842. */
  36843. private zDragFactor;
  36844. /**
  36845. * If the object should rotate to face the drag origin
  36846. */
  36847. rotateDraggedObject: boolean;
  36848. /**
  36849. * If the behavior is currently in a dragging state
  36850. */
  36851. dragging: boolean;
  36852. /**
  36853. * 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)
  36854. */
  36855. dragDeltaRatio: number;
  36856. /**
  36857. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36858. */
  36859. currentDraggingPointerID: number;
  36860. /**
  36861. * If camera controls should be detached during the drag
  36862. */
  36863. detachCameraControls: boolean;
  36864. /**
  36865. * Fires each time a drag starts
  36866. */
  36867. onDragStartObservable: Observable<{}>;
  36868. /**
  36869. * Fires each time a drag ends (eg. mouse release after drag)
  36870. */
  36871. onDragEndObservable: Observable<{}>;
  36872. /**
  36873. * 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
  36874. */
  36875. constructor();
  36876. /**
  36877. * The name of the behavior
  36878. */
  36879. readonly name: string;
  36880. /**
  36881. * Initializes the behavior
  36882. */
  36883. init(): void;
  36884. /**
  36885. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36886. */
  36887. private readonly _pointerCamera;
  36888. /**
  36889. * Attaches the scale behavior the passed in mesh
  36890. * @param ownerNode The mesh that will be scaled around once attached
  36891. */
  36892. attach(ownerNode: Mesh): void;
  36893. /**
  36894. * Detaches the behavior from the mesh
  36895. */
  36896. detach(): void;
  36897. }
  36898. }
  36899. declare module BABYLON {
  36900. /**
  36901. * Class used to apply inverse kinematics to bones
  36902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36903. */
  36904. export class BoneIKController {
  36905. private static _tmpVecs;
  36906. private static _tmpQuat;
  36907. private static _tmpMats;
  36908. /**
  36909. * Gets or sets the target mesh
  36910. */
  36911. targetMesh: AbstractMesh;
  36912. /** Gets or sets the mesh used as pole */
  36913. poleTargetMesh: AbstractMesh;
  36914. /**
  36915. * Gets or sets the bone used as pole
  36916. */
  36917. poleTargetBone: Nullable<Bone>;
  36918. /**
  36919. * Gets or sets the target position
  36920. */
  36921. targetPosition: Vector3;
  36922. /**
  36923. * Gets or sets the pole target position
  36924. */
  36925. poleTargetPosition: Vector3;
  36926. /**
  36927. * Gets or sets the pole target local offset
  36928. */
  36929. poleTargetLocalOffset: Vector3;
  36930. /**
  36931. * Gets or sets the pole angle
  36932. */
  36933. poleAngle: number;
  36934. /**
  36935. * Gets or sets the mesh associated with the controller
  36936. */
  36937. mesh: AbstractMesh;
  36938. /**
  36939. * 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)
  36940. */
  36941. slerpAmount: number;
  36942. private _bone1Quat;
  36943. private _bone1Mat;
  36944. private _bone2Ang;
  36945. private _bone1;
  36946. private _bone2;
  36947. private _bone1Length;
  36948. private _bone2Length;
  36949. private _maxAngle;
  36950. private _maxReach;
  36951. private _rightHandedSystem;
  36952. private _bendAxis;
  36953. private _slerping;
  36954. private _adjustRoll;
  36955. /**
  36956. * Gets or sets maximum allowed angle
  36957. */
  36958. maxAngle: number;
  36959. /**
  36960. * Creates a new BoneIKController
  36961. * @param mesh defines the mesh to control
  36962. * @param bone defines the bone to control
  36963. * @param options defines options to set up the controller
  36964. */
  36965. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36966. targetMesh?: AbstractMesh;
  36967. poleTargetMesh?: AbstractMesh;
  36968. poleTargetBone?: Bone;
  36969. poleTargetLocalOffset?: Vector3;
  36970. poleAngle?: number;
  36971. bendAxis?: Vector3;
  36972. maxAngle?: number;
  36973. slerpAmount?: number;
  36974. });
  36975. private _setMaxAngle;
  36976. /**
  36977. * Force the controller to update the bones
  36978. */
  36979. update(): void;
  36980. }
  36981. }
  36982. declare module BABYLON {
  36983. /**
  36984. * Class used to make a bone look toward a point in space
  36985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36986. */
  36987. export class BoneLookController {
  36988. private static _tmpVecs;
  36989. private static _tmpQuat;
  36990. private static _tmpMats;
  36991. /**
  36992. * The target Vector3 that the bone will look at
  36993. */
  36994. target: Vector3;
  36995. /**
  36996. * The mesh that the bone is attached to
  36997. */
  36998. mesh: AbstractMesh;
  36999. /**
  37000. * The bone that will be looking to the target
  37001. */
  37002. bone: Bone;
  37003. /**
  37004. * The up axis of the coordinate system that is used when the bone is rotated
  37005. */
  37006. upAxis: Vector3;
  37007. /**
  37008. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37009. */
  37010. upAxisSpace: Space;
  37011. /**
  37012. * Used to make an adjustment to the yaw of the bone
  37013. */
  37014. adjustYaw: number;
  37015. /**
  37016. * Used to make an adjustment to the pitch of the bone
  37017. */
  37018. adjustPitch: number;
  37019. /**
  37020. * Used to make an adjustment to the roll of the bone
  37021. */
  37022. adjustRoll: number;
  37023. /**
  37024. * 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)
  37025. */
  37026. slerpAmount: number;
  37027. private _minYaw;
  37028. private _maxYaw;
  37029. private _minPitch;
  37030. private _maxPitch;
  37031. private _minYawSin;
  37032. private _minYawCos;
  37033. private _maxYawSin;
  37034. private _maxYawCos;
  37035. private _midYawConstraint;
  37036. private _minPitchTan;
  37037. private _maxPitchTan;
  37038. private _boneQuat;
  37039. private _slerping;
  37040. private _transformYawPitch;
  37041. private _transformYawPitchInv;
  37042. private _firstFrameSkipped;
  37043. private _yawRange;
  37044. private _fowardAxis;
  37045. /**
  37046. * Gets or sets the minimum yaw angle that the bone can look to
  37047. */
  37048. minYaw: number;
  37049. /**
  37050. * Gets or sets the maximum yaw angle that the bone can look to
  37051. */
  37052. maxYaw: number;
  37053. /**
  37054. * Gets or sets the minimum pitch angle that the bone can look to
  37055. */
  37056. minPitch: number;
  37057. /**
  37058. * Gets or sets the maximum pitch angle that the bone can look to
  37059. */
  37060. maxPitch: number;
  37061. /**
  37062. * Create a BoneLookController
  37063. * @param mesh the mesh that the bone belongs to
  37064. * @param bone the bone that will be looking to the target
  37065. * @param target the target Vector3 to look at
  37066. * @param options optional settings:
  37067. * * maxYaw: the maximum angle the bone will yaw to
  37068. * * minYaw: the minimum angle the bone will yaw to
  37069. * * maxPitch: the maximum angle the bone will pitch to
  37070. * * minPitch: the minimum angle the bone will yaw to
  37071. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37072. * * upAxis: the up axis of the coordinate system
  37073. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37074. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37075. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37076. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37077. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37078. * * adjustRoll: used to make an adjustment to the roll of the bone
  37079. **/
  37080. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37081. maxYaw?: number;
  37082. minYaw?: number;
  37083. maxPitch?: number;
  37084. minPitch?: number;
  37085. slerpAmount?: number;
  37086. upAxis?: Vector3;
  37087. upAxisSpace?: Space;
  37088. yawAxis?: Vector3;
  37089. pitchAxis?: Vector3;
  37090. adjustYaw?: number;
  37091. adjustPitch?: number;
  37092. adjustRoll?: number;
  37093. });
  37094. /**
  37095. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37096. */
  37097. update(): void;
  37098. private _getAngleDiff;
  37099. private _getAngleBetween;
  37100. private _isAngleBetween;
  37101. }
  37102. }
  37103. declare module BABYLON {
  37104. /**
  37105. * Manage the gamepad inputs to control an arc rotate camera.
  37106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37107. */
  37108. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37109. /**
  37110. * Defines the camera the input is attached to.
  37111. */
  37112. camera: ArcRotateCamera;
  37113. /**
  37114. * Defines the gamepad the input is gathering event from.
  37115. */
  37116. gamepad: Nullable<Gamepad>;
  37117. /**
  37118. * Defines the gamepad rotation sensiblity.
  37119. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37120. */
  37121. gamepadRotationSensibility: number;
  37122. /**
  37123. * Defines the gamepad move sensiblity.
  37124. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37125. */
  37126. gamepadMoveSensibility: number;
  37127. private _onGamepadConnectedObserver;
  37128. private _onGamepadDisconnectedObserver;
  37129. /**
  37130. * Attach the input controls to a specific dom element to get the input from.
  37131. * @param element Defines the element the controls should be listened from
  37132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37133. */
  37134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37135. /**
  37136. * Detach the current controls from the specified dom element.
  37137. * @param element Defines the element to stop listening the inputs from
  37138. */
  37139. detachControl(element: Nullable<HTMLElement>): void;
  37140. /**
  37141. * Update the current camera state depending on the inputs that have been used this frame.
  37142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37143. */
  37144. checkInputs(): void;
  37145. /**
  37146. * Gets the class name of the current intput.
  37147. * @returns the class name
  37148. */
  37149. getClassName(): string;
  37150. /**
  37151. * Get the friendly name associated with the input class.
  37152. * @returns the input friendly name
  37153. */
  37154. getSimpleName(): string;
  37155. }
  37156. }
  37157. declare module BABYLON {
  37158. interface ArcRotateCameraInputsManager {
  37159. /**
  37160. * Add orientation input support to the input manager.
  37161. * @returns the current input manager
  37162. */
  37163. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37164. }
  37165. /**
  37166. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37168. */
  37169. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37170. /**
  37171. * Defines the camera the input is attached to.
  37172. */
  37173. camera: ArcRotateCamera;
  37174. /**
  37175. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37176. */
  37177. alphaCorrection: number;
  37178. /**
  37179. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37180. */
  37181. gammaCorrection: number;
  37182. private _alpha;
  37183. private _gamma;
  37184. private _dirty;
  37185. private _deviceOrientationHandler;
  37186. /**
  37187. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37188. */
  37189. constructor();
  37190. /**
  37191. * Attach the input controls to a specific dom element to get the input from.
  37192. * @param element Defines the element the controls should be listened from
  37193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37194. */
  37195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37196. /** @hidden */
  37197. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37198. /**
  37199. * Update the current camera state depending on the inputs that have been used this frame.
  37200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37201. */
  37202. checkInputs(): void;
  37203. /**
  37204. * Detach the current controls from the specified dom element.
  37205. * @param element Defines the element to stop listening the inputs from
  37206. */
  37207. detachControl(element: Nullable<HTMLElement>): void;
  37208. /**
  37209. * Gets the class name of the current intput.
  37210. * @returns the class name
  37211. */
  37212. getClassName(): string;
  37213. /**
  37214. * Get the friendly name associated with the input class.
  37215. * @returns the input friendly name
  37216. */
  37217. getSimpleName(): string;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Listen to mouse events to control the camera.
  37223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37224. */
  37225. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37226. /**
  37227. * Defines the camera the input is attached to.
  37228. */
  37229. camera: FlyCamera;
  37230. /**
  37231. * Defines if touch is enabled. (Default is true.)
  37232. */
  37233. touchEnabled: boolean;
  37234. /**
  37235. * Defines the buttons associated with the input to handle camera rotation.
  37236. */
  37237. buttons: number[];
  37238. /**
  37239. * Assign buttons for Yaw control.
  37240. */
  37241. buttonsYaw: number[];
  37242. /**
  37243. * Assign buttons for Pitch control.
  37244. */
  37245. buttonsPitch: number[];
  37246. /**
  37247. * Assign buttons for Roll control.
  37248. */
  37249. buttonsRoll: number[];
  37250. /**
  37251. * Detect if any button is being pressed while mouse is moved.
  37252. * -1 = Mouse locked.
  37253. * 0 = Left button.
  37254. * 1 = Middle Button.
  37255. * 2 = Right Button.
  37256. */
  37257. activeButton: number;
  37258. /**
  37259. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37260. * Higher values reduce its sensitivity.
  37261. */
  37262. angularSensibility: number;
  37263. private _mousemoveCallback;
  37264. private _observer;
  37265. private _rollObserver;
  37266. private previousPosition;
  37267. private noPreventDefault;
  37268. private element;
  37269. /**
  37270. * Listen to mouse events to control the camera.
  37271. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37273. */
  37274. constructor(touchEnabled?: boolean);
  37275. /**
  37276. * Attach the mouse control to the HTML DOM element.
  37277. * @param element Defines the element that listens to the input events.
  37278. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37279. */
  37280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37281. /**
  37282. * Detach the current controls from the specified dom element.
  37283. * @param element Defines the element to stop listening the inputs from
  37284. */
  37285. detachControl(element: Nullable<HTMLElement>): void;
  37286. /**
  37287. * Gets the class name of the current input.
  37288. * @returns the class name.
  37289. */
  37290. getClassName(): string;
  37291. /**
  37292. * Get the friendly name associated with the input class.
  37293. * @returns the input's friendly name.
  37294. */
  37295. getSimpleName(): string;
  37296. private _pointerInput;
  37297. private _onMouseMove;
  37298. /**
  37299. * Rotate camera by mouse offset.
  37300. */
  37301. private rotateCamera;
  37302. }
  37303. }
  37304. declare module BABYLON {
  37305. /**
  37306. * Default Inputs manager for the FlyCamera.
  37307. * It groups all the default supported inputs for ease of use.
  37308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37309. */
  37310. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37311. /**
  37312. * Instantiates a new FlyCameraInputsManager.
  37313. * @param camera Defines the camera the inputs belong to.
  37314. */
  37315. constructor(camera: FlyCamera);
  37316. /**
  37317. * Add keyboard input support to the input manager.
  37318. * @returns the new FlyCameraKeyboardMoveInput().
  37319. */
  37320. addKeyboard(): FlyCameraInputsManager;
  37321. /**
  37322. * Add mouse input support to the input manager.
  37323. * @param touchEnabled Enable touch screen support.
  37324. * @returns the new FlyCameraMouseInput().
  37325. */
  37326. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37327. }
  37328. }
  37329. declare module BABYLON {
  37330. /**
  37331. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37332. * such as in a 3D Space Shooter or a Flight Simulator.
  37333. */
  37334. export class FlyCamera extends TargetCamera {
  37335. /**
  37336. * Define the collision ellipsoid of the camera.
  37337. * This is helpful for simulating a camera body, like a player's body.
  37338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37339. */
  37340. ellipsoid: Vector3;
  37341. /**
  37342. * Define an offset for the position of the ellipsoid around the camera.
  37343. * This can be helpful if the camera is attached away from the player's body center,
  37344. * such as at its head.
  37345. */
  37346. ellipsoidOffset: Vector3;
  37347. /**
  37348. * Enable or disable collisions of the camera with the rest of the scene objects.
  37349. */
  37350. checkCollisions: boolean;
  37351. /**
  37352. * Enable or disable gravity on the camera.
  37353. */
  37354. applyGravity: boolean;
  37355. /**
  37356. * Define the current direction the camera is moving to.
  37357. */
  37358. cameraDirection: Vector3;
  37359. /**
  37360. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37361. * This overrides and empties cameraRotation.
  37362. */
  37363. rotationQuaternion: Quaternion;
  37364. /**
  37365. * Track Roll to maintain the wanted Rolling when looking around.
  37366. */
  37367. _trackRoll: number;
  37368. /**
  37369. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37370. */
  37371. rollCorrect: number;
  37372. /**
  37373. * Mimic a banked turn, Rolling the camera when Yawing.
  37374. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37375. */
  37376. bankedTurn: boolean;
  37377. /**
  37378. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37379. */
  37380. bankedTurnLimit: number;
  37381. /**
  37382. * Value of 0 disables the banked Roll.
  37383. * Value of 1 is equal to the Yaw angle in radians.
  37384. */
  37385. bankedTurnMultiplier: number;
  37386. /**
  37387. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37388. */
  37389. inputs: FlyCameraInputsManager;
  37390. /**
  37391. * Gets the input sensibility for mouse input.
  37392. * Higher values reduce sensitivity.
  37393. */
  37394. /**
  37395. * Sets the input sensibility for a mouse input.
  37396. * Higher values reduce sensitivity.
  37397. */
  37398. angularSensibility: number;
  37399. /**
  37400. * Get the keys for camera movement forward.
  37401. */
  37402. /**
  37403. * Set the keys for camera movement forward.
  37404. */
  37405. keysForward: number[];
  37406. /**
  37407. * Get the keys for camera movement backward.
  37408. */
  37409. keysBackward: number[];
  37410. /**
  37411. * Get the keys for camera movement up.
  37412. */
  37413. /**
  37414. * Set the keys for camera movement up.
  37415. */
  37416. keysUp: number[];
  37417. /**
  37418. * Get the keys for camera movement down.
  37419. */
  37420. /**
  37421. * Set the keys for camera movement down.
  37422. */
  37423. keysDown: number[];
  37424. /**
  37425. * Get the keys for camera movement left.
  37426. */
  37427. /**
  37428. * Set the keys for camera movement left.
  37429. */
  37430. keysLeft: number[];
  37431. /**
  37432. * Set the keys for camera movement right.
  37433. */
  37434. /**
  37435. * Set the keys for camera movement right.
  37436. */
  37437. keysRight: number[];
  37438. /**
  37439. * Event raised when the camera collides with a mesh in the scene.
  37440. */
  37441. onCollide: (collidedMesh: AbstractMesh) => void;
  37442. private _collider;
  37443. private _needMoveForGravity;
  37444. private _oldPosition;
  37445. private _diffPosition;
  37446. private _newPosition;
  37447. /** @hidden */
  37448. _localDirection: Vector3;
  37449. /** @hidden */
  37450. _transformedDirection: Vector3;
  37451. /**
  37452. * Instantiates a FlyCamera.
  37453. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37454. * such as in a 3D Space Shooter or a Flight Simulator.
  37455. * @param name Define the name of the camera in the scene.
  37456. * @param position Define the starting position of the camera in the scene.
  37457. * @param scene Define the scene the camera belongs to.
  37458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37459. */
  37460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37461. /**
  37462. * Attach a control to the HTML DOM element.
  37463. * @param element Defines the element that listens to the input events.
  37464. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37465. */
  37466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37467. /**
  37468. * Detach a control from the HTML DOM element.
  37469. * The camera will stop reacting to that input.
  37470. * @param element Defines the element that listens to the input events.
  37471. */
  37472. detachControl(element: HTMLElement): void;
  37473. private _collisionMask;
  37474. /**
  37475. * Get the mask that the camera ignores in collision events.
  37476. */
  37477. /**
  37478. * Set the mask that the camera ignores in collision events.
  37479. */
  37480. collisionMask: number;
  37481. /** @hidden */
  37482. _collideWithWorld(displacement: Vector3): void;
  37483. /** @hidden */
  37484. private _onCollisionPositionChange;
  37485. /** @hidden */
  37486. _checkInputs(): void;
  37487. /** @hidden */
  37488. _decideIfNeedsToMove(): boolean;
  37489. /** @hidden */
  37490. _updatePosition(): void;
  37491. /**
  37492. * Restore the Roll to its target value at the rate specified.
  37493. * @param rate - Higher means slower restoring.
  37494. * @hidden
  37495. */
  37496. restoreRoll(rate: number): void;
  37497. /**
  37498. * Destroy the camera and release the current resources held by it.
  37499. */
  37500. dispose(): void;
  37501. /**
  37502. * Get the current object class name.
  37503. * @returns the class name.
  37504. */
  37505. getClassName(): string;
  37506. }
  37507. }
  37508. declare module BABYLON {
  37509. /**
  37510. * Listen to keyboard events to control the camera.
  37511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37512. */
  37513. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37514. /**
  37515. * Defines the camera the input is attached to.
  37516. */
  37517. camera: FlyCamera;
  37518. /**
  37519. * The list of keyboard keys used to control the forward move of the camera.
  37520. */
  37521. keysForward: number[];
  37522. /**
  37523. * The list of keyboard keys used to control the backward move of the camera.
  37524. */
  37525. keysBackward: number[];
  37526. /**
  37527. * The list of keyboard keys used to control the forward move of the camera.
  37528. */
  37529. keysUp: number[];
  37530. /**
  37531. * The list of keyboard keys used to control the backward move of the camera.
  37532. */
  37533. keysDown: number[];
  37534. /**
  37535. * The list of keyboard keys used to control the right strafe move of the camera.
  37536. */
  37537. keysRight: number[];
  37538. /**
  37539. * The list of keyboard keys used to control the left strafe move of the camera.
  37540. */
  37541. keysLeft: number[];
  37542. private _keys;
  37543. private _onCanvasBlurObserver;
  37544. private _onKeyboardObserver;
  37545. private _engine;
  37546. private _scene;
  37547. /**
  37548. * Attach the input controls to a specific dom element to get the input from.
  37549. * @param element Defines the element the controls should be listened from
  37550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37551. */
  37552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37553. /**
  37554. * Detach the current controls from the specified dom element.
  37555. * @param element Defines the element to stop listening the inputs from
  37556. */
  37557. detachControl(element: Nullable<HTMLElement>): void;
  37558. /**
  37559. * Gets the class name of the current intput.
  37560. * @returns the class name
  37561. */
  37562. getClassName(): string;
  37563. /** @hidden */
  37564. _onLostFocus(e: FocusEvent): void;
  37565. /**
  37566. * Get the friendly name associated with the input class.
  37567. * @returns the input friendly name
  37568. */
  37569. getSimpleName(): string;
  37570. /**
  37571. * Update the current camera state depending on the inputs that have been used this frame.
  37572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37573. */
  37574. checkInputs(): void;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * Manage the mouse wheel inputs to control a follow camera.
  37580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37581. */
  37582. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37583. /**
  37584. * Defines the camera the input is attached to.
  37585. */
  37586. camera: FollowCamera;
  37587. /**
  37588. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37589. */
  37590. axisControlRadius: boolean;
  37591. /**
  37592. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37593. */
  37594. axisControlHeight: boolean;
  37595. /**
  37596. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37597. */
  37598. axisControlRotation: boolean;
  37599. /**
  37600. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37601. * relation to mouseWheel events.
  37602. */
  37603. wheelPrecision: number;
  37604. /**
  37605. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37606. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37607. */
  37608. wheelDeltaPercentage: number;
  37609. private _wheel;
  37610. private _observer;
  37611. /**
  37612. * Attach the input controls to a specific dom element to get the input from.
  37613. * @param element Defines the element the controls should be listened from
  37614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37615. */
  37616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37617. /**
  37618. * Detach the current controls from the specified dom element.
  37619. * @param element Defines the element to stop listening the inputs from
  37620. */
  37621. detachControl(element: Nullable<HTMLElement>): void;
  37622. /**
  37623. * Gets the class name of the current intput.
  37624. * @returns the class name
  37625. */
  37626. getClassName(): string;
  37627. /**
  37628. * Get the friendly name associated with the input class.
  37629. * @returns the input friendly name
  37630. */
  37631. getSimpleName(): string;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /**
  37636. * Manage the pointers inputs to control an follow camera.
  37637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37638. */
  37639. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37640. /**
  37641. * Defines the camera the input is attached to.
  37642. */
  37643. camera: FollowCamera;
  37644. /**
  37645. * Gets the class name of the current input.
  37646. * @returns the class name
  37647. */
  37648. getClassName(): string;
  37649. /**
  37650. * Defines the pointer angular sensibility along the X axis or how fast is
  37651. * the camera rotating.
  37652. * A negative number will reverse the axis direction.
  37653. */
  37654. angularSensibilityX: number;
  37655. /**
  37656. * Defines the pointer angular sensibility along the Y axis or how fast is
  37657. * the camera rotating.
  37658. * A negative number will reverse the axis direction.
  37659. */
  37660. angularSensibilityY: number;
  37661. /**
  37662. * Defines the pointer pinch precision or how fast is the camera zooming.
  37663. * A negative number will reverse the axis direction.
  37664. */
  37665. pinchPrecision: number;
  37666. /**
  37667. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37668. * from 0.
  37669. * It defines the percentage of current camera.radius to use as delta when
  37670. * pinch zoom is used.
  37671. */
  37672. pinchDeltaPercentage: number;
  37673. /**
  37674. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37675. */
  37676. axisXControlRadius: boolean;
  37677. /**
  37678. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37679. */
  37680. axisXControlHeight: boolean;
  37681. /**
  37682. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37683. */
  37684. axisXControlRotation: boolean;
  37685. /**
  37686. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37687. */
  37688. axisYControlRadius: boolean;
  37689. /**
  37690. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37691. */
  37692. axisYControlHeight: boolean;
  37693. /**
  37694. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37695. */
  37696. axisYControlRotation: boolean;
  37697. /**
  37698. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37699. */
  37700. axisPinchControlRadius: boolean;
  37701. /**
  37702. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37703. */
  37704. axisPinchControlHeight: boolean;
  37705. /**
  37706. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37707. */
  37708. axisPinchControlRotation: boolean;
  37709. /**
  37710. * Log error messages if basic misconfiguration has occurred.
  37711. */
  37712. warningEnable: boolean;
  37713. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37714. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37715. private _warningCounter;
  37716. private _warning;
  37717. }
  37718. }
  37719. declare module BABYLON {
  37720. /**
  37721. * Default Inputs manager for the FollowCamera.
  37722. * It groups all the default supported inputs for ease of use.
  37723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37724. */
  37725. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37726. /**
  37727. * Instantiates a new FollowCameraInputsManager.
  37728. * @param camera Defines the camera the inputs belong to
  37729. */
  37730. constructor(camera: FollowCamera);
  37731. /**
  37732. * Add keyboard input support to the input manager.
  37733. * @returns the current input manager
  37734. */
  37735. addKeyboard(): FollowCameraInputsManager;
  37736. /**
  37737. * Add mouse wheel input support to the input manager.
  37738. * @returns the current input manager
  37739. */
  37740. addMouseWheel(): FollowCameraInputsManager;
  37741. /**
  37742. * Add pointers input support to the input manager.
  37743. * @returns the current input manager
  37744. */
  37745. addPointers(): FollowCameraInputsManager;
  37746. /**
  37747. * Add orientation input support to the input manager.
  37748. * @returns the current input manager
  37749. */
  37750. addVRDeviceOrientation(): FollowCameraInputsManager;
  37751. }
  37752. }
  37753. declare module BABYLON {
  37754. /**
  37755. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37756. * an arc rotate version arcFollowCamera are available.
  37757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37758. */
  37759. export class FollowCamera extends TargetCamera {
  37760. /**
  37761. * Distance the follow camera should follow an object at
  37762. */
  37763. radius: number;
  37764. /**
  37765. * Minimum allowed distance of the camera to the axis of rotation
  37766. * (The camera can not get closer).
  37767. * This can help limiting how the Camera is able to move in the scene.
  37768. */
  37769. lowerRadiusLimit: Nullable<number>;
  37770. /**
  37771. * Maximum allowed distance of the camera to the axis of rotation
  37772. * (The camera can not get further).
  37773. * This can help limiting how the Camera is able to move in the scene.
  37774. */
  37775. upperRadiusLimit: Nullable<number>;
  37776. /**
  37777. * Define a rotation offset between the camera and the object it follows
  37778. */
  37779. rotationOffset: number;
  37780. /**
  37781. * Minimum allowed angle to camera position relative to target object.
  37782. * This can help limiting how the Camera is able to move in the scene.
  37783. */
  37784. lowerRotationOffsetLimit: Nullable<number>;
  37785. /**
  37786. * Maximum allowed angle to camera position relative to target object.
  37787. * This can help limiting how the Camera is able to move in the scene.
  37788. */
  37789. upperRotationOffsetLimit: Nullable<number>;
  37790. /**
  37791. * Define a height offset between the camera and the object it follows.
  37792. * It can help following an object from the top (like a car chaing a plane)
  37793. */
  37794. heightOffset: number;
  37795. /**
  37796. * Minimum allowed height of camera position relative to target object.
  37797. * This can help limiting how the Camera is able to move in the scene.
  37798. */
  37799. lowerHeightOffsetLimit: Nullable<number>;
  37800. /**
  37801. * Maximum allowed height of camera position relative to target object.
  37802. * This can help limiting how the Camera is able to move in the scene.
  37803. */
  37804. upperHeightOffsetLimit: Nullable<number>;
  37805. /**
  37806. * Define how fast the camera can accelerate to follow it s target.
  37807. */
  37808. cameraAcceleration: number;
  37809. /**
  37810. * Define the speed limit of the camera following an object.
  37811. */
  37812. maxCameraSpeed: number;
  37813. /**
  37814. * Define the target of the camera.
  37815. */
  37816. lockedTarget: Nullable<AbstractMesh>;
  37817. /**
  37818. * Defines the input associated with the camera.
  37819. */
  37820. inputs: FollowCameraInputsManager;
  37821. /**
  37822. * Instantiates the follow camera.
  37823. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37824. * @param name Define the name of the camera in the scene
  37825. * @param position Define the position of the camera
  37826. * @param scene Define the scene the camera belong to
  37827. * @param lockedTarget Define the target of the camera
  37828. */
  37829. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37830. private _follow;
  37831. /**
  37832. * Attached controls to the current camera.
  37833. * @param element Defines the element the controls should be listened from
  37834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37835. */
  37836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37837. /**
  37838. * Detach the current controls from the camera.
  37839. * The camera will stop reacting to inputs.
  37840. * @param element Defines the element to stop listening the inputs from
  37841. */
  37842. detachControl(element: HTMLElement): void;
  37843. /** @hidden */
  37844. _checkInputs(): void;
  37845. private _checkLimits;
  37846. /**
  37847. * Gets the camera class name.
  37848. * @returns the class name
  37849. */
  37850. getClassName(): string;
  37851. }
  37852. /**
  37853. * Arc Rotate version of the follow camera.
  37854. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37855. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37856. */
  37857. export class ArcFollowCamera extends TargetCamera {
  37858. /** The longitudinal angle of the camera */
  37859. alpha: number;
  37860. /** The latitudinal angle of the camera */
  37861. beta: number;
  37862. /** The radius of the camera from its target */
  37863. radius: number;
  37864. /** Define the camera target (the messh it should follow) */
  37865. target: Nullable<AbstractMesh>;
  37866. private _cartesianCoordinates;
  37867. /**
  37868. * Instantiates a new ArcFollowCamera
  37869. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37870. * @param name Define the name of the camera
  37871. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37872. * @param beta Define the rotation angle of the camera around the elevation axis
  37873. * @param radius Define the radius of the camera from its target point
  37874. * @param target Define the target of the camera
  37875. * @param scene Define the scene the camera belongs to
  37876. */
  37877. constructor(name: string,
  37878. /** The longitudinal angle of the camera */
  37879. alpha: number,
  37880. /** The latitudinal angle of the camera */
  37881. beta: number,
  37882. /** The radius of the camera from its target */
  37883. radius: number,
  37884. /** Define the camera target (the messh it should follow) */
  37885. target: Nullable<AbstractMesh>, scene: Scene);
  37886. private _follow;
  37887. /** @hidden */
  37888. _checkInputs(): void;
  37889. /**
  37890. * Returns the class name of the object.
  37891. * It is mostly used internally for serialization purposes.
  37892. */
  37893. getClassName(): string;
  37894. }
  37895. }
  37896. declare module BABYLON {
  37897. /**
  37898. * Manage the keyboard inputs to control the movement of a follow camera.
  37899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37900. */
  37901. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37902. /**
  37903. * Defines the camera the input is attached to.
  37904. */
  37905. camera: FollowCamera;
  37906. /**
  37907. * Defines the list of key codes associated with the up action (increase heightOffset)
  37908. */
  37909. keysHeightOffsetIncr: number[];
  37910. /**
  37911. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37912. */
  37913. keysHeightOffsetDecr: number[];
  37914. /**
  37915. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37916. */
  37917. keysHeightOffsetModifierAlt: boolean;
  37918. /**
  37919. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37920. */
  37921. keysHeightOffsetModifierCtrl: boolean;
  37922. /**
  37923. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37924. */
  37925. keysHeightOffsetModifierShift: boolean;
  37926. /**
  37927. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37928. */
  37929. keysRotationOffsetIncr: number[];
  37930. /**
  37931. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37932. */
  37933. keysRotationOffsetDecr: number[];
  37934. /**
  37935. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37936. */
  37937. keysRotationOffsetModifierAlt: boolean;
  37938. /**
  37939. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37940. */
  37941. keysRotationOffsetModifierCtrl: boolean;
  37942. /**
  37943. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37944. */
  37945. keysRotationOffsetModifierShift: boolean;
  37946. /**
  37947. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37948. */
  37949. keysRadiusIncr: number[];
  37950. /**
  37951. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37952. */
  37953. keysRadiusDecr: number[];
  37954. /**
  37955. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37956. */
  37957. keysRadiusModifierAlt: boolean;
  37958. /**
  37959. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37960. */
  37961. keysRadiusModifierCtrl: boolean;
  37962. /**
  37963. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37964. */
  37965. keysRadiusModifierShift: boolean;
  37966. /**
  37967. * Defines the rate of change of heightOffset.
  37968. */
  37969. heightSensibility: number;
  37970. /**
  37971. * Defines the rate of change of rotationOffset.
  37972. */
  37973. rotationSensibility: number;
  37974. /**
  37975. * Defines the rate of change of radius.
  37976. */
  37977. radiusSensibility: number;
  37978. private _keys;
  37979. private _ctrlPressed;
  37980. private _altPressed;
  37981. private _shiftPressed;
  37982. private _onCanvasBlurObserver;
  37983. private _onKeyboardObserver;
  37984. private _engine;
  37985. private _scene;
  37986. /**
  37987. * Attach the input controls to a specific dom element to get the input from.
  37988. * @param element Defines the element the controls should be listened from
  37989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37990. */
  37991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37992. /**
  37993. * Detach the current controls from the specified dom element.
  37994. * @param element Defines the element to stop listening the inputs from
  37995. */
  37996. detachControl(element: Nullable<HTMLElement>): void;
  37997. /**
  37998. * Update the current camera state depending on the inputs that have been used this frame.
  37999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38000. */
  38001. checkInputs(): void;
  38002. /**
  38003. * Gets the class name of the current input.
  38004. * @returns the class name
  38005. */
  38006. getClassName(): string;
  38007. /**
  38008. * Get the friendly name associated with the input class.
  38009. * @returns the input friendly name
  38010. */
  38011. getSimpleName(): string;
  38012. /**
  38013. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38014. * allow modification of the heightOffset value.
  38015. */
  38016. private _modifierHeightOffset;
  38017. /**
  38018. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38019. * allow modification of the rotationOffset value.
  38020. */
  38021. private _modifierRotationOffset;
  38022. /**
  38023. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38024. * allow modification of the radius value.
  38025. */
  38026. private _modifierRadius;
  38027. }
  38028. }
  38029. declare module BABYLON {
  38030. interface FreeCameraInputsManager {
  38031. /**
  38032. * @hidden
  38033. */
  38034. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38035. /**
  38036. * Add orientation input support to the input manager.
  38037. * @returns the current input manager
  38038. */
  38039. addDeviceOrientation(): FreeCameraInputsManager;
  38040. }
  38041. /**
  38042. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38043. * Screen rotation is taken into account.
  38044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38045. */
  38046. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38047. private _camera;
  38048. private _screenOrientationAngle;
  38049. private _constantTranform;
  38050. private _screenQuaternion;
  38051. private _alpha;
  38052. private _beta;
  38053. private _gamma;
  38054. /**
  38055. * Can be used to detect if a device orientation sensor is availible on a device
  38056. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38057. * @returns a promise that will resolve on orientation change
  38058. */
  38059. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38060. /**
  38061. * @hidden
  38062. */
  38063. _onDeviceOrientationChangedObservable: Observable<void>;
  38064. /**
  38065. * Instantiates a new input
  38066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38067. */
  38068. constructor();
  38069. /**
  38070. * Define the camera controlled by the input.
  38071. */
  38072. camera: FreeCamera;
  38073. /**
  38074. * Attach the input controls to a specific dom element to get the input from.
  38075. * @param element Defines the element the controls should be listened from
  38076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38077. */
  38078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38079. private _orientationChanged;
  38080. private _deviceOrientation;
  38081. /**
  38082. * Detach the current controls from the specified dom element.
  38083. * @param element Defines the element to stop listening the inputs from
  38084. */
  38085. detachControl(element: Nullable<HTMLElement>): void;
  38086. /**
  38087. * Update the current camera state depending on the inputs that have been used this frame.
  38088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38089. */
  38090. checkInputs(): void;
  38091. /**
  38092. * Gets the class name of the current intput.
  38093. * @returns the class name
  38094. */
  38095. getClassName(): string;
  38096. /**
  38097. * Get the friendly name associated with the input class.
  38098. * @returns the input friendly name
  38099. */
  38100. getSimpleName(): string;
  38101. }
  38102. }
  38103. declare module BABYLON {
  38104. /**
  38105. * Manage the gamepad inputs to control a free camera.
  38106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38107. */
  38108. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38109. /**
  38110. * Define the camera the input is attached to.
  38111. */
  38112. camera: FreeCamera;
  38113. /**
  38114. * Define the Gamepad controlling the input
  38115. */
  38116. gamepad: Nullable<Gamepad>;
  38117. /**
  38118. * Defines the gamepad rotation sensiblity.
  38119. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38120. */
  38121. gamepadAngularSensibility: number;
  38122. /**
  38123. * Defines the gamepad move sensiblity.
  38124. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38125. */
  38126. gamepadMoveSensibility: number;
  38127. private _onGamepadConnectedObserver;
  38128. private _onGamepadDisconnectedObserver;
  38129. private _cameraTransform;
  38130. private _deltaTransform;
  38131. private _vector3;
  38132. private _vector2;
  38133. /**
  38134. * Attach the input controls to a specific dom element to get the input from.
  38135. * @param element Defines the element the controls should be listened from
  38136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38137. */
  38138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38139. /**
  38140. * Detach the current controls from the specified dom element.
  38141. * @param element Defines the element to stop listening the inputs from
  38142. */
  38143. detachControl(element: Nullable<HTMLElement>): void;
  38144. /**
  38145. * Update the current camera state depending on the inputs that have been used this frame.
  38146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38147. */
  38148. checkInputs(): void;
  38149. /**
  38150. * Gets the class name of the current intput.
  38151. * @returns the class name
  38152. */
  38153. getClassName(): string;
  38154. /**
  38155. * Get the friendly name associated with the input class.
  38156. * @returns the input friendly name
  38157. */
  38158. getSimpleName(): string;
  38159. }
  38160. }
  38161. declare module BABYLON {
  38162. /**
  38163. * Defines the potential axis of a Joystick
  38164. */
  38165. export enum JoystickAxis {
  38166. /** X axis */
  38167. X = 0,
  38168. /** Y axis */
  38169. Y = 1,
  38170. /** Z axis */
  38171. Z = 2
  38172. }
  38173. /**
  38174. * Class used to define virtual joystick (used in touch mode)
  38175. */
  38176. export class VirtualJoystick {
  38177. /**
  38178. * Gets or sets a boolean indicating that left and right values must be inverted
  38179. */
  38180. reverseLeftRight: boolean;
  38181. /**
  38182. * Gets or sets a boolean indicating that up and down values must be inverted
  38183. */
  38184. reverseUpDown: boolean;
  38185. /**
  38186. * Gets the offset value for the position (ie. the change of the position value)
  38187. */
  38188. deltaPosition: Vector3;
  38189. /**
  38190. * Gets a boolean indicating if the virtual joystick was pressed
  38191. */
  38192. pressed: boolean;
  38193. /**
  38194. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38195. */
  38196. static Canvas: Nullable<HTMLCanvasElement>;
  38197. private static _globalJoystickIndex;
  38198. private static vjCanvasContext;
  38199. private static vjCanvasWidth;
  38200. private static vjCanvasHeight;
  38201. private static halfWidth;
  38202. private _action;
  38203. private _axisTargetedByLeftAndRight;
  38204. private _axisTargetedByUpAndDown;
  38205. private _joystickSensibility;
  38206. private _inversedSensibility;
  38207. private _joystickPointerID;
  38208. private _joystickColor;
  38209. private _joystickPointerPos;
  38210. private _joystickPreviousPointerPos;
  38211. private _joystickPointerStartPos;
  38212. private _deltaJoystickVector;
  38213. private _leftJoystick;
  38214. private _touches;
  38215. private _onPointerDownHandlerRef;
  38216. private _onPointerMoveHandlerRef;
  38217. private _onPointerUpHandlerRef;
  38218. private _onResize;
  38219. /**
  38220. * Creates a new virtual joystick
  38221. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38222. */
  38223. constructor(leftJoystick?: boolean);
  38224. /**
  38225. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38226. * @param newJoystickSensibility defines the new sensibility
  38227. */
  38228. setJoystickSensibility(newJoystickSensibility: number): void;
  38229. private _onPointerDown;
  38230. private _onPointerMove;
  38231. private _onPointerUp;
  38232. /**
  38233. * Change the color of the virtual joystick
  38234. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38235. */
  38236. setJoystickColor(newColor: string): void;
  38237. /**
  38238. * Defines a callback to call when the joystick is touched
  38239. * @param action defines the callback
  38240. */
  38241. setActionOnTouch(action: () => any): void;
  38242. /**
  38243. * Defines which axis you'd like to control for left & right
  38244. * @param axis defines the axis to use
  38245. */
  38246. setAxisForLeftRight(axis: JoystickAxis): void;
  38247. /**
  38248. * Defines which axis you'd like to control for up & down
  38249. * @param axis defines the axis to use
  38250. */
  38251. setAxisForUpDown(axis: JoystickAxis): void;
  38252. private _drawVirtualJoystick;
  38253. /**
  38254. * Release internal HTML canvas
  38255. */
  38256. releaseCanvas(): void;
  38257. }
  38258. }
  38259. declare module BABYLON {
  38260. interface FreeCameraInputsManager {
  38261. /**
  38262. * Add virtual joystick input support to the input manager.
  38263. * @returns the current input manager
  38264. */
  38265. addVirtualJoystick(): FreeCameraInputsManager;
  38266. }
  38267. /**
  38268. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38270. */
  38271. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38272. /**
  38273. * Defines the camera the input is attached to.
  38274. */
  38275. camera: FreeCamera;
  38276. private _leftjoystick;
  38277. private _rightjoystick;
  38278. /**
  38279. * Gets the left stick of the virtual joystick.
  38280. * @returns The virtual Joystick
  38281. */
  38282. getLeftJoystick(): VirtualJoystick;
  38283. /**
  38284. * Gets the right stick of the virtual joystick.
  38285. * @returns The virtual Joystick
  38286. */
  38287. getRightJoystick(): VirtualJoystick;
  38288. /**
  38289. * Update the current camera state depending on the inputs that have been used this frame.
  38290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38291. */
  38292. checkInputs(): void;
  38293. /**
  38294. * Attach the input controls to a specific dom element to get the input from.
  38295. * @param element Defines the element the controls should be listened from
  38296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38297. */
  38298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38299. /**
  38300. * Detach the current controls from the specified dom element.
  38301. * @param element Defines the element to stop listening the inputs from
  38302. */
  38303. detachControl(element: Nullable<HTMLElement>): void;
  38304. /**
  38305. * Gets the class name of the current intput.
  38306. * @returns the class name
  38307. */
  38308. getClassName(): string;
  38309. /**
  38310. * Get the friendly name associated with the input class.
  38311. * @returns the input friendly name
  38312. */
  38313. getSimpleName(): string;
  38314. }
  38315. }
  38316. declare module BABYLON {
  38317. /**
  38318. * This represents a FPS type of camera controlled by touch.
  38319. * This is like a universal camera minus the Gamepad controls.
  38320. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38321. */
  38322. export class TouchCamera extends FreeCamera {
  38323. /**
  38324. * Defines the touch sensibility for rotation.
  38325. * The higher the faster.
  38326. */
  38327. touchAngularSensibility: number;
  38328. /**
  38329. * Defines the touch sensibility for move.
  38330. * The higher the faster.
  38331. */
  38332. touchMoveSensibility: number;
  38333. /**
  38334. * Instantiates a new touch camera.
  38335. * This represents a FPS type of camera controlled by touch.
  38336. * This is like a universal camera minus the Gamepad controls.
  38337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38338. * @param name Define the name of the camera in the scene
  38339. * @param position Define the start position of the camera in the scene
  38340. * @param scene Define the scene the camera belongs to
  38341. */
  38342. constructor(name: string, position: Vector3, scene: Scene);
  38343. /**
  38344. * Gets the current object class name.
  38345. * @return the class name
  38346. */
  38347. getClassName(): string;
  38348. /** @hidden */
  38349. _setupInputs(): void;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38355. * being tilted forward or back and left or right.
  38356. */
  38357. export class DeviceOrientationCamera extends FreeCamera {
  38358. private _initialQuaternion;
  38359. private _quaternionCache;
  38360. private _tmpDragQuaternion;
  38361. private _disablePointerInputWhenUsingDeviceOrientation;
  38362. /**
  38363. * Creates a new device orientation camera
  38364. * @param name The name of the camera
  38365. * @param position The start position camera
  38366. * @param scene The scene the camera belongs to
  38367. */
  38368. constructor(name: string, position: Vector3, scene: Scene);
  38369. /**
  38370. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38371. */
  38372. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38373. private _dragFactor;
  38374. /**
  38375. * Enabled turning on the y axis when the orientation sensor is active
  38376. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38377. */
  38378. enableHorizontalDragging(dragFactor?: number): void;
  38379. /**
  38380. * Gets the current instance class name ("DeviceOrientationCamera").
  38381. * This helps avoiding instanceof at run time.
  38382. * @returns the class name
  38383. */
  38384. getClassName(): string;
  38385. /**
  38386. * @hidden
  38387. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38388. */
  38389. _checkInputs(): void;
  38390. /**
  38391. * Reset the camera to its default orientation on the specified axis only.
  38392. * @param axis The axis to reset
  38393. */
  38394. resetToCurrentRotation(axis?: Axis): void;
  38395. }
  38396. }
  38397. declare module BABYLON {
  38398. /**
  38399. * Defines supported buttons for XBox360 compatible gamepads
  38400. */
  38401. export enum Xbox360Button {
  38402. /** A */
  38403. A = 0,
  38404. /** B */
  38405. B = 1,
  38406. /** X */
  38407. X = 2,
  38408. /** Y */
  38409. Y = 3,
  38410. /** Start */
  38411. Start = 4,
  38412. /** Back */
  38413. Back = 5,
  38414. /** Left button */
  38415. LB = 6,
  38416. /** Right button */
  38417. RB = 7,
  38418. /** Left stick */
  38419. LeftStick = 8,
  38420. /** Right stick */
  38421. RightStick = 9
  38422. }
  38423. /** Defines values for XBox360 DPad */
  38424. export enum Xbox360Dpad {
  38425. /** Up */
  38426. Up = 0,
  38427. /** Down */
  38428. Down = 1,
  38429. /** Left */
  38430. Left = 2,
  38431. /** Right */
  38432. Right = 3
  38433. }
  38434. /**
  38435. * Defines a XBox360 gamepad
  38436. */
  38437. export class Xbox360Pad extends Gamepad {
  38438. private _leftTrigger;
  38439. private _rightTrigger;
  38440. private _onlefttriggerchanged;
  38441. private _onrighttriggerchanged;
  38442. private _onbuttondown;
  38443. private _onbuttonup;
  38444. private _ondpaddown;
  38445. private _ondpadup;
  38446. /** Observable raised when a button is pressed */
  38447. onButtonDownObservable: Observable<Xbox360Button>;
  38448. /** Observable raised when a button is released */
  38449. onButtonUpObservable: Observable<Xbox360Button>;
  38450. /** Observable raised when a pad is pressed */
  38451. onPadDownObservable: Observable<Xbox360Dpad>;
  38452. /** Observable raised when a pad is released */
  38453. onPadUpObservable: Observable<Xbox360Dpad>;
  38454. private _buttonA;
  38455. private _buttonB;
  38456. private _buttonX;
  38457. private _buttonY;
  38458. private _buttonBack;
  38459. private _buttonStart;
  38460. private _buttonLB;
  38461. private _buttonRB;
  38462. private _buttonLeftStick;
  38463. private _buttonRightStick;
  38464. private _dPadUp;
  38465. private _dPadDown;
  38466. private _dPadLeft;
  38467. private _dPadRight;
  38468. private _isXboxOnePad;
  38469. /**
  38470. * Creates a new XBox360 gamepad object
  38471. * @param id defines the id of this gamepad
  38472. * @param index defines its index
  38473. * @param gamepad defines the internal HTML gamepad object
  38474. * @param xboxOne defines if it is a XBox One gamepad
  38475. */
  38476. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38477. /**
  38478. * Defines the callback to call when left trigger is pressed
  38479. * @param callback defines the callback to use
  38480. */
  38481. onlefttriggerchanged(callback: (value: number) => void): void;
  38482. /**
  38483. * Defines the callback to call when right trigger is pressed
  38484. * @param callback defines the callback to use
  38485. */
  38486. onrighttriggerchanged(callback: (value: number) => void): void;
  38487. /**
  38488. * Gets the left trigger value
  38489. */
  38490. /**
  38491. * Sets the left trigger value
  38492. */
  38493. leftTrigger: number;
  38494. /**
  38495. * Gets the right trigger value
  38496. */
  38497. /**
  38498. * Sets the right trigger value
  38499. */
  38500. rightTrigger: number;
  38501. /**
  38502. * Defines the callback to call when a button is pressed
  38503. * @param callback defines the callback to use
  38504. */
  38505. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38506. /**
  38507. * Defines the callback to call when a button is released
  38508. * @param callback defines the callback to use
  38509. */
  38510. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38511. /**
  38512. * Defines the callback to call when a pad is pressed
  38513. * @param callback defines the callback to use
  38514. */
  38515. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38516. /**
  38517. * Defines the callback to call when a pad is released
  38518. * @param callback defines the callback to use
  38519. */
  38520. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38521. private _setButtonValue;
  38522. private _setDPadValue;
  38523. /**
  38524. * Gets the value of the `A` button
  38525. */
  38526. /**
  38527. * Sets the value of the `A` button
  38528. */
  38529. buttonA: number;
  38530. /**
  38531. * Gets the value of the `B` button
  38532. */
  38533. /**
  38534. * Sets the value of the `B` button
  38535. */
  38536. buttonB: number;
  38537. /**
  38538. * Gets the value of the `X` button
  38539. */
  38540. /**
  38541. * Sets the value of the `X` button
  38542. */
  38543. buttonX: number;
  38544. /**
  38545. * Gets the value of the `Y` button
  38546. */
  38547. /**
  38548. * Sets the value of the `Y` button
  38549. */
  38550. buttonY: number;
  38551. /**
  38552. * Gets the value of the `Start` button
  38553. */
  38554. /**
  38555. * Sets the value of the `Start` button
  38556. */
  38557. buttonStart: number;
  38558. /**
  38559. * Gets the value of the `Back` button
  38560. */
  38561. /**
  38562. * Sets the value of the `Back` button
  38563. */
  38564. buttonBack: number;
  38565. /**
  38566. * Gets the value of the `Left` button
  38567. */
  38568. /**
  38569. * Sets the value of the `Left` button
  38570. */
  38571. buttonLB: number;
  38572. /**
  38573. * Gets the value of the `Right` button
  38574. */
  38575. /**
  38576. * Sets the value of the `Right` button
  38577. */
  38578. buttonRB: number;
  38579. /**
  38580. * Gets the value of the Left joystick
  38581. */
  38582. /**
  38583. * Sets the value of the Left joystick
  38584. */
  38585. buttonLeftStick: number;
  38586. /**
  38587. * Gets the value of the Right joystick
  38588. */
  38589. /**
  38590. * Sets the value of the Right joystick
  38591. */
  38592. buttonRightStick: number;
  38593. /**
  38594. * Gets the value of D-pad up
  38595. */
  38596. /**
  38597. * Sets the value of D-pad up
  38598. */
  38599. dPadUp: number;
  38600. /**
  38601. * Gets the value of D-pad down
  38602. */
  38603. /**
  38604. * Sets the value of D-pad down
  38605. */
  38606. dPadDown: number;
  38607. /**
  38608. * Gets the value of D-pad left
  38609. */
  38610. /**
  38611. * Sets the value of D-pad left
  38612. */
  38613. dPadLeft: number;
  38614. /**
  38615. * Gets the value of D-pad right
  38616. */
  38617. /**
  38618. * Sets the value of D-pad right
  38619. */
  38620. dPadRight: number;
  38621. /**
  38622. * Force the gamepad to synchronize with device values
  38623. */
  38624. update(): void;
  38625. /**
  38626. * Disposes the gamepad
  38627. */
  38628. dispose(): void;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. /**
  38633. * Defines supported buttons for DualShock compatible gamepads
  38634. */
  38635. export enum DualShockButton {
  38636. /** Cross */
  38637. Cross = 0,
  38638. /** Circle */
  38639. Circle = 1,
  38640. /** Square */
  38641. Square = 2,
  38642. /** Triangle */
  38643. Triangle = 3,
  38644. /** Options */
  38645. Options = 4,
  38646. /** Share */
  38647. Share = 5,
  38648. /** L1 */
  38649. L1 = 6,
  38650. /** R1 */
  38651. R1 = 7,
  38652. /** Left stick */
  38653. LeftStick = 8,
  38654. /** Right stick */
  38655. RightStick = 9
  38656. }
  38657. /** Defines values for DualShock DPad */
  38658. export enum DualShockDpad {
  38659. /** Up */
  38660. Up = 0,
  38661. /** Down */
  38662. Down = 1,
  38663. /** Left */
  38664. Left = 2,
  38665. /** Right */
  38666. Right = 3
  38667. }
  38668. /**
  38669. * Defines a DualShock gamepad
  38670. */
  38671. export class DualShockPad extends Gamepad {
  38672. private _leftTrigger;
  38673. private _rightTrigger;
  38674. private _onlefttriggerchanged;
  38675. private _onrighttriggerchanged;
  38676. private _onbuttondown;
  38677. private _onbuttonup;
  38678. private _ondpaddown;
  38679. private _ondpadup;
  38680. /** Observable raised when a button is pressed */
  38681. onButtonDownObservable: Observable<DualShockButton>;
  38682. /** Observable raised when a button is released */
  38683. onButtonUpObservable: Observable<DualShockButton>;
  38684. /** Observable raised when a pad is pressed */
  38685. onPadDownObservable: Observable<DualShockDpad>;
  38686. /** Observable raised when a pad is released */
  38687. onPadUpObservable: Observable<DualShockDpad>;
  38688. private _buttonCross;
  38689. private _buttonCircle;
  38690. private _buttonSquare;
  38691. private _buttonTriangle;
  38692. private _buttonShare;
  38693. private _buttonOptions;
  38694. private _buttonL1;
  38695. private _buttonR1;
  38696. private _buttonLeftStick;
  38697. private _buttonRightStick;
  38698. private _dPadUp;
  38699. private _dPadDown;
  38700. private _dPadLeft;
  38701. private _dPadRight;
  38702. /**
  38703. * Creates a new DualShock gamepad object
  38704. * @param id defines the id of this gamepad
  38705. * @param index defines its index
  38706. * @param gamepad defines the internal HTML gamepad object
  38707. */
  38708. constructor(id: string, index: number, gamepad: any);
  38709. /**
  38710. * Defines the callback to call when left trigger is pressed
  38711. * @param callback defines the callback to use
  38712. */
  38713. onlefttriggerchanged(callback: (value: number) => void): void;
  38714. /**
  38715. * Defines the callback to call when right trigger is pressed
  38716. * @param callback defines the callback to use
  38717. */
  38718. onrighttriggerchanged(callback: (value: number) => void): void;
  38719. /**
  38720. * Gets the left trigger value
  38721. */
  38722. /**
  38723. * Sets the left trigger value
  38724. */
  38725. leftTrigger: number;
  38726. /**
  38727. * Gets the right trigger value
  38728. */
  38729. /**
  38730. * Sets the right trigger value
  38731. */
  38732. rightTrigger: number;
  38733. /**
  38734. * Defines the callback to call when a button is pressed
  38735. * @param callback defines the callback to use
  38736. */
  38737. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38738. /**
  38739. * Defines the callback to call when a button is released
  38740. * @param callback defines the callback to use
  38741. */
  38742. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38743. /**
  38744. * Defines the callback to call when a pad is pressed
  38745. * @param callback defines the callback to use
  38746. */
  38747. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38748. /**
  38749. * Defines the callback to call when a pad is released
  38750. * @param callback defines the callback to use
  38751. */
  38752. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38753. private _setButtonValue;
  38754. private _setDPadValue;
  38755. /**
  38756. * Gets the value of the `Cross` button
  38757. */
  38758. /**
  38759. * Sets the value of the `Cross` button
  38760. */
  38761. buttonCross: number;
  38762. /**
  38763. * Gets the value of the `Circle` button
  38764. */
  38765. /**
  38766. * Sets the value of the `Circle` button
  38767. */
  38768. buttonCircle: number;
  38769. /**
  38770. * Gets the value of the `Square` button
  38771. */
  38772. /**
  38773. * Sets the value of the `Square` button
  38774. */
  38775. buttonSquare: number;
  38776. /**
  38777. * Gets the value of the `Triangle` button
  38778. */
  38779. /**
  38780. * Sets the value of the `Triangle` button
  38781. */
  38782. buttonTriangle: number;
  38783. /**
  38784. * Gets the value of the `Options` button
  38785. */
  38786. /**
  38787. * Sets the value of the `Options` button
  38788. */
  38789. buttonOptions: number;
  38790. /**
  38791. * Gets the value of the `Share` button
  38792. */
  38793. /**
  38794. * Sets the value of the `Share` button
  38795. */
  38796. buttonShare: number;
  38797. /**
  38798. * Gets the value of the `L1` button
  38799. */
  38800. /**
  38801. * Sets the value of the `L1` button
  38802. */
  38803. buttonL1: number;
  38804. /**
  38805. * Gets the value of the `R1` button
  38806. */
  38807. /**
  38808. * Sets the value of the `R1` button
  38809. */
  38810. buttonR1: number;
  38811. /**
  38812. * Gets the value of the Left joystick
  38813. */
  38814. /**
  38815. * Sets the value of the Left joystick
  38816. */
  38817. buttonLeftStick: number;
  38818. /**
  38819. * Gets the value of the Right joystick
  38820. */
  38821. /**
  38822. * Sets the value of the Right joystick
  38823. */
  38824. buttonRightStick: number;
  38825. /**
  38826. * Gets the value of D-pad up
  38827. */
  38828. /**
  38829. * Sets the value of D-pad up
  38830. */
  38831. dPadUp: number;
  38832. /**
  38833. * Gets the value of D-pad down
  38834. */
  38835. /**
  38836. * Sets the value of D-pad down
  38837. */
  38838. dPadDown: number;
  38839. /**
  38840. * Gets the value of D-pad left
  38841. */
  38842. /**
  38843. * Sets the value of D-pad left
  38844. */
  38845. dPadLeft: number;
  38846. /**
  38847. * Gets the value of D-pad right
  38848. */
  38849. /**
  38850. * Sets the value of D-pad right
  38851. */
  38852. dPadRight: number;
  38853. /**
  38854. * Force the gamepad to synchronize with device values
  38855. */
  38856. update(): void;
  38857. /**
  38858. * Disposes the gamepad
  38859. */
  38860. dispose(): void;
  38861. }
  38862. }
  38863. declare module BABYLON {
  38864. /**
  38865. * Manager for handling gamepads
  38866. */
  38867. export class GamepadManager {
  38868. private _scene?;
  38869. private _babylonGamepads;
  38870. private _oneGamepadConnected;
  38871. /** @hidden */
  38872. _isMonitoring: boolean;
  38873. private _gamepadEventSupported;
  38874. private _gamepadSupport;
  38875. /**
  38876. * observable to be triggered when the gamepad controller has been connected
  38877. */
  38878. onGamepadConnectedObservable: Observable<Gamepad>;
  38879. /**
  38880. * observable to be triggered when the gamepad controller has been disconnected
  38881. */
  38882. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38883. private _onGamepadConnectedEvent;
  38884. private _onGamepadDisconnectedEvent;
  38885. /**
  38886. * Initializes the gamepad manager
  38887. * @param _scene BabylonJS scene
  38888. */
  38889. constructor(_scene?: Scene | undefined);
  38890. /**
  38891. * The gamepads in the game pad manager
  38892. */
  38893. readonly gamepads: Gamepad[];
  38894. /**
  38895. * Get the gamepad controllers based on type
  38896. * @param type The type of gamepad controller
  38897. * @returns Nullable gamepad
  38898. */
  38899. getGamepadByType(type?: number): Nullable<Gamepad>;
  38900. /**
  38901. * Disposes the gamepad manager
  38902. */
  38903. dispose(): void;
  38904. private _addNewGamepad;
  38905. private _startMonitoringGamepads;
  38906. private _stopMonitoringGamepads;
  38907. /** @hidden */
  38908. _checkGamepadsStatus(): void;
  38909. private _updateGamepadObjects;
  38910. }
  38911. }
  38912. declare module BABYLON {
  38913. interface Scene {
  38914. /** @hidden */
  38915. _gamepadManager: Nullable<GamepadManager>;
  38916. /**
  38917. * Gets the gamepad manager associated with the scene
  38918. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38919. */
  38920. gamepadManager: GamepadManager;
  38921. }
  38922. /**
  38923. * Interface representing a free camera inputs manager
  38924. */
  38925. interface FreeCameraInputsManager {
  38926. /**
  38927. * Adds gamepad input support to the FreeCameraInputsManager.
  38928. * @returns the FreeCameraInputsManager
  38929. */
  38930. addGamepad(): FreeCameraInputsManager;
  38931. }
  38932. /**
  38933. * Interface representing an arc rotate camera inputs manager
  38934. */
  38935. interface ArcRotateCameraInputsManager {
  38936. /**
  38937. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38938. * @returns the camera inputs manager
  38939. */
  38940. addGamepad(): ArcRotateCameraInputsManager;
  38941. }
  38942. /**
  38943. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38944. */
  38945. export class GamepadSystemSceneComponent implements ISceneComponent {
  38946. /**
  38947. * The component name helpfull to identify the component in the list of scene components.
  38948. */
  38949. readonly name: string;
  38950. /**
  38951. * The scene the component belongs to.
  38952. */
  38953. scene: Scene;
  38954. /**
  38955. * Creates a new instance of the component for the given scene
  38956. * @param scene Defines the scene to register the component in
  38957. */
  38958. constructor(scene: Scene);
  38959. /**
  38960. * Registers the component in a given scene
  38961. */
  38962. register(): void;
  38963. /**
  38964. * Rebuilds the elements related to this component in case of
  38965. * context lost for instance.
  38966. */
  38967. rebuild(): void;
  38968. /**
  38969. * Disposes the component and the associated ressources
  38970. */
  38971. dispose(): void;
  38972. private _beforeCameraUpdate;
  38973. }
  38974. }
  38975. declare module BABYLON {
  38976. /**
  38977. * 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,
  38978. * which still works and will still be found in many Playgrounds.
  38979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38980. */
  38981. export class UniversalCamera extends TouchCamera {
  38982. /**
  38983. * Defines the gamepad rotation sensiblity.
  38984. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38985. */
  38986. gamepadAngularSensibility: number;
  38987. /**
  38988. * Defines the gamepad move sensiblity.
  38989. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38990. */
  38991. gamepadMoveSensibility: number;
  38992. /**
  38993. * 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,
  38994. * which still works and will still be found in many Playgrounds.
  38995. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38996. * @param name Define the name of the camera in the scene
  38997. * @param position Define the start position of the camera in the scene
  38998. * @param scene Define the scene the camera belongs to
  38999. */
  39000. constructor(name: string, position: Vector3, scene: Scene);
  39001. /**
  39002. * Gets the current object class name.
  39003. * @return the class name
  39004. */
  39005. getClassName(): string;
  39006. }
  39007. }
  39008. declare module BABYLON {
  39009. /**
  39010. * This represents a FPS type of camera. This is only here for back compat purpose.
  39011. * Please use the UniversalCamera instead as both are identical.
  39012. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39013. */
  39014. export class GamepadCamera extends UniversalCamera {
  39015. /**
  39016. * Instantiates a new Gamepad Camera
  39017. * This represents a FPS type of camera. This is only here for back compat purpose.
  39018. * Please use the UniversalCamera instead as both are identical.
  39019. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39020. * @param name Define the name of the camera in the scene
  39021. * @param position Define the start position of the camera in the scene
  39022. * @param scene Define the scene the camera belongs to
  39023. */
  39024. constructor(name: string, position: Vector3, scene: Scene);
  39025. /**
  39026. * Gets the current object class name.
  39027. * @return the class name
  39028. */
  39029. getClassName(): string;
  39030. }
  39031. }
  39032. declare module BABYLON {
  39033. /** @hidden */
  39034. export var passPixelShader: {
  39035. name: string;
  39036. shader: string;
  39037. };
  39038. }
  39039. declare module BABYLON {
  39040. /** @hidden */
  39041. export var passCubePixelShader: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module BABYLON {
  39047. /**
  39048. * PassPostProcess which produces an output the same as it's input
  39049. */
  39050. export class PassPostProcess extends PostProcess {
  39051. /**
  39052. * Creates the PassPostProcess
  39053. * @param name The name of the effect.
  39054. * @param options The required width/height ratio to downsize to before computing the render pass.
  39055. * @param camera The camera to apply the render pass to.
  39056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39057. * @param engine The engine which the post process will be applied. (default: current engine)
  39058. * @param reusable If the post process can be reused on the same frame. (default: false)
  39059. * @param textureType The type of texture to be used when performing the post processing.
  39060. * @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)
  39061. */
  39062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39063. }
  39064. /**
  39065. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39066. */
  39067. export class PassCubePostProcess extends PostProcess {
  39068. private _face;
  39069. /**
  39070. * Gets or sets the cube face to display.
  39071. * * 0 is +X
  39072. * * 1 is -X
  39073. * * 2 is +Y
  39074. * * 3 is -Y
  39075. * * 4 is +Z
  39076. * * 5 is -Z
  39077. */
  39078. face: number;
  39079. /**
  39080. * Creates the PassCubePostProcess
  39081. * @param name The name of the effect.
  39082. * @param options The required width/height ratio to downsize to before computing the render pass.
  39083. * @param camera The camera to apply the render pass to.
  39084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39085. * @param engine The engine which the post process will be applied. (default: current engine)
  39086. * @param reusable If the post process can be reused on the same frame. (default: false)
  39087. * @param textureType The type of texture to be used when performing the post processing.
  39088. * @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)
  39089. */
  39090. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39091. }
  39092. }
  39093. declare module BABYLON {
  39094. /** @hidden */
  39095. export var anaglyphPixelShader: {
  39096. name: string;
  39097. shader: string;
  39098. };
  39099. }
  39100. declare module BABYLON {
  39101. /**
  39102. * Postprocess used to generate anaglyphic rendering
  39103. */
  39104. export class AnaglyphPostProcess extends PostProcess {
  39105. private _passedProcess;
  39106. /**
  39107. * Creates a new AnaglyphPostProcess
  39108. * @param name defines postprocess name
  39109. * @param options defines creation options or target ratio scale
  39110. * @param rigCameras defines cameras using this postprocess
  39111. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39112. * @param engine defines hosting engine
  39113. * @param reusable defines if the postprocess will be reused multiple times per frame
  39114. */
  39115. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39116. }
  39117. }
  39118. declare module BABYLON {
  39119. /**
  39120. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39121. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39122. */
  39123. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39124. /**
  39125. * Creates a new AnaglyphArcRotateCamera
  39126. * @param name defines camera name
  39127. * @param alpha defines alpha angle (in radians)
  39128. * @param beta defines beta angle (in radians)
  39129. * @param radius defines radius
  39130. * @param target defines camera target
  39131. * @param interaxialDistance defines distance between each color axis
  39132. * @param scene defines the hosting scene
  39133. */
  39134. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39135. /**
  39136. * Gets camera class name
  39137. * @returns AnaglyphArcRotateCamera
  39138. */
  39139. getClassName(): string;
  39140. }
  39141. }
  39142. declare module BABYLON {
  39143. /**
  39144. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39145. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39146. */
  39147. export class AnaglyphFreeCamera extends FreeCamera {
  39148. /**
  39149. * Creates a new AnaglyphFreeCamera
  39150. * @param name defines camera name
  39151. * @param position defines initial position
  39152. * @param interaxialDistance defines distance between each color axis
  39153. * @param scene defines the hosting scene
  39154. */
  39155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39156. /**
  39157. * Gets camera class name
  39158. * @returns AnaglyphFreeCamera
  39159. */
  39160. getClassName(): string;
  39161. }
  39162. }
  39163. declare module BABYLON {
  39164. /**
  39165. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39166. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39167. */
  39168. export class AnaglyphGamepadCamera extends GamepadCamera {
  39169. /**
  39170. * Creates a new AnaglyphGamepadCamera
  39171. * @param name defines camera name
  39172. * @param position defines initial position
  39173. * @param interaxialDistance defines distance between each color axis
  39174. * @param scene defines the hosting scene
  39175. */
  39176. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39177. /**
  39178. * Gets camera class name
  39179. * @returns AnaglyphGamepadCamera
  39180. */
  39181. getClassName(): string;
  39182. }
  39183. }
  39184. declare module BABYLON {
  39185. /**
  39186. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39187. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39188. */
  39189. export class AnaglyphUniversalCamera extends UniversalCamera {
  39190. /**
  39191. * Creates a new AnaglyphUniversalCamera
  39192. * @param name defines camera name
  39193. * @param position defines initial position
  39194. * @param interaxialDistance defines distance between each color axis
  39195. * @param scene defines the hosting scene
  39196. */
  39197. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39198. /**
  39199. * Gets camera class name
  39200. * @returns AnaglyphUniversalCamera
  39201. */
  39202. getClassName(): string;
  39203. }
  39204. }
  39205. declare module BABYLON {
  39206. /** @hidden */
  39207. export var stereoscopicInterlacePixelShader: {
  39208. name: string;
  39209. shader: string;
  39210. };
  39211. }
  39212. declare module BABYLON {
  39213. /**
  39214. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39215. */
  39216. export class StereoscopicInterlacePostProcess extends PostProcess {
  39217. private _stepSize;
  39218. private _passedProcess;
  39219. /**
  39220. * Initializes a StereoscopicInterlacePostProcess
  39221. * @param name The name of the effect.
  39222. * @param rigCameras The rig cameras to be appled to the post process
  39223. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39225. * @param engine The engine which the post process will be applied. (default: current engine)
  39226. * @param reusable If the post process can be reused on the same frame. (default: false)
  39227. */
  39228. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39229. }
  39230. }
  39231. declare module BABYLON {
  39232. /**
  39233. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39234. * @see http://doc.babylonjs.com/features/cameras
  39235. */
  39236. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39237. /**
  39238. * Creates a new StereoscopicArcRotateCamera
  39239. * @param name defines camera name
  39240. * @param alpha defines alpha angle (in radians)
  39241. * @param beta defines beta angle (in radians)
  39242. * @param radius defines radius
  39243. * @param target defines camera target
  39244. * @param interaxialDistance defines distance between each color axis
  39245. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39246. * @param scene defines the hosting scene
  39247. */
  39248. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39249. /**
  39250. * Gets camera class name
  39251. * @returns StereoscopicArcRotateCamera
  39252. */
  39253. getClassName(): string;
  39254. }
  39255. }
  39256. declare module BABYLON {
  39257. /**
  39258. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39259. * @see http://doc.babylonjs.com/features/cameras
  39260. */
  39261. export class StereoscopicFreeCamera extends FreeCamera {
  39262. /**
  39263. * Creates a new StereoscopicFreeCamera
  39264. * @param name defines camera name
  39265. * @param position defines initial position
  39266. * @param interaxialDistance defines distance between each color axis
  39267. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39268. * @param scene defines the hosting scene
  39269. */
  39270. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39271. /**
  39272. * Gets camera class name
  39273. * @returns StereoscopicFreeCamera
  39274. */
  39275. getClassName(): string;
  39276. }
  39277. }
  39278. declare module BABYLON {
  39279. /**
  39280. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39281. * @see http://doc.babylonjs.com/features/cameras
  39282. */
  39283. export class StereoscopicGamepadCamera extends GamepadCamera {
  39284. /**
  39285. * Creates a new StereoscopicGamepadCamera
  39286. * @param name defines camera name
  39287. * @param position defines initial position
  39288. * @param interaxialDistance defines distance between each color axis
  39289. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39290. * @param scene defines the hosting scene
  39291. */
  39292. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39293. /**
  39294. * Gets camera class name
  39295. * @returns StereoscopicGamepadCamera
  39296. */
  39297. getClassName(): string;
  39298. }
  39299. }
  39300. declare module BABYLON {
  39301. /**
  39302. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39303. * @see http://doc.babylonjs.com/features/cameras
  39304. */
  39305. export class StereoscopicUniversalCamera extends UniversalCamera {
  39306. /**
  39307. * Creates a new StereoscopicUniversalCamera
  39308. * @param name defines camera name
  39309. * @param position defines initial position
  39310. * @param interaxialDistance defines distance between each color axis
  39311. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39312. * @param scene defines the hosting scene
  39313. */
  39314. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39315. /**
  39316. * Gets camera class name
  39317. * @returns StereoscopicUniversalCamera
  39318. */
  39319. getClassName(): string;
  39320. }
  39321. }
  39322. declare module BABYLON {
  39323. /**
  39324. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39325. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39326. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39327. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39328. */
  39329. export class VirtualJoysticksCamera extends FreeCamera {
  39330. /**
  39331. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39332. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39333. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39334. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39335. * @param name Define the name of the camera in the scene
  39336. * @param position Define the start position of the camera in the scene
  39337. * @param scene Define the scene the camera belongs to
  39338. */
  39339. constructor(name: string, position: Vector3, scene: Scene);
  39340. /**
  39341. * Gets the current object class name.
  39342. * @return the class name
  39343. */
  39344. getClassName(): string;
  39345. }
  39346. }
  39347. declare module BABYLON {
  39348. /**
  39349. * This represents all the required metrics to create a VR camera.
  39350. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39351. */
  39352. export class VRCameraMetrics {
  39353. /**
  39354. * Define the horizontal resolution off the screen.
  39355. */
  39356. hResolution: number;
  39357. /**
  39358. * Define the vertical resolution off the screen.
  39359. */
  39360. vResolution: number;
  39361. /**
  39362. * Define the horizontal screen size.
  39363. */
  39364. hScreenSize: number;
  39365. /**
  39366. * Define the vertical screen size.
  39367. */
  39368. vScreenSize: number;
  39369. /**
  39370. * Define the vertical screen center position.
  39371. */
  39372. vScreenCenter: number;
  39373. /**
  39374. * Define the distance of the eyes to the screen.
  39375. */
  39376. eyeToScreenDistance: number;
  39377. /**
  39378. * Define the distance between both lenses
  39379. */
  39380. lensSeparationDistance: number;
  39381. /**
  39382. * Define the distance between both viewer's eyes.
  39383. */
  39384. interpupillaryDistance: number;
  39385. /**
  39386. * Define the distortion factor of the VR postprocess.
  39387. * Please, touch with care.
  39388. */
  39389. distortionK: number[];
  39390. /**
  39391. * Define the chromatic aberration correction factors for the VR post process.
  39392. */
  39393. chromaAbCorrection: number[];
  39394. /**
  39395. * Define the scale factor of the post process.
  39396. * The smaller the better but the slower.
  39397. */
  39398. postProcessScaleFactor: number;
  39399. /**
  39400. * Define an offset for the lens center.
  39401. */
  39402. lensCenterOffset: number;
  39403. /**
  39404. * Define if the current vr camera should compensate the distortion of the lense or not.
  39405. */
  39406. compensateDistortion: boolean;
  39407. /**
  39408. * Defines if multiview should be enabled when rendering (Default: false)
  39409. */
  39410. multiviewEnabled: boolean;
  39411. /**
  39412. * Gets the rendering aspect ratio based on the provided resolutions.
  39413. */
  39414. readonly aspectRatio: number;
  39415. /**
  39416. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39417. */
  39418. readonly aspectRatioFov: number;
  39419. /**
  39420. * @hidden
  39421. */
  39422. readonly leftHMatrix: Matrix;
  39423. /**
  39424. * @hidden
  39425. */
  39426. readonly rightHMatrix: Matrix;
  39427. /**
  39428. * @hidden
  39429. */
  39430. readonly leftPreViewMatrix: Matrix;
  39431. /**
  39432. * @hidden
  39433. */
  39434. readonly rightPreViewMatrix: Matrix;
  39435. /**
  39436. * Get the default VRMetrics based on the most generic setup.
  39437. * @returns the default vr metrics
  39438. */
  39439. static GetDefault(): VRCameraMetrics;
  39440. }
  39441. }
  39442. declare module BABYLON {
  39443. /** @hidden */
  39444. export var vrDistortionCorrectionPixelShader: {
  39445. name: string;
  39446. shader: string;
  39447. };
  39448. }
  39449. declare module BABYLON {
  39450. /**
  39451. * VRDistortionCorrectionPostProcess used for mobile VR
  39452. */
  39453. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39454. private _isRightEye;
  39455. private _distortionFactors;
  39456. private _postProcessScaleFactor;
  39457. private _lensCenterOffset;
  39458. private _scaleIn;
  39459. private _scaleFactor;
  39460. private _lensCenter;
  39461. /**
  39462. * Initializes the VRDistortionCorrectionPostProcess
  39463. * @param name The name of the effect.
  39464. * @param camera The camera to apply the render pass to.
  39465. * @param isRightEye If this is for the right eye distortion
  39466. * @param vrMetrics All the required metrics for the VR camera
  39467. */
  39468. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39469. }
  39470. }
  39471. declare module BABYLON {
  39472. /**
  39473. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39474. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39475. */
  39476. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39477. /**
  39478. * Creates a new VRDeviceOrientationArcRotateCamera
  39479. * @param name defines camera name
  39480. * @param alpha defines the camera rotation along the logitudinal axis
  39481. * @param beta defines the camera rotation along the latitudinal axis
  39482. * @param radius defines the camera distance from its target
  39483. * @param target defines the camera target
  39484. * @param scene defines the scene the camera belongs to
  39485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39487. */
  39488. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39489. /**
  39490. * Gets camera class name
  39491. * @returns VRDeviceOrientationArcRotateCamera
  39492. */
  39493. getClassName(): string;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Camera used to simulate VR rendering (based on FreeCamera)
  39499. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39500. */
  39501. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39502. /**
  39503. * Creates a new VRDeviceOrientationFreeCamera
  39504. * @param name defines camera name
  39505. * @param position defines the start position of the camera
  39506. * @param scene defines the scene the camera belongs to
  39507. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39508. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39509. */
  39510. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39511. /**
  39512. * Gets camera class name
  39513. * @returns VRDeviceOrientationFreeCamera
  39514. */
  39515. getClassName(): string;
  39516. }
  39517. }
  39518. declare module BABYLON {
  39519. /**
  39520. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39521. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39522. */
  39523. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39524. /**
  39525. * Creates a new VRDeviceOrientationGamepadCamera
  39526. * @param name defines camera name
  39527. * @param position defines the start position of the camera
  39528. * @param scene defines the scene the camera belongs to
  39529. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39530. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39531. */
  39532. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39533. /**
  39534. * Gets camera class name
  39535. * @returns VRDeviceOrientationGamepadCamera
  39536. */
  39537. getClassName(): string;
  39538. }
  39539. }
  39540. declare module BABYLON {
  39541. /**
  39542. * Base class of materials working in push mode in babylon JS
  39543. * @hidden
  39544. */
  39545. export class PushMaterial extends Material {
  39546. protected _activeEffect: Effect;
  39547. protected _normalMatrix: Matrix;
  39548. /**
  39549. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39550. * This means that the material can keep using a previous shader while a new one is being compiled.
  39551. * This is mostly used when shader parallel compilation is supported (true by default)
  39552. */
  39553. allowShaderHotSwapping: boolean;
  39554. constructor(name: string, scene: Scene);
  39555. getEffect(): Effect;
  39556. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39557. /**
  39558. * Binds the given world matrix to the active effect
  39559. *
  39560. * @param world the matrix to bind
  39561. */
  39562. bindOnlyWorldMatrix(world: Matrix): void;
  39563. /**
  39564. * Binds the given normal matrix to the active effect
  39565. *
  39566. * @param normalMatrix the matrix to bind
  39567. */
  39568. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39569. bind(world: Matrix, mesh?: Mesh): void;
  39570. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39571. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39572. }
  39573. }
  39574. declare module BABYLON {
  39575. /**
  39576. * This groups all the flags used to control the materials channel.
  39577. */
  39578. export class MaterialFlags {
  39579. private static _DiffuseTextureEnabled;
  39580. /**
  39581. * Are diffuse textures enabled in the application.
  39582. */
  39583. static DiffuseTextureEnabled: boolean;
  39584. private static _AmbientTextureEnabled;
  39585. /**
  39586. * Are ambient textures enabled in the application.
  39587. */
  39588. static AmbientTextureEnabled: boolean;
  39589. private static _OpacityTextureEnabled;
  39590. /**
  39591. * Are opacity textures enabled in the application.
  39592. */
  39593. static OpacityTextureEnabled: boolean;
  39594. private static _ReflectionTextureEnabled;
  39595. /**
  39596. * Are reflection textures enabled in the application.
  39597. */
  39598. static ReflectionTextureEnabled: boolean;
  39599. private static _EmissiveTextureEnabled;
  39600. /**
  39601. * Are emissive textures enabled in the application.
  39602. */
  39603. static EmissiveTextureEnabled: boolean;
  39604. private static _SpecularTextureEnabled;
  39605. /**
  39606. * Are specular textures enabled in the application.
  39607. */
  39608. static SpecularTextureEnabled: boolean;
  39609. private static _BumpTextureEnabled;
  39610. /**
  39611. * Are bump textures enabled in the application.
  39612. */
  39613. static BumpTextureEnabled: boolean;
  39614. private static _LightmapTextureEnabled;
  39615. /**
  39616. * Are lightmap textures enabled in the application.
  39617. */
  39618. static LightmapTextureEnabled: boolean;
  39619. private static _RefractionTextureEnabled;
  39620. /**
  39621. * Are refraction textures enabled in the application.
  39622. */
  39623. static RefractionTextureEnabled: boolean;
  39624. private static _ColorGradingTextureEnabled;
  39625. /**
  39626. * Are color grading textures enabled in the application.
  39627. */
  39628. static ColorGradingTextureEnabled: boolean;
  39629. private static _FresnelEnabled;
  39630. /**
  39631. * Are fresnels enabled in the application.
  39632. */
  39633. static FresnelEnabled: boolean;
  39634. private static _ClearCoatTextureEnabled;
  39635. /**
  39636. * Are clear coat textures enabled in the application.
  39637. */
  39638. static ClearCoatTextureEnabled: boolean;
  39639. private static _ClearCoatBumpTextureEnabled;
  39640. /**
  39641. * Are clear coat bump textures enabled in the application.
  39642. */
  39643. static ClearCoatBumpTextureEnabled: boolean;
  39644. private static _ClearCoatTintTextureEnabled;
  39645. /**
  39646. * Are clear coat tint textures enabled in the application.
  39647. */
  39648. static ClearCoatTintTextureEnabled: boolean;
  39649. private static _SheenTextureEnabled;
  39650. /**
  39651. * Are sheen textures enabled in the application.
  39652. */
  39653. static SheenTextureEnabled: boolean;
  39654. private static _AnisotropicTextureEnabled;
  39655. /**
  39656. * Are anisotropic textures enabled in the application.
  39657. */
  39658. static AnisotropicTextureEnabled: boolean;
  39659. private static _ThicknessTextureEnabled;
  39660. /**
  39661. * Are thickness textures enabled in the application.
  39662. */
  39663. static ThicknessTextureEnabled: boolean;
  39664. }
  39665. }
  39666. declare module BABYLON {
  39667. /** @hidden */
  39668. export var defaultFragmentDeclaration: {
  39669. name: string;
  39670. shader: string;
  39671. };
  39672. }
  39673. declare module BABYLON {
  39674. /** @hidden */
  39675. export var defaultUboDeclaration: {
  39676. name: string;
  39677. shader: string;
  39678. };
  39679. }
  39680. declare module BABYLON {
  39681. /** @hidden */
  39682. export var lightFragmentDeclaration: {
  39683. name: string;
  39684. shader: string;
  39685. };
  39686. }
  39687. declare module BABYLON {
  39688. /** @hidden */
  39689. export var lightUboDeclaration: {
  39690. name: string;
  39691. shader: string;
  39692. };
  39693. }
  39694. declare module BABYLON {
  39695. /** @hidden */
  39696. export var lightsFragmentFunctions: {
  39697. name: string;
  39698. shader: string;
  39699. };
  39700. }
  39701. declare module BABYLON {
  39702. /** @hidden */
  39703. export var shadowsFragmentFunctions: {
  39704. name: string;
  39705. shader: string;
  39706. };
  39707. }
  39708. declare module BABYLON {
  39709. /** @hidden */
  39710. export var fresnelFunction: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module BABYLON {
  39716. /** @hidden */
  39717. export var reflectionFunction: {
  39718. name: string;
  39719. shader: string;
  39720. };
  39721. }
  39722. declare module BABYLON {
  39723. /** @hidden */
  39724. export var bumpFragmentFunctions: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module BABYLON {
  39730. /** @hidden */
  39731. export var logDepthDeclaration: {
  39732. name: string;
  39733. shader: string;
  39734. };
  39735. }
  39736. declare module BABYLON {
  39737. /** @hidden */
  39738. export var bumpFragment: {
  39739. name: string;
  39740. shader: string;
  39741. };
  39742. }
  39743. declare module BABYLON {
  39744. /** @hidden */
  39745. export var depthPrePass: {
  39746. name: string;
  39747. shader: string;
  39748. };
  39749. }
  39750. declare module BABYLON {
  39751. /** @hidden */
  39752. export var lightFragment: {
  39753. name: string;
  39754. shader: string;
  39755. };
  39756. }
  39757. declare module BABYLON {
  39758. /** @hidden */
  39759. export var logDepthFragment: {
  39760. name: string;
  39761. shader: string;
  39762. };
  39763. }
  39764. declare module BABYLON {
  39765. /** @hidden */
  39766. export var defaultPixelShader: {
  39767. name: string;
  39768. shader: string;
  39769. };
  39770. }
  39771. declare module BABYLON {
  39772. /** @hidden */
  39773. export var defaultVertexDeclaration: {
  39774. name: string;
  39775. shader: string;
  39776. };
  39777. }
  39778. declare module BABYLON {
  39779. /** @hidden */
  39780. export var bumpVertexDeclaration: {
  39781. name: string;
  39782. shader: string;
  39783. };
  39784. }
  39785. declare module BABYLON {
  39786. /** @hidden */
  39787. export var bumpVertex: {
  39788. name: string;
  39789. shader: string;
  39790. };
  39791. }
  39792. declare module BABYLON {
  39793. /** @hidden */
  39794. export var fogVertex: {
  39795. name: string;
  39796. shader: string;
  39797. };
  39798. }
  39799. declare module BABYLON {
  39800. /** @hidden */
  39801. export var shadowsVertex: {
  39802. name: string;
  39803. shader: string;
  39804. };
  39805. }
  39806. declare module BABYLON {
  39807. /** @hidden */
  39808. export var pointCloudVertex: {
  39809. name: string;
  39810. shader: string;
  39811. };
  39812. }
  39813. declare module BABYLON {
  39814. /** @hidden */
  39815. export var logDepthVertex: {
  39816. name: string;
  39817. shader: string;
  39818. };
  39819. }
  39820. declare module BABYLON {
  39821. /** @hidden */
  39822. export var defaultVertexShader: {
  39823. name: string;
  39824. shader: string;
  39825. };
  39826. }
  39827. declare module BABYLON {
  39828. /** @hidden */
  39829. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39830. MAINUV1: boolean;
  39831. MAINUV2: boolean;
  39832. DIFFUSE: boolean;
  39833. DIFFUSEDIRECTUV: number;
  39834. AMBIENT: boolean;
  39835. AMBIENTDIRECTUV: number;
  39836. OPACITY: boolean;
  39837. OPACITYDIRECTUV: number;
  39838. OPACITYRGB: boolean;
  39839. REFLECTION: boolean;
  39840. EMISSIVE: boolean;
  39841. EMISSIVEDIRECTUV: number;
  39842. SPECULAR: boolean;
  39843. SPECULARDIRECTUV: number;
  39844. BUMP: boolean;
  39845. BUMPDIRECTUV: number;
  39846. PARALLAX: boolean;
  39847. PARALLAXOCCLUSION: boolean;
  39848. SPECULAROVERALPHA: boolean;
  39849. CLIPPLANE: boolean;
  39850. CLIPPLANE2: boolean;
  39851. CLIPPLANE3: boolean;
  39852. CLIPPLANE4: boolean;
  39853. ALPHATEST: boolean;
  39854. DEPTHPREPASS: boolean;
  39855. ALPHAFROMDIFFUSE: boolean;
  39856. POINTSIZE: boolean;
  39857. FOG: boolean;
  39858. SPECULARTERM: boolean;
  39859. DIFFUSEFRESNEL: boolean;
  39860. OPACITYFRESNEL: boolean;
  39861. REFLECTIONFRESNEL: boolean;
  39862. REFRACTIONFRESNEL: boolean;
  39863. EMISSIVEFRESNEL: boolean;
  39864. FRESNEL: boolean;
  39865. NORMAL: boolean;
  39866. UV1: boolean;
  39867. UV2: boolean;
  39868. VERTEXCOLOR: boolean;
  39869. VERTEXALPHA: boolean;
  39870. NUM_BONE_INFLUENCERS: number;
  39871. BonesPerMesh: number;
  39872. BONETEXTURE: boolean;
  39873. INSTANCES: boolean;
  39874. GLOSSINESS: boolean;
  39875. ROUGHNESS: boolean;
  39876. EMISSIVEASILLUMINATION: boolean;
  39877. LINKEMISSIVEWITHDIFFUSE: boolean;
  39878. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39879. LIGHTMAP: boolean;
  39880. LIGHTMAPDIRECTUV: number;
  39881. OBJECTSPACE_NORMALMAP: boolean;
  39882. USELIGHTMAPASSHADOWMAP: boolean;
  39883. REFLECTIONMAP_3D: boolean;
  39884. REFLECTIONMAP_SPHERICAL: boolean;
  39885. REFLECTIONMAP_PLANAR: boolean;
  39886. REFLECTIONMAP_CUBIC: boolean;
  39887. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39888. REFLECTIONMAP_PROJECTION: boolean;
  39889. REFLECTIONMAP_SKYBOX: boolean;
  39890. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39891. REFLECTIONMAP_EXPLICIT: boolean;
  39892. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39893. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39894. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39895. INVERTCUBICMAP: boolean;
  39896. LOGARITHMICDEPTH: boolean;
  39897. REFRACTION: boolean;
  39898. REFRACTIONMAP_3D: boolean;
  39899. REFLECTIONOVERALPHA: boolean;
  39900. TWOSIDEDLIGHTING: boolean;
  39901. SHADOWFLOAT: boolean;
  39902. MORPHTARGETS: boolean;
  39903. MORPHTARGETS_NORMAL: boolean;
  39904. MORPHTARGETS_TANGENT: boolean;
  39905. MORPHTARGETS_UV: boolean;
  39906. NUM_MORPH_INFLUENCERS: number;
  39907. NONUNIFORMSCALING: boolean;
  39908. PREMULTIPLYALPHA: boolean;
  39909. IMAGEPROCESSING: boolean;
  39910. VIGNETTE: boolean;
  39911. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39912. VIGNETTEBLENDMODEOPAQUE: boolean;
  39913. TONEMAPPING: boolean;
  39914. TONEMAPPING_ACES: boolean;
  39915. CONTRAST: boolean;
  39916. COLORCURVES: boolean;
  39917. COLORGRADING: boolean;
  39918. COLORGRADING3D: boolean;
  39919. SAMPLER3DGREENDEPTH: boolean;
  39920. SAMPLER3DBGRMAP: boolean;
  39921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39922. MULTIVIEW: boolean;
  39923. /**
  39924. * If the reflection texture on this material is in linear color space
  39925. * @hidden
  39926. */
  39927. IS_REFLECTION_LINEAR: boolean;
  39928. /**
  39929. * If the refraction texture on this material is in linear color space
  39930. * @hidden
  39931. */
  39932. IS_REFRACTION_LINEAR: boolean;
  39933. EXPOSURE: boolean;
  39934. constructor();
  39935. setReflectionMode(modeToEnable: string): void;
  39936. }
  39937. /**
  39938. * This is the default material used in Babylon. It is the best trade off between quality
  39939. * and performances.
  39940. * @see http://doc.babylonjs.com/babylon101/materials
  39941. */
  39942. export class StandardMaterial extends PushMaterial {
  39943. private _diffuseTexture;
  39944. /**
  39945. * The basic texture of the material as viewed under a light.
  39946. */
  39947. diffuseTexture: Nullable<BaseTexture>;
  39948. private _ambientTexture;
  39949. /**
  39950. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39951. */
  39952. ambientTexture: Nullable<BaseTexture>;
  39953. private _opacityTexture;
  39954. /**
  39955. * Define the transparency of the material from a texture.
  39956. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39957. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39958. */
  39959. opacityTexture: Nullable<BaseTexture>;
  39960. private _reflectionTexture;
  39961. /**
  39962. * Define the texture used to display the reflection.
  39963. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39964. */
  39965. reflectionTexture: Nullable<BaseTexture>;
  39966. private _emissiveTexture;
  39967. /**
  39968. * Define texture of the material as if self lit.
  39969. * This will be mixed in the final result even in the absence of light.
  39970. */
  39971. emissiveTexture: Nullable<BaseTexture>;
  39972. private _specularTexture;
  39973. /**
  39974. * Define how the color and intensity of the highlight given by the light in the material.
  39975. */
  39976. specularTexture: Nullable<BaseTexture>;
  39977. private _bumpTexture;
  39978. /**
  39979. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39980. * 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.
  39981. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39982. */
  39983. bumpTexture: Nullable<BaseTexture>;
  39984. private _lightmapTexture;
  39985. /**
  39986. * Complex lighting can be computationally expensive to compute at runtime.
  39987. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39988. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39989. */
  39990. lightmapTexture: Nullable<BaseTexture>;
  39991. private _refractionTexture;
  39992. /**
  39993. * Define the texture used to display the refraction.
  39994. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39995. */
  39996. refractionTexture: Nullable<BaseTexture>;
  39997. /**
  39998. * The color of the material lit by the environmental background lighting.
  39999. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40000. */
  40001. ambientColor: Color3;
  40002. /**
  40003. * The basic color of the material as viewed under a light.
  40004. */
  40005. diffuseColor: Color3;
  40006. /**
  40007. * Define how the color and intensity of the highlight given by the light in the material.
  40008. */
  40009. specularColor: Color3;
  40010. /**
  40011. * Define the color of the material as if self lit.
  40012. * This will be mixed in the final result even in the absence of light.
  40013. */
  40014. emissiveColor: Color3;
  40015. /**
  40016. * Defines how sharp are the highlights in the material.
  40017. * The bigger the value the sharper giving a more glossy feeling to the result.
  40018. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40019. */
  40020. specularPower: number;
  40021. private _useAlphaFromDiffuseTexture;
  40022. /**
  40023. * Does the transparency come from the diffuse texture alpha channel.
  40024. */
  40025. useAlphaFromDiffuseTexture: boolean;
  40026. private _useEmissiveAsIllumination;
  40027. /**
  40028. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40029. */
  40030. useEmissiveAsIllumination: boolean;
  40031. private _linkEmissiveWithDiffuse;
  40032. /**
  40033. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40034. * the emissive level when the final color is close to one.
  40035. */
  40036. linkEmissiveWithDiffuse: boolean;
  40037. private _useSpecularOverAlpha;
  40038. /**
  40039. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40040. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40041. */
  40042. useSpecularOverAlpha: boolean;
  40043. private _useReflectionOverAlpha;
  40044. /**
  40045. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40046. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40047. */
  40048. useReflectionOverAlpha: boolean;
  40049. private _disableLighting;
  40050. /**
  40051. * Does lights from the scene impacts this material.
  40052. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40053. */
  40054. disableLighting: boolean;
  40055. private _useObjectSpaceNormalMap;
  40056. /**
  40057. * Allows using an object space normal map (instead of tangent space).
  40058. */
  40059. useObjectSpaceNormalMap: boolean;
  40060. private _useParallax;
  40061. /**
  40062. * Is parallax enabled or not.
  40063. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40064. */
  40065. useParallax: boolean;
  40066. private _useParallaxOcclusion;
  40067. /**
  40068. * Is parallax occlusion enabled or not.
  40069. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40070. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40071. */
  40072. useParallaxOcclusion: boolean;
  40073. /**
  40074. * 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.
  40075. */
  40076. parallaxScaleBias: number;
  40077. private _roughness;
  40078. /**
  40079. * Helps to define how blurry the reflections should appears in the material.
  40080. */
  40081. roughness: number;
  40082. /**
  40083. * In case of refraction, define the value of the index of refraction.
  40084. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40085. */
  40086. indexOfRefraction: number;
  40087. /**
  40088. * Invert the refraction texture alongside the y axis.
  40089. * It can be useful with procedural textures or probe for instance.
  40090. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40091. */
  40092. invertRefractionY: boolean;
  40093. /**
  40094. * Defines the alpha limits in alpha test mode.
  40095. */
  40096. alphaCutOff: number;
  40097. private _useLightmapAsShadowmap;
  40098. /**
  40099. * In case of light mapping, define whether the map contains light or shadow informations.
  40100. */
  40101. useLightmapAsShadowmap: boolean;
  40102. private _diffuseFresnelParameters;
  40103. /**
  40104. * Define the diffuse fresnel parameters of the material.
  40105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40106. */
  40107. diffuseFresnelParameters: FresnelParameters;
  40108. private _opacityFresnelParameters;
  40109. /**
  40110. * Define the opacity fresnel parameters of the material.
  40111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40112. */
  40113. opacityFresnelParameters: FresnelParameters;
  40114. private _reflectionFresnelParameters;
  40115. /**
  40116. * Define the reflection fresnel parameters of the material.
  40117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40118. */
  40119. reflectionFresnelParameters: FresnelParameters;
  40120. private _refractionFresnelParameters;
  40121. /**
  40122. * Define the refraction fresnel parameters of the material.
  40123. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40124. */
  40125. refractionFresnelParameters: FresnelParameters;
  40126. private _emissiveFresnelParameters;
  40127. /**
  40128. * Define the emissive fresnel parameters of the material.
  40129. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40130. */
  40131. emissiveFresnelParameters: FresnelParameters;
  40132. private _useReflectionFresnelFromSpecular;
  40133. /**
  40134. * If true automatically deducts the fresnels values from the material specularity.
  40135. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40136. */
  40137. useReflectionFresnelFromSpecular: boolean;
  40138. private _useGlossinessFromSpecularMapAlpha;
  40139. /**
  40140. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40141. */
  40142. useGlossinessFromSpecularMapAlpha: boolean;
  40143. private _maxSimultaneousLights;
  40144. /**
  40145. * Defines the maximum number of lights that can be used in the material
  40146. */
  40147. maxSimultaneousLights: number;
  40148. private _invertNormalMapX;
  40149. /**
  40150. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40151. */
  40152. invertNormalMapX: boolean;
  40153. private _invertNormalMapY;
  40154. /**
  40155. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40156. */
  40157. invertNormalMapY: boolean;
  40158. private _twoSidedLighting;
  40159. /**
  40160. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40161. */
  40162. twoSidedLighting: boolean;
  40163. /**
  40164. * Default configuration related to image processing available in the standard Material.
  40165. */
  40166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40167. /**
  40168. * Gets the image processing configuration used either in this material.
  40169. */
  40170. /**
  40171. * Sets the Default image processing configuration used either in the this material.
  40172. *
  40173. * If sets to null, the scene one is in use.
  40174. */
  40175. imageProcessingConfiguration: ImageProcessingConfiguration;
  40176. /**
  40177. * Keep track of the image processing observer to allow dispose and replace.
  40178. */
  40179. private _imageProcessingObserver;
  40180. /**
  40181. * Attaches a new image processing configuration to the Standard Material.
  40182. * @param configuration
  40183. */
  40184. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40185. /**
  40186. * Gets wether the color curves effect is enabled.
  40187. */
  40188. /**
  40189. * Sets wether the color curves effect is enabled.
  40190. */
  40191. cameraColorCurvesEnabled: boolean;
  40192. /**
  40193. * Gets wether the color grading effect is enabled.
  40194. */
  40195. /**
  40196. * Gets wether the color grading effect is enabled.
  40197. */
  40198. cameraColorGradingEnabled: boolean;
  40199. /**
  40200. * Gets wether tonemapping is enabled or not.
  40201. */
  40202. /**
  40203. * Sets wether tonemapping is enabled or not
  40204. */
  40205. cameraToneMappingEnabled: boolean;
  40206. /**
  40207. * The camera exposure used on this material.
  40208. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40209. * This corresponds to a photographic exposure.
  40210. */
  40211. /**
  40212. * The camera exposure used on this material.
  40213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40214. * This corresponds to a photographic exposure.
  40215. */
  40216. cameraExposure: number;
  40217. /**
  40218. * Gets The camera contrast used on this material.
  40219. */
  40220. /**
  40221. * Sets The camera contrast used on this material.
  40222. */
  40223. cameraContrast: number;
  40224. /**
  40225. * Gets the Color Grading 2D Lookup Texture.
  40226. */
  40227. /**
  40228. * Sets the Color Grading 2D Lookup Texture.
  40229. */
  40230. cameraColorGradingTexture: Nullable<BaseTexture>;
  40231. /**
  40232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40234. * 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;
  40235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40236. */
  40237. /**
  40238. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40239. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40240. * 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;
  40241. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40242. */
  40243. cameraColorCurves: Nullable<ColorCurves>;
  40244. /**
  40245. * Custom callback helping to override the default shader used in the material.
  40246. */
  40247. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40248. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40249. protected _worldViewProjectionMatrix: Matrix;
  40250. protected _globalAmbientColor: Color3;
  40251. protected _useLogarithmicDepth: boolean;
  40252. protected _rebuildInParallel: boolean;
  40253. /**
  40254. * Instantiates a new standard material.
  40255. * This is the default material used in Babylon. It is the best trade off between quality
  40256. * and performances.
  40257. * @see http://doc.babylonjs.com/babylon101/materials
  40258. * @param name Define the name of the material in the scene
  40259. * @param scene Define the scene the material belong to
  40260. */
  40261. constructor(name: string, scene: Scene);
  40262. /**
  40263. * Gets a boolean indicating that current material needs to register RTT
  40264. */
  40265. readonly hasRenderTargetTextures: boolean;
  40266. /**
  40267. * Gets the current class name of the material e.g. "StandardMaterial"
  40268. * Mainly use in serialization.
  40269. * @returns the class name
  40270. */
  40271. getClassName(): string;
  40272. /**
  40273. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40274. * You can try switching to logarithmic depth.
  40275. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40276. */
  40277. useLogarithmicDepth: boolean;
  40278. /**
  40279. * Specifies if the material will require alpha blending
  40280. * @returns a boolean specifying if alpha blending is needed
  40281. */
  40282. needAlphaBlending(): boolean;
  40283. /**
  40284. * Specifies if this material should be rendered in alpha test mode
  40285. * @returns a boolean specifying if an alpha test is needed.
  40286. */
  40287. needAlphaTesting(): boolean;
  40288. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40289. /**
  40290. * Get the texture used for alpha test purpose.
  40291. * @returns the diffuse texture in case of the standard material.
  40292. */
  40293. getAlphaTestTexture(): Nullable<BaseTexture>;
  40294. /**
  40295. * Get if the submesh is ready to be used and all its information available.
  40296. * Child classes can use it to update shaders
  40297. * @param mesh defines the mesh to check
  40298. * @param subMesh defines which submesh to check
  40299. * @param useInstances specifies that instances should be used
  40300. * @returns a boolean indicating that the submesh is ready or not
  40301. */
  40302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40303. /**
  40304. * Builds the material UBO layouts.
  40305. * Used internally during the effect preparation.
  40306. */
  40307. buildUniformLayout(): void;
  40308. /**
  40309. * Unbinds the material from the mesh
  40310. */
  40311. unbind(): void;
  40312. /**
  40313. * Binds the submesh to this material by preparing the effect and shader to draw
  40314. * @param world defines the world transformation matrix
  40315. * @param mesh defines the mesh containing the submesh
  40316. * @param subMesh defines the submesh to bind the material to
  40317. */
  40318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40319. /**
  40320. * Get the list of animatables in the material.
  40321. * @returns the list of animatables object used in the material
  40322. */
  40323. getAnimatables(): IAnimatable[];
  40324. /**
  40325. * Gets the active textures from the material
  40326. * @returns an array of textures
  40327. */
  40328. getActiveTextures(): BaseTexture[];
  40329. /**
  40330. * Specifies if the material uses a texture
  40331. * @param texture defines the texture to check against the material
  40332. * @returns a boolean specifying if the material uses the texture
  40333. */
  40334. hasTexture(texture: BaseTexture): boolean;
  40335. /**
  40336. * Disposes the material
  40337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40339. */
  40340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40341. /**
  40342. * Makes a duplicate of the material, and gives it a new name
  40343. * @param name defines the new name for the duplicated material
  40344. * @returns the cloned material
  40345. */
  40346. clone(name: string): StandardMaterial;
  40347. /**
  40348. * Serializes this material in a JSON representation
  40349. * @returns the serialized material object
  40350. */
  40351. serialize(): any;
  40352. /**
  40353. * Creates a standard material from parsed material data
  40354. * @param source defines the JSON representation of the material
  40355. * @param scene defines the hosting scene
  40356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40357. * @returns a new standard material
  40358. */
  40359. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40360. /**
  40361. * Are diffuse textures enabled in the application.
  40362. */
  40363. static DiffuseTextureEnabled: boolean;
  40364. /**
  40365. * Are ambient textures enabled in the application.
  40366. */
  40367. static AmbientTextureEnabled: boolean;
  40368. /**
  40369. * Are opacity textures enabled in the application.
  40370. */
  40371. static OpacityTextureEnabled: boolean;
  40372. /**
  40373. * Are reflection textures enabled in the application.
  40374. */
  40375. static ReflectionTextureEnabled: boolean;
  40376. /**
  40377. * Are emissive textures enabled in the application.
  40378. */
  40379. static EmissiveTextureEnabled: boolean;
  40380. /**
  40381. * Are specular textures enabled in the application.
  40382. */
  40383. static SpecularTextureEnabled: boolean;
  40384. /**
  40385. * Are bump textures enabled in the application.
  40386. */
  40387. static BumpTextureEnabled: boolean;
  40388. /**
  40389. * Are lightmap textures enabled in the application.
  40390. */
  40391. static LightmapTextureEnabled: boolean;
  40392. /**
  40393. * Are refraction textures enabled in the application.
  40394. */
  40395. static RefractionTextureEnabled: boolean;
  40396. /**
  40397. * Are color grading textures enabled in the application.
  40398. */
  40399. static ColorGradingTextureEnabled: boolean;
  40400. /**
  40401. * Are fresnels enabled in the application.
  40402. */
  40403. static FresnelEnabled: boolean;
  40404. }
  40405. }
  40406. declare module BABYLON {
  40407. /**
  40408. * A class extending Texture allowing drawing on a texture
  40409. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40410. */
  40411. export class DynamicTexture extends Texture {
  40412. private _generateMipMaps;
  40413. private _canvas;
  40414. private _context;
  40415. private _engine;
  40416. /**
  40417. * Creates a DynamicTexture
  40418. * @param name defines the name of the texture
  40419. * @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
  40420. * @param scene defines the scene where you want the texture
  40421. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40423. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40424. */
  40425. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40426. /**
  40427. * Get the current class name of the texture useful for serialization or dynamic coding.
  40428. * @returns "DynamicTexture"
  40429. */
  40430. getClassName(): string;
  40431. /**
  40432. * Gets the current state of canRescale
  40433. */
  40434. readonly canRescale: boolean;
  40435. private _recreate;
  40436. /**
  40437. * Scales the texture
  40438. * @param ratio the scale factor to apply to both width and height
  40439. */
  40440. scale(ratio: number): void;
  40441. /**
  40442. * Resizes the texture
  40443. * @param width the new width
  40444. * @param height the new height
  40445. */
  40446. scaleTo(width: number, height: number): void;
  40447. /**
  40448. * Gets the context of the canvas used by the texture
  40449. * @returns the canvas context of the dynamic texture
  40450. */
  40451. getContext(): CanvasRenderingContext2D;
  40452. /**
  40453. * Clears the texture
  40454. */
  40455. clear(): void;
  40456. /**
  40457. * Updates the texture
  40458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40459. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40460. */
  40461. update(invertY?: boolean, premulAlpha?: boolean): void;
  40462. /**
  40463. * Draws text onto the texture
  40464. * @param text defines the text to be drawn
  40465. * @param x defines the placement of the text from the left
  40466. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40467. * @param font defines the font to be used with font-style, font-size, font-name
  40468. * @param color defines the color used for the text
  40469. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40470. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40471. * @param update defines whether texture is immediately update (default is true)
  40472. */
  40473. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40474. /**
  40475. * Clones the texture
  40476. * @returns the clone of the texture.
  40477. */
  40478. clone(): DynamicTexture;
  40479. /**
  40480. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40481. * @returns a serialized dynamic texture object
  40482. */
  40483. serialize(): any;
  40484. /** @hidden */
  40485. _rebuild(): void;
  40486. }
  40487. }
  40488. declare module BABYLON {
  40489. /** @hidden */
  40490. export var imageProcessingPixelShader: {
  40491. name: string;
  40492. shader: string;
  40493. };
  40494. }
  40495. declare module BABYLON {
  40496. /**
  40497. * ImageProcessingPostProcess
  40498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40499. */
  40500. export class ImageProcessingPostProcess extends PostProcess {
  40501. /**
  40502. * Default configuration related to image processing available in the PBR Material.
  40503. */
  40504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40505. /**
  40506. * Gets the image processing configuration used either in this material.
  40507. */
  40508. /**
  40509. * Sets the Default image processing configuration used either in the this material.
  40510. *
  40511. * If sets to null, the scene one is in use.
  40512. */
  40513. imageProcessingConfiguration: ImageProcessingConfiguration;
  40514. /**
  40515. * Keep track of the image processing observer to allow dispose and replace.
  40516. */
  40517. private _imageProcessingObserver;
  40518. /**
  40519. * Attaches a new image processing configuration to the PBR Material.
  40520. * @param configuration
  40521. */
  40522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40523. /**
  40524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40525. */
  40526. /**
  40527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40528. */
  40529. colorCurves: Nullable<ColorCurves>;
  40530. /**
  40531. * Gets wether the color curves effect is enabled.
  40532. */
  40533. /**
  40534. * Sets wether the color curves effect is enabled.
  40535. */
  40536. colorCurvesEnabled: boolean;
  40537. /**
  40538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40539. */
  40540. /**
  40541. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40542. */
  40543. colorGradingTexture: Nullable<BaseTexture>;
  40544. /**
  40545. * Gets wether the color grading effect is enabled.
  40546. */
  40547. /**
  40548. * Gets wether the color grading effect is enabled.
  40549. */
  40550. colorGradingEnabled: boolean;
  40551. /**
  40552. * Gets exposure used in the effect.
  40553. */
  40554. /**
  40555. * Sets exposure used in the effect.
  40556. */
  40557. exposure: number;
  40558. /**
  40559. * Gets wether tonemapping is enabled or not.
  40560. */
  40561. /**
  40562. * Sets wether tonemapping is enabled or not
  40563. */
  40564. toneMappingEnabled: boolean;
  40565. /**
  40566. * Gets the type of tone mapping effect.
  40567. */
  40568. /**
  40569. * Sets the type of tone mapping effect.
  40570. */
  40571. toneMappingType: number;
  40572. /**
  40573. * Gets contrast used in the effect.
  40574. */
  40575. /**
  40576. * Sets contrast used in the effect.
  40577. */
  40578. contrast: number;
  40579. /**
  40580. * Gets Vignette stretch size.
  40581. */
  40582. /**
  40583. * Sets Vignette stretch size.
  40584. */
  40585. vignetteStretch: number;
  40586. /**
  40587. * Gets Vignette centre X Offset.
  40588. */
  40589. /**
  40590. * Sets Vignette centre X Offset.
  40591. */
  40592. vignetteCentreX: number;
  40593. /**
  40594. * Gets Vignette centre Y Offset.
  40595. */
  40596. /**
  40597. * Sets Vignette centre Y Offset.
  40598. */
  40599. vignetteCentreY: number;
  40600. /**
  40601. * Gets Vignette weight or intensity of the vignette effect.
  40602. */
  40603. /**
  40604. * Sets Vignette weight or intensity of the vignette effect.
  40605. */
  40606. vignetteWeight: number;
  40607. /**
  40608. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40609. * if vignetteEnabled is set to true.
  40610. */
  40611. /**
  40612. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40613. * if vignetteEnabled is set to true.
  40614. */
  40615. vignetteColor: Color4;
  40616. /**
  40617. * Gets Camera field of view used by the Vignette effect.
  40618. */
  40619. /**
  40620. * Sets Camera field of view used by the Vignette effect.
  40621. */
  40622. vignetteCameraFov: number;
  40623. /**
  40624. * Gets the vignette blend mode allowing different kind of effect.
  40625. */
  40626. /**
  40627. * Sets the vignette blend mode allowing different kind of effect.
  40628. */
  40629. vignetteBlendMode: number;
  40630. /**
  40631. * Gets wether the vignette effect is enabled.
  40632. */
  40633. /**
  40634. * Sets wether the vignette effect is enabled.
  40635. */
  40636. vignetteEnabled: boolean;
  40637. private _fromLinearSpace;
  40638. /**
  40639. * Gets wether the input of the processing is in Gamma or Linear Space.
  40640. */
  40641. /**
  40642. * Sets wether the input of the processing is in Gamma or Linear Space.
  40643. */
  40644. fromLinearSpace: boolean;
  40645. /**
  40646. * Defines cache preventing GC.
  40647. */
  40648. private _defines;
  40649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40650. /**
  40651. * "ImageProcessingPostProcess"
  40652. * @returns "ImageProcessingPostProcess"
  40653. */
  40654. getClassName(): string;
  40655. protected _updateParameters(): void;
  40656. dispose(camera?: Camera): void;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. /**
  40661. * Class containing static functions to help procedurally build meshes
  40662. */
  40663. export class GroundBuilder {
  40664. /**
  40665. * Creates a ground mesh
  40666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40669. * @param name defines the name of the mesh
  40670. * @param options defines the options used to create the mesh
  40671. * @param scene defines the hosting scene
  40672. * @returns the ground mesh
  40673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40674. */
  40675. static CreateGround(name: string, options: {
  40676. width?: number;
  40677. height?: number;
  40678. subdivisions?: number;
  40679. subdivisionsX?: number;
  40680. subdivisionsY?: number;
  40681. updatable?: boolean;
  40682. }, scene: any): Mesh;
  40683. /**
  40684. * Creates a tiled ground mesh
  40685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40687. * * 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
  40688. * * 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
  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 tiled ground mesh
  40694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40695. */
  40696. static CreateTiledGround(name: string, options: {
  40697. xmin: number;
  40698. zmin: number;
  40699. xmax: number;
  40700. zmax: number;
  40701. subdivisions?: {
  40702. w: number;
  40703. h: number;
  40704. };
  40705. precision?: {
  40706. w: number;
  40707. h: number;
  40708. };
  40709. updatable?: boolean;
  40710. }, scene?: Nullable<Scene>): Mesh;
  40711. /**
  40712. * Creates a ground mesh from a height map
  40713. * * The parameter `url` sets the URL of the height map image resource.
  40714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40718. * * 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.
  40719. * * 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).
  40720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40722. * @param name defines the name of the mesh
  40723. * @param url defines the url to the height map
  40724. * @param options defines the options used to create the mesh
  40725. * @param scene defines the hosting scene
  40726. * @returns the ground mesh
  40727. * @see https://doc.babylonjs.com/babylon101/height_map
  40728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40729. */
  40730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40731. width?: number;
  40732. height?: number;
  40733. subdivisions?: number;
  40734. minHeight?: number;
  40735. maxHeight?: number;
  40736. colorFilter?: Color3;
  40737. alphaFilter?: number;
  40738. updatable?: boolean;
  40739. onReady?: (mesh: GroundMesh) => void;
  40740. }, scene?: Nullable<Scene>): GroundMesh;
  40741. }
  40742. }
  40743. declare module BABYLON {
  40744. /**
  40745. * Class containing static functions to help procedurally build meshes
  40746. */
  40747. export class TorusBuilder {
  40748. /**
  40749. * Creates a torus mesh
  40750. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40751. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40752. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40754. * * 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
  40755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40756. * @param name defines the name of the mesh
  40757. * @param options defines the options used to create the mesh
  40758. * @param scene defines the hosting scene
  40759. * @returns the torus mesh
  40760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40761. */
  40762. static CreateTorus(name: string, options: {
  40763. diameter?: number;
  40764. thickness?: number;
  40765. tessellation?: number;
  40766. updatable?: boolean;
  40767. sideOrientation?: number;
  40768. frontUVs?: Vector4;
  40769. backUVs?: Vector4;
  40770. }, scene: any): Mesh;
  40771. }
  40772. }
  40773. declare module BABYLON {
  40774. /**
  40775. * Class containing static functions to help procedurally build meshes
  40776. */
  40777. export class CylinderBuilder {
  40778. /**
  40779. * Creates a cylinder or a cone mesh
  40780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40782. * * 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.
  40783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40787. * * 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).
  40788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40789. * * 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).
  40790. * * 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
  40791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40792. * * 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
  40793. * * 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.
  40794. * * If `enclose` is false, a ring surface is one element.
  40795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40796. * * 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
  40797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40798. * * 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
  40799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40800. * @param name defines the name of the mesh
  40801. * @param options defines the options used to create the mesh
  40802. * @param scene defines the hosting scene
  40803. * @returns the cylinder mesh
  40804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40805. */
  40806. static CreateCylinder(name: string, options: {
  40807. height?: number;
  40808. diameterTop?: number;
  40809. diameterBottom?: number;
  40810. diameter?: number;
  40811. tessellation?: number;
  40812. subdivisions?: number;
  40813. arc?: number;
  40814. faceColors?: Color4[];
  40815. faceUV?: Vector4[];
  40816. updatable?: boolean;
  40817. hasRings?: boolean;
  40818. enclose?: boolean;
  40819. cap?: number;
  40820. sideOrientation?: number;
  40821. frontUVs?: Vector4;
  40822. backUVs?: Vector4;
  40823. }, scene: any): Mesh;
  40824. }
  40825. }
  40826. declare module BABYLON {
  40827. /**
  40828. * Options to modify the vr teleportation behavior.
  40829. */
  40830. export interface VRTeleportationOptions {
  40831. /**
  40832. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40833. */
  40834. floorMeshName?: string;
  40835. /**
  40836. * A list of meshes to be used as the teleportation floor. (default: empty)
  40837. */
  40838. floorMeshes?: Mesh[];
  40839. }
  40840. /**
  40841. * Options to modify the vr experience helper's behavior.
  40842. */
  40843. export interface VRExperienceHelperOptions extends WebVROptions {
  40844. /**
  40845. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40846. */
  40847. createDeviceOrientationCamera?: boolean;
  40848. /**
  40849. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40850. */
  40851. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40852. /**
  40853. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40854. */
  40855. laserToggle?: boolean;
  40856. /**
  40857. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40858. */
  40859. floorMeshes?: Mesh[];
  40860. /**
  40861. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40862. */
  40863. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40864. }
  40865. /**
  40866. * Event containing information after VR has been entered
  40867. */
  40868. export class OnAfterEnteringVRObservableEvent {
  40869. /**
  40870. * If entering vr was successful
  40871. */
  40872. success: boolean;
  40873. }
  40874. /**
  40875. * Helps to quickly add VR support to an existing scene.
  40876. * See http://doc.babylonjs.com/how_to/webvr_helper
  40877. */
  40878. export class VRExperienceHelper {
  40879. /** Options to modify the vr experience helper's behavior. */
  40880. webVROptions: VRExperienceHelperOptions;
  40881. private _scene;
  40882. private _position;
  40883. private _btnVR;
  40884. private _btnVRDisplayed;
  40885. private _webVRsupported;
  40886. private _webVRready;
  40887. private _webVRrequesting;
  40888. private _webVRpresenting;
  40889. private _hasEnteredVR;
  40890. private _fullscreenVRpresenting;
  40891. private _canvas;
  40892. private _webVRCamera;
  40893. private _vrDeviceOrientationCamera;
  40894. private _deviceOrientationCamera;
  40895. private _existingCamera;
  40896. private _onKeyDown;
  40897. private _onVrDisplayPresentChange;
  40898. private _onVRDisplayChanged;
  40899. private _onVRRequestPresentStart;
  40900. private _onVRRequestPresentComplete;
  40901. /**
  40902. * 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)
  40903. */
  40904. enableGazeEvenWhenNoPointerLock: boolean;
  40905. /**
  40906. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40907. */
  40908. exitVROnDoubleTap: boolean;
  40909. /**
  40910. * Observable raised right before entering VR.
  40911. */
  40912. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40913. /**
  40914. * Observable raised when entering VR has completed.
  40915. */
  40916. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40917. /**
  40918. * Observable raised when exiting VR.
  40919. */
  40920. onExitingVRObservable: Observable<VRExperienceHelper>;
  40921. /**
  40922. * Observable raised when controller mesh is loaded.
  40923. */
  40924. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40925. /** Return this.onEnteringVRObservable
  40926. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40927. */
  40928. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40929. /** Return this.onExitingVRObservable
  40930. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40931. */
  40932. readonly onExitingVR: Observable<VRExperienceHelper>;
  40933. /** Return this.onControllerMeshLoadedObservable
  40934. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40935. */
  40936. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40937. private _rayLength;
  40938. private _useCustomVRButton;
  40939. private _teleportationRequested;
  40940. private _teleportActive;
  40941. private _floorMeshName;
  40942. private _floorMeshesCollection;
  40943. private _rotationAllowed;
  40944. private _teleportBackwardsVector;
  40945. private _teleportationTarget;
  40946. private _isDefaultTeleportationTarget;
  40947. private _postProcessMove;
  40948. private _teleportationFillColor;
  40949. private _teleportationBorderColor;
  40950. private _rotationAngle;
  40951. private _haloCenter;
  40952. private _cameraGazer;
  40953. private _padSensibilityUp;
  40954. private _padSensibilityDown;
  40955. private _leftController;
  40956. private _rightController;
  40957. /**
  40958. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40959. */
  40960. onNewMeshSelected: Observable<AbstractMesh>;
  40961. /**
  40962. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40963. * This observable will provide the mesh and the controller used to select the mesh
  40964. */
  40965. onMeshSelectedWithController: Observable<{
  40966. mesh: AbstractMesh;
  40967. controller: WebVRController;
  40968. }>;
  40969. /**
  40970. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40971. */
  40972. onNewMeshPicked: Observable<PickingInfo>;
  40973. private _circleEase;
  40974. /**
  40975. * Observable raised before camera teleportation
  40976. */
  40977. onBeforeCameraTeleport: Observable<Vector3>;
  40978. /**
  40979. * Observable raised after camera teleportation
  40980. */
  40981. onAfterCameraTeleport: Observable<Vector3>;
  40982. /**
  40983. * Observable raised when current selected mesh gets unselected
  40984. */
  40985. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40986. private _raySelectionPredicate;
  40987. /**
  40988. * To be optionaly changed by user to define custom ray selection
  40989. */
  40990. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40991. /**
  40992. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40993. */
  40994. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40995. /**
  40996. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40997. */
  40998. teleportationEnabled: boolean;
  40999. private _defaultHeight;
  41000. private _teleportationInitialized;
  41001. private _interactionsEnabled;
  41002. private _interactionsRequested;
  41003. private _displayGaze;
  41004. private _displayLaserPointer;
  41005. /**
  41006. * The mesh used to display where the user is going to teleport.
  41007. */
  41008. /**
  41009. * Sets the mesh to be used to display where the user is going to teleport.
  41010. */
  41011. teleportationTarget: Mesh;
  41012. /**
  41013. * 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
  41014. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41015. * See http://doc.babylonjs.com/resources/baking_transformations
  41016. */
  41017. gazeTrackerMesh: Mesh;
  41018. /**
  41019. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41020. */
  41021. updateGazeTrackerScale: boolean;
  41022. /**
  41023. * If the gaze trackers color should be updated when selecting meshes
  41024. */
  41025. updateGazeTrackerColor: boolean;
  41026. /**
  41027. * The gaze tracking mesh corresponding to the left controller
  41028. */
  41029. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41030. /**
  41031. * The gaze tracking mesh corresponding to the right controller
  41032. */
  41033. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41034. /**
  41035. * If the ray of the gaze should be displayed.
  41036. */
  41037. /**
  41038. * Sets if the ray of the gaze should be displayed.
  41039. */
  41040. displayGaze: boolean;
  41041. /**
  41042. * If the ray of the LaserPointer should be displayed.
  41043. */
  41044. /**
  41045. * Sets if the ray of the LaserPointer should be displayed.
  41046. */
  41047. displayLaserPointer: boolean;
  41048. /**
  41049. * The deviceOrientationCamera used as the camera when not in VR.
  41050. */
  41051. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41052. /**
  41053. * Based on the current WebVR support, returns the current VR camera used.
  41054. */
  41055. readonly currentVRCamera: Nullable<Camera>;
  41056. /**
  41057. * The webVRCamera which is used when in VR.
  41058. */
  41059. readonly webVRCamera: WebVRFreeCamera;
  41060. /**
  41061. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41062. */
  41063. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41064. /**
  41065. * The html button that is used to trigger entering into VR.
  41066. */
  41067. readonly vrButton: Nullable<HTMLButtonElement>;
  41068. private readonly _teleportationRequestInitiated;
  41069. /**
  41070. * Defines wether or not Pointer lock should be requested when switching to
  41071. * full screen.
  41072. */
  41073. requestPointerLockOnFullScreen: boolean;
  41074. /**
  41075. * Instantiates a VRExperienceHelper.
  41076. * Helps to quickly add VR support to an existing scene.
  41077. * @param scene The scene the VRExperienceHelper belongs to.
  41078. * @param webVROptions Options to modify the vr experience helper's behavior.
  41079. */
  41080. constructor(scene: Scene,
  41081. /** Options to modify the vr experience helper's behavior. */
  41082. webVROptions?: VRExperienceHelperOptions);
  41083. private _onDefaultMeshLoaded;
  41084. private _onResize;
  41085. private _onFullscreenChange;
  41086. /**
  41087. * Gets a value indicating if we are currently in VR mode.
  41088. */
  41089. readonly isInVRMode: boolean;
  41090. private onVrDisplayPresentChange;
  41091. private onVRDisplayChanged;
  41092. private moveButtonToBottomRight;
  41093. private displayVRButton;
  41094. private updateButtonVisibility;
  41095. private _cachedAngularSensibility;
  41096. /**
  41097. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41098. * Otherwise, will use the fullscreen API.
  41099. */
  41100. enterVR(): void;
  41101. /**
  41102. * Attempt to exit VR, or fullscreen.
  41103. */
  41104. exitVR(): void;
  41105. /**
  41106. * The position of the vr experience helper.
  41107. */
  41108. /**
  41109. * Sets the position of the vr experience helper.
  41110. */
  41111. position: Vector3;
  41112. /**
  41113. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41114. */
  41115. enableInteractions(): void;
  41116. private readonly _noControllerIsActive;
  41117. private beforeRender;
  41118. private _isTeleportationFloor;
  41119. /**
  41120. * Adds a floor mesh to be used for teleportation.
  41121. * @param floorMesh the mesh to be used for teleportation.
  41122. */
  41123. addFloorMesh(floorMesh: Mesh): void;
  41124. /**
  41125. * Removes a floor mesh from being used for teleportation.
  41126. * @param floorMesh the mesh to be removed.
  41127. */
  41128. removeFloorMesh(floorMesh: Mesh): void;
  41129. /**
  41130. * Enables interactions and teleportation using the VR controllers and gaze.
  41131. * @param vrTeleportationOptions options to modify teleportation behavior.
  41132. */
  41133. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41134. private _onNewGamepadConnected;
  41135. private _tryEnableInteractionOnController;
  41136. private _onNewGamepadDisconnected;
  41137. private _enableInteractionOnController;
  41138. private _checkTeleportWithRay;
  41139. private _checkRotate;
  41140. private _checkTeleportBackwards;
  41141. private _enableTeleportationOnController;
  41142. private _createTeleportationCircles;
  41143. private _displayTeleportationTarget;
  41144. private _hideTeleportationTarget;
  41145. private _rotateCamera;
  41146. private _moveTeleportationSelectorTo;
  41147. private _workingVector;
  41148. private _workingQuaternion;
  41149. private _workingMatrix;
  41150. /**
  41151. * Teleports the users feet to the desired location
  41152. * @param location The location where the user's feet should be placed
  41153. */
  41154. teleportCamera(location: Vector3): void;
  41155. private _convertNormalToDirectionOfRay;
  41156. private _castRayAndSelectObject;
  41157. private _notifySelectedMeshUnselected;
  41158. /**
  41159. * Sets the color of the laser ray from the vr controllers.
  41160. * @param color new color for the ray.
  41161. */
  41162. changeLaserColor(color: Color3): void;
  41163. /**
  41164. * Sets the color of the ray from the vr headsets gaze.
  41165. * @param color new color for the ray.
  41166. */
  41167. changeGazeColor(color: Color3): void;
  41168. /**
  41169. * Exits VR and disposes of the vr experience helper
  41170. */
  41171. dispose(): void;
  41172. /**
  41173. * Gets the name of the VRExperienceHelper class
  41174. * @returns "VRExperienceHelper"
  41175. */
  41176. getClassName(): string;
  41177. }
  41178. }
  41179. declare module BABYLON {
  41180. /**
  41181. * Manages an XRSession to work with Babylon's engine
  41182. * @see https://doc.babylonjs.com/how_to/webxr
  41183. */
  41184. export class WebXRSessionManager implements IDisposable {
  41185. private scene;
  41186. /**
  41187. * Fires every time a new xrFrame arrives which can be used to update the camera
  41188. */
  41189. onXRFrameObservable: Observable<any>;
  41190. /**
  41191. * Fires when the xr session is ended either by the device or manually done
  41192. */
  41193. onXRSessionEnded: Observable<any>;
  41194. /**
  41195. * Underlying xr session
  41196. */
  41197. session: XRSession;
  41198. /**
  41199. * Type of reference space used when creating the session
  41200. */
  41201. referenceSpace: XRReferenceSpace;
  41202. /** @hidden */
  41203. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41204. /**
  41205. * Current XR frame
  41206. */
  41207. currentFrame: Nullable<XRFrame>;
  41208. private _xrNavigator;
  41209. private baseLayer;
  41210. /**
  41211. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41212. * @param scene The scene which the session should be created for
  41213. */
  41214. constructor(scene: Scene);
  41215. /**
  41216. * Initializes the manager
  41217. * After initialization enterXR can be called to start an XR session
  41218. * @returns Promise which resolves after it is initialized
  41219. */
  41220. initializeAsync(): Promise<void>;
  41221. /**
  41222. * Initializes an xr session
  41223. * @param xrSessionMode mode to initialize
  41224. * @returns a promise which will resolve once the session has been initialized
  41225. */
  41226. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41227. /**
  41228. * Sets the reference space on the xr session
  41229. * @param referenceSpace space to set
  41230. * @returns a promise that will resolve once the reference space has been set
  41231. */
  41232. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41233. /**
  41234. * Updates the render state of the session
  41235. * @param state state to set
  41236. * @returns a promise that resolves once the render state has been updated
  41237. */
  41238. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41239. /**
  41240. * Starts rendering to the xr layer
  41241. * @returns a promise that will resolve once rendering has started
  41242. */
  41243. startRenderingToXRAsync(): Promise<void>;
  41244. /**
  41245. * Stops the xrSession and restores the renderloop
  41246. * @returns Promise which resolves after it exits XR
  41247. */
  41248. exitXRAsync(): Promise<unknown>;
  41249. /**
  41250. * Checks if a session would be supported for the creation options specified
  41251. * @param sessionMode session mode to check if supported eg. immersive-vr
  41252. * @returns true if supported
  41253. */
  41254. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41255. /**
  41256. * @hidden
  41257. * Converts the render layer of xrSession to a render target
  41258. * @param session session to create render target for
  41259. * @param scene scene the new render target should be created for
  41260. */
  41261. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41262. /**
  41263. * Disposes of the session manager
  41264. */
  41265. dispose(): void;
  41266. }
  41267. }
  41268. declare module BABYLON {
  41269. /**
  41270. * WebXR Camera which holds the views for the xrSession
  41271. * @see https://doc.babylonjs.com/how_to/webxr
  41272. */
  41273. export class WebXRCamera extends FreeCamera {
  41274. private static _TmpMatrix;
  41275. /**
  41276. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41277. * @param name the name of the camera
  41278. * @param scene the scene to add the camera to
  41279. */
  41280. constructor(name: string, scene: Scene);
  41281. private _updateNumberOfRigCameras;
  41282. /** @hidden */
  41283. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41284. /**
  41285. * Updates the cameras position from the current pose information of the XR session
  41286. * @param xrSessionManager the session containing pose information
  41287. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41288. */
  41289. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41290. }
  41291. }
  41292. declare module BABYLON {
  41293. /**
  41294. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41295. */
  41296. export class WebXRManagedOutputCanvas implements IDisposable {
  41297. private helper;
  41298. private _canvas;
  41299. /**
  41300. * xrpresent context of the canvas which can be used to display/mirror xr content
  41301. */
  41302. canvasContext: WebGLRenderingContext;
  41303. /**
  41304. * xr layer for the canvas
  41305. */
  41306. xrLayer: Nullable<XRWebGLLayer>;
  41307. /**
  41308. * Initializes the xr layer for the session
  41309. * @param xrSession xr session
  41310. * @returns a promise that will resolve once the XR Layer has been created
  41311. */
  41312. initializeXRLayerAsync(xrSession: any): any;
  41313. /**
  41314. * Initializes the canvas to be added/removed upon entering/exiting xr
  41315. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41316. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41317. */
  41318. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41319. /**
  41320. * Disposes of the object
  41321. */
  41322. dispose(): void;
  41323. private _setManagedOutputCanvas;
  41324. private _addCanvas;
  41325. private _removeCanvas;
  41326. }
  41327. }
  41328. declare module BABYLON {
  41329. /**
  41330. * States of the webXR experience
  41331. */
  41332. export enum WebXRState {
  41333. /**
  41334. * Transitioning to being in XR mode
  41335. */
  41336. ENTERING_XR = 0,
  41337. /**
  41338. * Transitioning to non XR mode
  41339. */
  41340. EXITING_XR = 1,
  41341. /**
  41342. * In XR mode and presenting
  41343. */
  41344. IN_XR = 2,
  41345. /**
  41346. * Not entered XR mode
  41347. */
  41348. NOT_IN_XR = 3
  41349. }
  41350. /**
  41351. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41352. * @see https://doc.babylonjs.com/how_to/webxr
  41353. */
  41354. export class WebXRExperienceHelper implements IDisposable {
  41355. private scene;
  41356. /**
  41357. * 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
  41358. */
  41359. container: AbstractMesh;
  41360. /**
  41361. * Camera used to render xr content
  41362. */
  41363. camera: WebXRCamera;
  41364. /**
  41365. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41366. */
  41367. state: WebXRState;
  41368. private _setState;
  41369. private static _TmpVector;
  41370. /**
  41371. * Fires when the state of the experience helper has changed
  41372. */
  41373. onStateChangedObservable: Observable<WebXRState>;
  41374. /** Session manager used to keep track of xr session */
  41375. sessionManager: WebXRSessionManager;
  41376. private _nonVRCamera;
  41377. private _originalSceneAutoClear;
  41378. private _supported;
  41379. /**
  41380. * Creates the experience helper
  41381. * @param scene the scene to attach the experience helper to
  41382. * @returns a promise for the experience helper
  41383. */
  41384. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41385. /**
  41386. * Creates a WebXRExperienceHelper
  41387. * @param scene The scene the helper should be created in
  41388. */
  41389. private constructor();
  41390. /**
  41391. * Exits XR mode and returns the scene to its original state
  41392. * @returns promise that resolves after xr mode has exited
  41393. */
  41394. exitXRAsync(): Promise<unknown>;
  41395. /**
  41396. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41397. * @param sessionCreationOptions options for the XR session
  41398. * @param referenceSpaceType frame of reference of the XR session
  41399. * @param outputCanvas the output canvas that will be used to enter XR mode
  41400. * @returns promise that resolves after xr mode has entered
  41401. */
  41402. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41403. /**
  41404. * Updates the global position of the camera by moving the camera's container
  41405. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41406. * @param position The desired global position of the camera
  41407. */
  41408. setPositionOfCameraUsingContainer(position: Vector3): void;
  41409. /**
  41410. * Rotates the xr camera by rotating the camera's container around the camera's position
  41411. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41412. * @param rotation the desired quaternion rotation to apply to the camera
  41413. */
  41414. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41415. /**
  41416. * Disposes of the experience helper
  41417. */
  41418. dispose(): void;
  41419. }
  41420. }
  41421. declare module BABYLON {
  41422. /**
  41423. * Button which can be used to enter a different mode of XR
  41424. */
  41425. export class WebXREnterExitUIButton {
  41426. /** button element */
  41427. element: HTMLElement;
  41428. /** XR initialization options for the button */
  41429. sessionMode: XRSessionMode;
  41430. /** Reference space type */
  41431. referenceSpaceType: XRReferenceSpaceType;
  41432. /**
  41433. * Creates a WebXREnterExitUIButton
  41434. * @param element button element
  41435. * @param sessionMode XR initialization session mode
  41436. * @param referenceSpaceType the type of reference space to be used
  41437. */
  41438. constructor(
  41439. /** button element */
  41440. element: HTMLElement,
  41441. /** XR initialization options for the button */
  41442. sessionMode: XRSessionMode,
  41443. /** Reference space type */
  41444. referenceSpaceType: XRReferenceSpaceType);
  41445. /**
  41446. * Overwritable function which can be used to update the button's visuals when the state changes
  41447. * @param activeButton the current active button in the UI
  41448. */
  41449. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41450. }
  41451. /**
  41452. * Options to create the webXR UI
  41453. */
  41454. export class WebXREnterExitUIOptions {
  41455. /**
  41456. * Context to enter xr with
  41457. */
  41458. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41459. /**
  41460. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41461. */
  41462. customButtons?: Array<WebXREnterExitUIButton>;
  41463. }
  41464. /**
  41465. * UI to allow the user to enter/exit XR mode
  41466. */
  41467. export class WebXREnterExitUI implements IDisposable {
  41468. private scene;
  41469. private _overlay;
  41470. private _buttons;
  41471. private _activeButton;
  41472. /**
  41473. * Fired every time the active button is changed.
  41474. *
  41475. * When xr is entered via a button that launches xr that button will be the callback parameter
  41476. *
  41477. * When exiting xr the callback parameter will be null)
  41478. */
  41479. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41480. /**
  41481. * Creates UI to allow the user to enter/exit XR mode
  41482. * @param scene the scene to add the ui to
  41483. * @param helper the xr experience helper to enter/exit xr with
  41484. * @param options options to configure the UI
  41485. * @returns the created ui
  41486. */
  41487. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41488. private constructor();
  41489. private _updateButtons;
  41490. /**
  41491. * Disposes of the object
  41492. */
  41493. dispose(): void;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /**
  41498. * Represents an XR input
  41499. */
  41500. export class WebXRController {
  41501. private scene;
  41502. /** The underlying input source for the controller */
  41503. inputSource: XRInputSource;
  41504. private parentContainer;
  41505. /**
  41506. * 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
  41507. */
  41508. grip?: AbstractMesh;
  41509. /**
  41510. * Pointer which can be used to select objects or attach a visible laser to
  41511. */
  41512. pointer: AbstractMesh;
  41513. /**
  41514. * Event that fires when the controller is removed/disposed
  41515. */
  41516. onDisposeObservable: Observable<{}>;
  41517. private _tmpMatrix;
  41518. private _tmpQuaternion;
  41519. private _tmpVector;
  41520. /**
  41521. * Creates the controller
  41522. * @see https://doc.babylonjs.com/how_to/webxr
  41523. * @param scene the scene which the controller should be associated to
  41524. * @param inputSource the underlying input source for the controller
  41525. * @param parentContainer parent that the controller meshes should be children of
  41526. */
  41527. constructor(scene: Scene,
  41528. /** The underlying input source for the controller */
  41529. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41530. /**
  41531. * Updates the controller pose based on the given XRFrame
  41532. * @param xrFrame xr frame to update the pose with
  41533. * @param referenceSpace reference space to use
  41534. */
  41535. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41536. /**
  41537. * Gets a world space ray coming from the controller
  41538. * @param result the resulting ray
  41539. */
  41540. getWorldPointerRayToRef(result: Ray): void;
  41541. /**
  41542. * Disposes of the object
  41543. */
  41544. dispose(): void;
  41545. }
  41546. }
  41547. declare module BABYLON {
  41548. /**
  41549. * XR input used to track XR inputs such as controllers/rays
  41550. */
  41551. export class WebXRInput implements IDisposable {
  41552. /**
  41553. * Base experience the input listens to
  41554. */
  41555. baseExperience: WebXRExperienceHelper;
  41556. /**
  41557. * XR controllers being tracked
  41558. */
  41559. controllers: Array<WebXRController>;
  41560. private _frameObserver;
  41561. private _stateObserver;
  41562. /**
  41563. * Event when a controller has been connected/added
  41564. */
  41565. onControllerAddedObservable: Observable<WebXRController>;
  41566. /**
  41567. * Event when a controller has been removed/disconnected
  41568. */
  41569. onControllerRemovedObservable: Observable<WebXRController>;
  41570. /**
  41571. * Initializes the WebXRInput
  41572. * @param baseExperience experience helper which the input should be created for
  41573. */
  41574. constructor(
  41575. /**
  41576. * Base experience the input listens to
  41577. */
  41578. baseExperience: WebXRExperienceHelper);
  41579. private _onInputSourcesChange;
  41580. private _addAndRemoveControllers;
  41581. /**
  41582. * Disposes of the object
  41583. */
  41584. dispose(): void;
  41585. }
  41586. }
  41587. declare module BABYLON {
  41588. /**
  41589. * Enables teleportation
  41590. */
  41591. export class WebXRControllerTeleportation {
  41592. private _teleportationFillColor;
  41593. private _teleportationBorderColor;
  41594. private _tmpRay;
  41595. private _tmpVector;
  41596. /**
  41597. * Creates a WebXRControllerTeleportation
  41598. * @param input input manager to add teleportation to
  41599. * @param floorMeshes floormeshes which can be teleported to
  41600. */
  41601. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * Handles pointer input automatically for the pointer of XR controllers
  41607. */
  41608. export class WebXRControllerPointerSelection {
  41609. private static _idCounter;
  41610. private _tmpRay;
  41611. /**
  41612. * Creates a WebXRControllerPointerSelection
  41613. * @param input input manager to setup pointer selection
  41614. */
  41615. constructor(input: WebXRInput);
  41616. private _convertNormalToDirectionOfRay;
  41617. private _updatePointerDistance;
  41618. }
  41619. }
  41620. declare module BABYLON {
  41621. /**
  41622. * Class used to represent data loading progression
  41623. */
  41624. export class SceneLoaderProgressEvent {
  41625. /** defines if data length to load can be evaluated */
  41626. readonly lengthComputable: boolean;
  41627. /** defines the loaded data length */
  41628. readonly loaded: number;
  41629. /** defines the data length to load */
  41630. readonly total: number;
  41631. /**
  41632. * Create a new progress event
  41633. * @param lengthComputable defines if data length to load can be evaluated
  41634. * @param loaded defines the loaded data length
  41635. * @param total defines the data length to load
  41636. */
  41637. constructor(
  41638. /** defines if data length to load can be evaluated */
  41639. lengthComputable: boolean,
  41640. /** defines the loaded data length */
  41641. loaded: number,
  41642. /** defines the data length to load */
  41643. total: number);
  41644. /**
  41645. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41646. * @param event defines the source event
  41647. * @returns a new SceneLoaderProgressEvent
  41648. */
  41649. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41650. }
  41651. /**
  41652. * Interface used by SceneLoader plugins to define supported file extensions
  41653. */
  41654. export interface ISceneLoaderPluginExtensions {
  41655. /**
  41656. * Defines the list of supported extensions
  41657. */
  41658. [extension: string]: {
  41659. isBinary: boolean;
  41660. };
  41661. }
  41662. /**
  41663. * Interface used by SceneLoader plugin factory
  41664. */
  41665. export interface ISceneLoaderPluginFactory {
  41666. /**
  41667. * Defines the name of the factory
  41668. */
  41669. name: string;
  41670. /**
  41671. * Function called to create a new plugin
  41672. * @return the new plugin
  41673. */
  41674. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41675. /**
  41676. * Boolean indicating if the plugin can direct load specific data
  41677. */
  41678. canDirectLoad?: (data: string) => boolean;
  41679. }
  41680. /**
  41681. * Interface used to define a SceneLoader plugin
  41682. */
  41683. export interface ISceneLoaderPlugin {
  41684. /**
  41685. * The friendly name of this plugin.
  41686. */
  41687. name: string;
  41688. /**
  41689. * The file extensions supported by this plugin.
  41690. */
  41691. extensions: string | ISceneLoaderPluginExtensions;
  41692. /**
  41693. * Import meshes into a scene.
  41694. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41695. * @param scene The scene to import into
  41696. * @param data The data to import
  41697. * @param rootUrl The root url for scene and resources
  41698. * @param meshes The meshes array to import into
  41699. * @param particleSystems The particle systems array to import into
  41700. * @param skeletons The skeletons array to import into
  41701. * @param onError The callback when import fails
  41702. * @returns True if successful or false otherwise
  41703. */
  41704. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41705. /**
  41706. * Load into a scene.
  41707. * @param scene The scene to load into
  41708. * @param data The data to import
  41709. * @param rootUrl The root url for scene and resources
  41710. * @param onError The callback when import fails
  41711. * @returns true if successful or false otherwise
  41712. */
  41713. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41714. /**
  41715. * The callback that returns true if the data can be directly loaded.
  41716. */
  41717. canDirectLoad?: (data: string) => boolean;
  41718. /**
  41719. * The callback that allows custom handling of the root url based on the response url.
  41720. */
  41721. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41722. /**
  41723. * Load into an asset container.
  41724. * @param scene The scene to load into
  41725. * @param data The data to import
  41726. * @param rootUrl The root url for scene and resources
  41727. * @param onError The callback when import fails
  41728. * @returns The loaded asset container
  41729. */
  41730. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41731. }
  41732. /**
  41733. * Interface used to define an async SceneLoader plugin
  41734. */
  41735. export interface ISceneLoaderPluginAsync {
  41736. /**
  41737. * The friendly name of this plugin.
  41738. */
  41739. name: string;
  41740. /**
  41741. * The file extensions supported by this plugin.
  41742. */
  41743. extensions: string | ISceneLoaderPluginExtensions;
  41744. /**
  41745. * Import meshes into a scene.
  41746. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41747. * @param scene The scene to import into
  41748. * @param data The data to import
  41749. * @param rootUrl The root url for scene and resources
  41750. * @param onProgress The callback when the load progresses
  41751. * @param fileName Defines the name of the file to load
  41752. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41753. */
  41754. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41755. meshes: AbstractMesh[];
  41756. particleSystems: IParticleSystem[];
  41757. skeletons: Skeleton[];
  41758. animationGroups: AnimationGroup[];
  41759. }>;
  41760. /**
  41761. * Load into a scene.
  41762. * @param scene The scene to load into
  41763. * @param data The data to import
  41764. * @param rootUrl The root url for scene and resources
  41765. * @param onProgress The callback when the load progresses
  41766. * @param fileName Defines the name of the file to load
  41767. * @returns Nothing
  41768. */
  41769. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41770. /**
  41771. * The callback that returns true if the data can be directly loaded.
  41772. */
  41773. canDirectLoad?: (data: string) => boolean;
  41774. /**
  41775. * The callback that allows custom handling of the root url based on the response url.
  41776. */
  41777. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41778. /**
  41779. * Load into an asset container.
  41780. * @param scene The scene to load into
  41781. * @param data The data to import
  41782. * @param rootUrl The root url for scene and resources
  41783. * @param onProgress The callback when the load progresses
  41784. * @param fileName Defines the name of the file to load
  41785. * @returns The loaded asset container
  41786. */
  41787. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41788. }
  41789. /**
  41790. * Class used to load scene from various file formats using registered plugins
  41791. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41792. */
  41793. export class SceneLoader {
  41794. /**
  41795. * No logging while loading
  41796. */
  41797. static readonly NO_LOGGING: number;
  41798. /**
  41799. * Minimal logging while loading
  41800. */
  41801. static readonly MINIMAL_LOGGING: number;
  41802. /**
  41803. * Summary logging while loading
  41804. */
  41805. static readonly SUMMARY_LOGGING: number;
  41806. /**
  41807. * Detailled logging while loading
  41808. */
  41809. static readonly DETAILED_LOGGING: number;
  41810. /**
  41811. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41812. */
  41813. static ForceFullSceneLoadingForIncremental: boolean;
  41814. /**
  41815. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41816. */
  41817. static ShowLoadingScreen: boolean;
  41818. /**
  41819. * Defines the current logging level (while loading the scene)
  41820. * @ignorenaming
  41821. */
  41822. static loggingLevel: number;
  41823. /**
  41824. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41825. */
  41826. static CleanBoneMatrixWeights: boolean;
  41827. /**
  41828. * Event raised when a plugin is used to load a scene
  41829. */
  41830. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41831. private static _registeredPlugins;
  41832. private static _getDefaultPlugin;
  41833. private static _getPluginForExtension;
  41834. private static _getPluginForDirectLoad;
  41835. private static _getPluginForFilename;
  41836. private static _getDirectLoad;
  41837. private static _loadData;
  41838. private static _getFileInfo;
  41839. /**
  41840. * Gets a plugin that can load the given extension
  41841. * @param extension defines the extension to load
  41842. * @returns a plugin or null if none works
  41843. */
  41844. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41845. /**
  41846. * Gets a boolean indicating that the given extension can be loaded
  41847. * @param extension defines the extension to load
  41848. * @returns true if the extension is supported
  41849. */
  41850. static IsPluginForExtensionAvailable(extension: string): boolean;
  41851. /**
  41852. * Adds a new plugin to the list of registered plugins
  41853. * @param plugin defines the plugin to add
  41854. */
  41855. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41856. /**
  41857. * Import meshes into a scene
  41858. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41859. * @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)
  41860. * @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)
  41861. * @param scene the instance of BABYLON.Scene to append to
  41862. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41863. * @param onProgress a callback with a progress event for each file being loaded
  41864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41865. * @param pluginExtension the extension used to determine the plugin
  41866. * @returns The loaded plugin
  41867. */
  41868. 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>;
  41869. /**
  41870. * Import meshes into a scene
  41871. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41872. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41873. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41874. * @param scene the instance of BABYLON.Scene to append to
  41875. * @param onProgress a callback with a progress event for each file being loaded
  41876. * @param pluginExtension the extension used to determine the plugin
  41877. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41878. */
  41879. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41880. meshes: AbstractMesh[];
  41881. particleSystems: IParticleSystem[];
  41882. skeletons: Skeleton[];
  41883. animationGroups: AnimationGroup[];
  41884. }>;
  41885. /**
  41886. * Load a scene
  41887. * @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)
  41888. * @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)
  41889. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41890. * @param onSuccess a callback with the scene when import succeeds
  41891. * @param onProgress a callback with a progress event for each file being loaded
  41892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41893. * @param pluginExtension the extension used to determine the plugin
  41894. * @returns The loaded plugin
  41895. */
  41896. 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>;
  41897. /**
  41898. * Load a scene
  41899. * @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)
  41900. * @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)
  41901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41902. * @param onProgress a callback with a progress event for each file being loaded
  41903. * @param pluginExtension the extension used to determine the plugin
  41904. * @returns The loaded scene
  41905. */
  41906. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41907. /**
  41908. * Append a scene
  41909. * @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)
  41910. * @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)
  41911. * @param scene is the instance of BABYLON.Scene to append to
  41912. * @param onSuccess a callback with the scene when import succeeds
  41913. * @param onProgress a callback with a progress event for each file being loaded
  41914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41915. * @param pluginExtension the extension used to determine the plugin
  41916. * @returns The loaded plugin
  41917. */
  41918. 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>;
  41919. /**
  41920. * Append a scene
  41921. * @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)
  41922. * @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)
  41923. * @param scene is the instance of BABYLON.Scene to append to
  41924. * @param onProgress a callback with a progress event for each file being loaded
  41925. * @param pluginExtension the extension used to determine the plugin
  41926. * @returns The given scene
  41927. */
  41928. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41929. /**
  41930. * Load a scene into an asset container
  41931. * @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)
  41932. * @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)
  41933. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41934. * @param onSuccess a callback with the scene when import succeeds
  41935. * @param onProgress a callback with a progress event for each file being loaded
  41936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41937. * @param pluginExtension the extension used to determine the plugin
  41938. * @returns The loaded plugin
  41939. */
  41940. 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>;
  41941. /**
  41942. * Load a scene into an asset container
  41943. * @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)
  41944. * @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)
  41945. * @param scene is the instance of Scene to append to
  41946. * @param onProgress a callback with a progress event for each file being loaded
  41947. * @param pluginExtension the extension used to determine the plugin
  41948. * @returns The loaded asset container
  41949. */
  41950. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41951. }
  41952. }
  41953. declare module BABYLON {
  41954. /**
  41955. * Generic Controller
  41956. */
  41957. export class GenericController extends WebVRController {
  41958. /**
  41959. * Base Url for the controller model.
  41960. */
  41961. static readonly MODEL_BASE_URL: string;
  41962. /**
  41963. * File name for the controller model.
  41964. */
  41965. static readonly MODEL_FILENAME: string;
  41966. /**
  41967. * Creates a new GenericController from a gamepad
  41968. * @param vrGamepad the gamepad that the controller should be created from
  41969. */
  41970. constructor(vrGamepad: any);
  41971. /**
  41972. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41973. * @param scene scene in which to add meshes
  41974. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41975. */
  41976. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41977. /**
  41978. * Called once for each button that changed state since the last frame
  41979. * @param buttonIdx Which button index changed
  41980. * @param state New state of the button
  41981. * @param changes Which properties on the state changed since last frame
  41982. */
  41983. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41984. }
  41985. }
  41986. declare module BABYLON {
  41987. /**
  41988. * Defines the WindowsMotionController object that the state of the windows motion controller
  41989. */
  41990. export class WindowsMotionController extends WebVRController {
  41991. /**
  41992. * The base url used to load the left and right controller models
  41993. */
  41994. static MODEL_BASE_URL: string;
  41995. /**
  41996. * The name of the left controller model file
  41997. */
  41998. static MODEL_LEFT_FILENAME: string;
  41999. /**
  42000. * The name of the right controller model file
  42001. */
  42002. static MODEL_RIGHT_FILENAME: string;
  42003. /**
  42004. * The controller name prefix for this controller type
  42005. */
  42006. static readonly GAMEPAD_ID_PREFIX: string;
  42007. /**
  42008. * The controller id pattern for this controller type
  42009. */
  42010. private static readonly GAMEPAD_ID_PATTERN;
  42011. private _loadedMeshInfo;
  42012. private readonly _mapping;
  42013. /**
  42014. * Fired when the trackpad on this controller is clicked
  42015. */
  42016. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42017. /**
  42018. * Fired when the trackpad on this controller is modified
  42019. */
  42020. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42021. /**
  42022. * The current x and y values of this controller's trackpad
  42023. */
  42024. trackpad: StickValues;
  42025. /**
  42026. * Creates a new WindowsMotionController from a gamepad
  42027. * @param vrGamepad the gamepad that the controller should be created from
  42028. */
  42029. constructor(vrGamepad: any);
  42030. /**
  42031. * Fired when the trigger on this controller is modified
  42032. */
  42033. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42034. /**
  42035. * Fired when the menu button on this controller is modified
  42036. */
  42037. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42038. /**
  42039. * Fired when the grip button on this controller is modified
  42040. */
  42041. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42042. /**
  42043. * Fired when the thumbstick button on this controller is modified
  42044. */
  42045. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42046. /**
  42047. * Fired when the touchpad button on this controller is modified
  42048. */
  42049. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42050. /**
  42051. * Fired when the touchpad values on this controller are modified
  42052. */
  42053. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42054. private _updateTrackpad;
  42055. /**
  42056. * Called once per frame by the engine.
  42057. */
  42058. update(): void;
  42059. /**
  42060. * Called once for each button that changed state since the last frame
  42061. * @param buttonIdx Which button index changed
  42062. * @param state New state of the button
  42063. * @param changes Which properties on the state changed since last frame
  42064. */
  42065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42066. /**
  42067. * Moves the buttons on the controller mesh based on their current state
  42068. * @param buttonName the name of the button to move
  42069. * @param buttonValue the value of the button which determines the buttons new position
  42070. */
  42071. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42072. /**
  42073. * Moves the axis on the controller mesh based on its current state
  42074. * @param axis the index of the axis
  42075. * @param axisValue the value of the axis which determines the meshes new position
  42076. * @hidden
  42077. */
  42078. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42079. /**
  42080. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42081. * @param scene scene in which to add meshes
  42082. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42083. */
  42084. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42085. /**
  42086. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42087. * can be transformed by button presses and axes values, based on this._mapping.
  42088. *
  42089. * @param scene scene in which the meshes exist
  42090. * @param meshes list of meshes that make up the controller model to process
  42091. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42092. */
  42093. private processModel;
  42094. private createMeshInfo;
  42095. /**
  42096. * Gets the ray of the controller in the direction the controller is pointing
  42097. * @param length the length the resulting ray should be
  42098. * @returns a ray in the direction the controller is pointing
  42099. */
  42100. getForwardRay(length?: number): Ray;
  42101. /**
  42102. * Disposes of the controller
  42103. */
  42104. dispose(): void;
  42105. }
  42106. }
  42107. declare module BABYLON {
  42108. /**
  42109. * Oculus Touch Controller
  42110. */
  42111. export class OculusTouchController extends WebVRController {
  42112. /**
  42113. * Base Url for the controller model.
  42114. */
  42115. static MODEL_BASE_URL: string;
  42116. /**
  42117. * File name for the left controller model.
  42118. */
  42119. static MODEL_LEFT_FILENAME: string;
  42120. /**
  42121. * File name for the right controller model.
  42122. */
  42123. static MODEL_RIGHT_FILENAME: string;
  42124. /**
  42125. * Base Url for the Quest controller model.
  42126. */
  42127. static QUEST_MODEL_BASE_URL: string;
  42128. /**
  42129. * @hidden
  42130. * If the controllers are running on a device that needs the updated Quest controller models
  42131. */
  42132. static _IsQuest: boolean;
  42133. /**
  42134. * Fired when the secondary trigger on this controller is modified
  42135. */
  42136. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42137. /**
  42138. * Fired when the thumb rest on this controller is modified
  42139. */
  42140. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42141. /**
  42142. * Creates a new OculusTouchController from a gamepad
  42143. * @param vrGamepad the gamepad that the controller should be created from
  42144. */
  42145. constructor(vrGamepad: any);
  42146. /**
  42147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42148. * @param scene scene in which to add meshes
  42149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42150. */
  42151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42152. /**
  42153. * Fired when the A button on this controller is modified
  42154. */
  42155. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42156. /**
  42157. * Fired when the B button on this controller is modified
  42158. */
  42159. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42160. /**
  42161. * Fired when the X button on this controller is modified
  42162. */
  42163. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42164. /**
  42165. * Fired when the Y button on this controller is modified
  42166. */
  42167. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42168. /**
  42169. * Called once for each button that changed state since the last frame
  42170. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42171. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42172. * 2) secondary trigger (same)
  42173. * 3) A (right) X (left), touch, pressed = value
  42174. * 4) B / Y
  42175. * 5) thumb rest
  42176. * @param buttonIdx Which button index changed
  42177. * @param state New state of the button
  42178. * @param changes Which properties on the state changed since last frame
  42179. */
  42180. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42181. }
  42182. }
  42183. declare module BABYLON {
  42184. /**
  42185. * Vive Controller
  42186. */
  42187. export class ViveController extends WebVRController {
  42188. /**
  42189. * Base Url for the controller model.
  42190. */
  42191. static MODEL_BASE_URL: string;
  42192. /**
  42193. * File name for the controller model.
  42194. */
  42195. static MODEL_FILENAME: string;
  42196. /**
  42197. * Creates a new ViveController from a gamepad
  42198. * @param vrGamepad the gamepad that the controller should be created from
  42199. */
  42200. constructor(vrGamepad: any);
  42201. /**
  42202. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42203. * @param scene scene in which to add meshes
  42204. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42205. */
  42206. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42207. /**
  42208. * Fired when the left button on this controller is modified
  42209. */
  42210. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42211. /**
  42212. * Fired when the right button on this controller is modified
  42213. */
  42214. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42215. /**
  42216. * Fired when the menu button on this controller is modified
  42217. */
  42218. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42219. /**
  42220. * Called once for each button that changed state since the last frame
  42221. * Vive mapping:
  42222. * 0: touchpad
  42223. * 1: trigger
  42224. * 2: left AND right buttons
  42225. * 3: menu button
  42226. * @param buttonIdx Which button index changed
  42227. * @param state New state of the button
  42228. * @param changes Which properties on the state changed since last frame
  42229. */
  42230. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /**
  42235. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42236. */
  42237. export class WebXRControllerModelLoader {
  42238. /**
  42239. * Creates the WebXRControllerModelLoader
  42240. * @param input xr input that creates the controllers
  42241. */
  42242. constructor(input: WebXRInput);
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * Contains an array of blocks representing the octree
  42248. */
  42249. export interface IOctreeContainer<T> {
  42250. /**
  42251. * Blocks within the octree
  42252. */
  42253. blocks: Array<OctreeBlock<T>>;
  42254. }
  42255. /**
  42256. * Class used to store a cell in an octree
  42257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42258. */
  42259. export class OctreeBlock<T> {
  42260. /**
  42261. * Gets the content of the current block
  42262. */
  42263. entries: T[];
  42264. /**
  42265. * Gets the list of block children
  42266. */
  42267. blocks: Array<OctreeBlock<T>>;
  42268. private _depth;
  42269. private _maxDepth;
  42270. private _capacity;
  42271. private _minPoint;
  42272. private _maxPoint;
  42273. private _boundingVectors;
  42274. private _creationFunc;
  42275. /**
  42276. * Creates a new block
  42277. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42278. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42279. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42280. * @param depth defines the current depth of this block in the octree
  42281. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42282. * @param creationFunc defines a callback to call when an element is added to the block
  42283. */
  42284. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42285. /**
  42286. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42287. */
  42288. readonly capacity: number;
  42289. /**
  42290. * Gets the minimum vector (in world space) of the block's bounding box
  42291. */
  42292. readonly minPoint: Vector3;
  42293. /**
  42294. * Gets the maximum vector (in world space) of the block's bounding box
  42295. */
  42296. readonly maxPoint: Vector3;
  42297. /**
  42298. * Add a new element to this block
  42299. * @param entry defines the element to add
  42300. */
  42301. addEntry(entry: T): void;
  42302. /**
  42303. * Remove an element from this block
  42304. * @param entry defines the element to remove
  42305. */
  42306. removeEntry(entry: T): void;
  42307. /**
  42308. * Add an array of elements to this block
  42309. * @param entries defines the array of elements to add
  42310. */
  42311. addEntries(entries: T[]): void;
  42312. /**
  42313. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42314. * @param frustumPlanes defines the frustum planes to test
  42315. * @param selection defines the array to store current content if selection is positive
  42316. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42317. */
  42318. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42319. /**
  42320. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42321. * @param sphereCenter defines the bounding sphere center
  42322. * @param sphereRadius defines the bounding sphere radius
  42323. * @param selection defines the array to store current content if selection is positive
  42324. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42325. */
  42326. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42327. /**
  42328. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42329. * @param ray defines the ray to test with
  42330. * @param selection defines the array to store current content if selection is positive
  42331. */
  42332. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42333. /**
  42334. * Subdivide the content into child blocks (this block will then be empty)
  42335. */
  42336. createInnerBlocks(): void;
  42337. /**
  42338. * @hidden
  42339. */
  42340. 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;
  42341. }
  42342. }
  42343. declare module BABYLON {
  42344. /**
  42345. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42347. */
  42348. export class Octree<T> {
  42349. /** 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.) */
  42350. maxDepth: number;
  42351. /**
  42352. * Blocks within the octree containing objects
  42353. */
  42354. blocks: Array<OctreeBlock<T>>;
  42355. /**
  42356. * Content stored in the octree
  42357. */
  42358. dynamicContent: T[];
  42359. private _maxBlockCapacity;
  42360. private _selectionContent;
  42361. private _creationFunc;
  42362. /**
  42363. * Creates a octree
  42364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42365. * @param creationFunc function to be used to instatiate the octree
  42366. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42367. * @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.)
  42368. */
  42369. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42370. /** 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.) */
  42371. maxDepth?: number);
  42372. /**
  42373. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42374. * @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);
  42375. * @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);
  42376. * @param entries meshes to be added to the octree blocks
  42377. */
  42378. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42379. /**
  42380. * Adds a mesh to the octree
  42381. * @param entry Mesh to add to the octree
  42382. */
  42383. addMesh(entry: T): void;
  42384. /**
  42385. * Remove an element from the octree
  42386. * @param entry defines the element to remove
  42387. */
  42388. removeMesh(entry: T): void;
  42389. /**
  42390. * Selects an array of meshes within the frustum
  42391. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42392. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42393. * @returns array of meshes within the frustum
  42394. */
  42395. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42396. /**
  42397. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42398. * @param sphereCenter defines the bounding sphere center
  42399. * @param sphereRadius defines the bounding sphere radius
  42400. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42401. * @returns an array of objects that intersect the sphere
  42402. */
  42403. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42404. /**
  42405. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42406. * @param ray defines the ray to test with
  42407. * @returns array of intersected objects
  42408. */
  42409. intersectsRay(ray: Ray): SmartArray<T>;
  42410. /**
  42411. * Adds a mesh into the octree block if it intersects the block
  42412. */
  42413. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42414. /**
  42415. * Adds a submesh into the octree block if it intersects the block
  42416. */
  42417. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42418. }
  42419. }
  42420. declare module BABYLON {
  42421. interface Scene {
  42422. /**
  42423. * @hidden
  42424. * Backing Filed
  42425. */
  42426. _selectionOctree: Octree<AbstractMesh>;
  42427. /**
  42428. * Gets the octree used to boost mesh selection (picking)
  42429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42430. */
  42431. selectionOctree: Octree<AbstractMesh>;
  42432. /**
  42433. * Creates or updates the octree used to boost selection (picking)
  42434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42435. * @param maxCapacity defines the maximum capacity per leaf
  42436. * @param maxDepth defines the maximum depth of the octree
  42437. * @returns an octree of AbstractMesh
  42438. */
  42439. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42440. }
  42441. interface AbstractMesh {
  42442. /**
  42443. * @hidden
  42444. * Backing Field
  42445. */
  42446. _submeshesOctree: Octree<SubMesh>;
  42447. /**
  42448. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42449. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42450. * @param maxCapacity defines the maximum size of each block (64 by default)
  42451. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42452. * @returns the new octree
  42453. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42455. */
  42456. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42457. }
  42458. /**
  42459. * Defines the octree scene component responsible to manage any octrees
  42460. * in a given scene.
  42461. */
  42462. export class OctreeSceneComponent {
  42463. /**
  42464. * The component name help to identify the component in the list of scene components.
  42465. */
  42466. readonly name: string;
  42467. /**
  42468. * The scene the component belongs to.
  42469. */
  42470. scene: Scene;
  42471. /**
  42472. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42473. */
  42474. readonly checksIsEnabled: boolean;
  42475. /**
  42476. * Creates a new instance of the component for the given scene
  42477. * @param scene Defines the scene to register the component in
  42478. */
  42479. constructor(scene: Scene);
  42480. /**
  42481. * Registers the component in a given scene
  42482. */
  42483. register(): void;
  42484. /**
  42485. * Return the list of active meshes
  42486. * @returns the list of active meshes
  42487. */
  42488. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42489. /**
  42490. * Return the list of active sub meshes
  42491. * @param mesh The mesh to get the candidates sub meshes from
  42492. * @returns the list of active sub meshes
  42493. */
  42494. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42495. private _tempRay;
  42496. /**
  42497. * Return the list of sub meshes intersecting with a given local ray
  42498. * @param mesh defines the mesh to find the submesh for
  42499. * @param localRay defines the ray in local space
  42500. * @returns the list of intersecting sub meshes
  42501. */
  42502. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42503. /**
  42504. * Return the list of sub meshes colliding with a collider
  42505. * @param mesh defines the mesh to find the submesh for
  42506. * @param collider defines the collider to evaluate the collision against
  42507. * @returns the list of colliding sub meshes
  42508. */
  42509. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42510. /**
  42511. * Rebuilds the elements related to this component in case of
  42512. * context lost for instance.
  42513. */
  42514. rebuild(): void;
  42515. /**
  42516. * Disposes the component and the associated ressources.
  42517. */
  42518. dispose(): void;
  42519. }
  42520. }
  42521. declare module BABYLON {
  42522. /**
  42523. * Renders a layer on top of an existing scene
  42524. */
  42525. export class UtilityLayerRenderer implements IDisposable {
  42526. /** the original scene that will be rendered on top of */
  42527. originalScene: Scene;
  42528. private _pointerCaptures;
  42529. private _lastPointerEvents;
  42530. private static _DefaultUtilityLayer;
  42531. private static _DefaultKeepDepthUtilityLayer;
  42532. private _sharedGizmoLight;
  42533. private _renderCamera;
  42534. /**
  42535. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42536. * @returns the camera that is used when rendering the utility layer
  42537. */
  42538. getRenderCamera(): Nullable<Camera>;
  42539. /**
  42540. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42541. * @param cam the camera that should be used when rendering the utility layer
  42542. */
  42543. setRenderCamera(cam: Nullable<Camera>): void;
  42544. /**
  42545. * @hidden
  42546. * Light which used by gizmos to get light shading
  42547. */
  42548. _getSharedGizmoLight(): HemisphericLight;
  42549. /**
  42550. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42551. */
  42552. pickUtilitySceneFirst: boolean;
  42553. /**
  42554. * 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)
  42555. */
  42556. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42557. /**
  42558. * 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)
  42559. */
  42560. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42561. /**
  42562. * The scene that is rendered on top of the original scene
  42563. */
  42564. utilityLayerScene: Scene;
  42565. /**
  42566. * If the utility layer should automatically be rendered on top of existing scene
  42567. */
  42568. shouldRender: boolean;
  42569. /**
  42570. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42571. */
  42572. onlyCheckPointerDownEvents: boolean;
  42573. /**
  42574. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42575. */
  42576. processAllEvents: boolean;
  42577. /**
  42578. * Observable raised when the pointer move from the utility layer scene to the main scene
  42579. */
  42580. onPointerOutObservable: Observable<number>;
  42581. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42582. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42583. private _afterRenderObserver;
  42584. private _sceneDisposeObserver;
  42585. private _originalPointerObserver;
  42586. /**
  42587. * Instantiates a UtilityLayerRenderer
  42588. * @param originalScene the original scene that will be rendered on top of
  42589. * @param handleEvents boolean indicating if the utility layer should handle events
  42590. */
  42591. constructor(
  42592. /** the original scene that will be rendered on top of */
  42593. originalScene: Scene, handleEvents?: boolean);
  42594. private _notifyObservers;
  42595. /**
  42596. * Renders the utility layers scene on top of the original scene
  42597. */
  42598. render(): void;
  42599. /**
  42600. * Disposes of the renderer
  42601. */
  42602. dispose(): void;
  42603. private _updateCamera;
  42604. }
  42605. }
  42606. declare module BABYLON {
  42607. /**
  42608. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42609. */
  42610. export class Gizmo implements IDisposable {
  42611. /** The utility layer the gizmo will be added to */
  42612. gizmoLayer: UtilityLayerRenderer;
  42613. /**
  42614. * The root mesh of the gizmo
  42615. */
  42616. _rootMesh: Mesh;
  42617. private _attachedMesh;
  42618. /**
  42619. * Ratio for the scale of the gizmo (Default: 1)
  42620. */
  42621. scaleRatio: number;
  42622. /**
  42623. * If a custom mesh has been set (Default: false)
  42624. */
  42625. protected _customMeshSet: boolean;
  42626. /**
  42627. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42628. * * When set, interactions will be enabled
  42629. */
  42630. attachedMesh: Nullable<AbstractMesh>;
  42631. /**
  42632. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42633. * @param mesh The mesh to replace the default mesh of the gizmo
  42634. */
  42635. setCustomMesh(mesh: Mesh): void;
  42636. /**
  42637. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42638. */
  42639. updateGizmoRotationToMatchAttachedMesh: boolean;
  42640. /**
  42641. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42642. */
  42643. updateGizmoPositionToMatchAttachedMesh: boolean;
  42644. /**
  42645. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42646. */
  42647. updateScale: boolean;
  42648. protected _interactionsEnabled: boolean;
  42649. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42650. private _beforeRenderObserver;
  42651. private _tempVector;
  42652. /**
  42653. * Creates a gizmo
  42654. * @param gizmoLayer The utility layer the gizmo will be added to
  42655. */
  42656. constructor(
  42657. /** The utility layer the gizmo will be added to */
  42658. gizmoLayer?: UtilityLayerRenderer);
  42659. /**
  42660. * Updates the gizmo to match the attached mesh's position/rotation
  42661. */
  42662. protected _update(): void;
  42663. /**
  42664. * Disposes of the gizmo
  42665. */
  42666. dispose(): void;
  42667. }
  42668. }
  42669. declare module BABYLON {
  42670. /**
  42671. * Single plane drag gizmo
  42672. */
  42673. export class PlaneDragGizmo extends Gizmo {
  42674. /**
  42675. * Drag behavior responsible for the gizmos dragging interactions
  42676. */
  42677. dragBehavior: PointerDragBehavior;
  42678. private _pointerObserver;
  42679. /**
  42680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42681. */
  42682. snapDistance: number;
  42683. /**
  42684. * Event that fires each time the gizmo snaps to a new location.
  42685. * * snapDistance is the the change in distance
  42686. */
  42687. onSnapObservable: Observable<{
  42688. snapDistance: number;
  42689. }>;
  42690. private _plane;
  42691. private _coloredMaterial;
  42692. private _hoverMaterial;
  42693. private _isEnabled;
  42694. private _parent;
  42695. /** @hidden */
  42696. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42697. /** @hidden */
  42698. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42699. /**
  42700. * Creates a PlaneDragGizmo
  42701. * @param gizmoLayer The utility layer the gizmo will be added to
  42702. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42703. * @param color The color of the gizmo
  42704. */
  42705. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42706. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42707. /**
  42708. * If the gizmo is enabled
  42709. */
  42710. isEnabled: boolean;
  42711. /**
  42712. * Disposes of the gizmo
  42713. */
  42714. dispose(): void;
  42715. }
  42716. }
  42717. declare module BABYLON {
  42718. /**
  42719. * Gizmo that enables dragging a mesh along 3 axis
  42720. */
  42721. export class PositionGizmo extends Gizmo {
  42722. /**
  42723. * Internal gizmo used for interactions on the x axis
  42724. */
  42725. xGizmo: AxisDragGizmo;
  42726. /**
  42727. * Internal gizmo used for interactions on the y axis
  42728. */
  42729. yGizmo: AxisDragGizmo;
  42730. /**
  42731. * Internal gizmo used for interactions on the z axis
  42732. */
  42733. zGizmo: AxisDragGizmo;
  42734. /**
  42735. * Internal gizmo used for interactions on the yz plane
  42736. */
  42737. xPlaneGizmo: PlaneDragGizmo;
  42738. /**
  42739. * Internal gizmo used for interactions on the xz plane
  42740. */
  42741. yPlaneGizmo: PlaneDragGizmo;
  42742. /**
  42743. * Internal gizmo used for interactions on the xy plane
  42744. */
  42745. zPlaneGizmo: PlaneDragGizmo;
  42746. /**
  42747. * private variables
  42748. */
  42749. private _meshAttached;
  42750. private _updateGizmoRotationToMatchAttachedMesh;
  42751. private _snapDistance;
  42752. private _scaleRatio;
  42753. /** Fires an event when any of it's sub gizmos are dragged */
  42754. onDragStartObservable: Observable<unknown>;
  42755. /** Fires an event when any of it's sub gizmos are released from dragging */
  42756. onDragEndObservable: Observable<unknown>;
  42757. /**
  42758. * If set to true, planar drag is enabled
  42759. */
  42760. private _planarGizmoEnabled;
  42761. attachedMesh: Nullable<AbstractMesh>;
  42762. /**
  42763. * Creates a PositionGizmo
  42764. * @param gizmoLayer The utility layer the gizmo will be added to
  42765. */
  42766. constructor(gizmoLayer?: UtilityLayerRenderer);
  42767. /**
  42768. * If the planar drag gizmo is enabled
  42769. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42770. */
  42771. planarGizmoEnabled: boolean;
  42772. updateGizmoRotationToMatchAttachedMesh: boolean;
  42773. /**
  42774. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42775. */
  42776. snapDistance: number;
  42777. /**
  42778. * Ratio for the scale of the gizmo (Default: 1)
  42779. */
  42780. scaleRatio: number;
  42781. /**
  42782. * Disposes of the gizmo
  42783. */
  42784. dispose(): void;
  42785. /**
  42786. * CustomMeshes are not supported by this gizmo
  42787. * @param mesh The mesh to replace the default mesh of the gizmo
  42788. */
  42789. setCustomMesh(mesh: Mesh): void;
  42790. }
  42791. }
  42792. declare module BABYLON {
  42793. /**
  42794. * Single axis drag gizmo
  42795. */
  42796. export class AxisDragGizmo extends Gizmo {
  42797. /**
  42798. * Drag behavior responsible for the gizmos dragging interactions
  42799. */
  42800. dragBehavior: PointerDragBehavior;
  42801. private _pointerObserver;
  42802. /**
  42803. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42804. */
  42805. snapDistance: number;
  42806. /**
  42807. * Event that fires each time the gizmo snaps to a new location.
  42808. * * snapDistance is the the change in distance
  42809. */
  42810. onSnapObservable: Observable<{
  42811. snapDistance: number;
  42812. }>;
  42813. private _isEnabled;
  42814. private _parent;
  42815. private _arrow;
  42816. private _coloredMaterial;
  42817. private _hoverMaterial;
  42818. /** @hidden */
  42819. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42820. /** @hidden */
  42821. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42822. /**
  42823. * Creates an AxisDragGizmo
  42824. * @param gizmoLayer The utility layer the gizmo will be added to
  42825. * @param dragAxis The axis which the gizmo will be able to drag on
  42826. * @param color The color of the gizmo
  42827. */
  42828. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42830. /**
  42831. * If the gizmo is enabled
  42832. */
  42833. isEnabled: boolean;
  42834. /**
  42835. * Disposes of the gizmo
  42836. */
  42837. dispose(): void;
  42838. }
  42839. }
  42840. declare module BABYLON.Debug {
  42841. /**
  42842. * The Axes viewer will show 3 axes in a specific point in space
  42843. */
  42844. export class AxesViewer {
  42845. private _xAxis;
  42846. private _yAxis;
  42847. private _zAxis;
  42848. private _scaleLinesFactor;
  42849. private _instanced;
  42850. /**
  42851. * Gets the hosting scene
  42852. */
  42853. scene: Scene;
  42854. /**
  42855. * Gets or sets a number used to scale line length
  42856. */
  42857. scaleLines: number;
  42858. /** Gets the node hierarchy used to render x-axis */
  42859. readonly xAxis: TransformNode;
  42860. /** Gets the node hierarchy used to render y-axis */
  42861. readonly yAxis: TransformNode;
  42862. /** Gets the node hierarchy used to render z-axis */
  42863. readonly zAxis: TransformNode;
  42864. /**
  42865. * Creates a new AxesViewer
  42866. * @param scene defines the hosting scene
  42867. * @param scaleLines defines a number used to scale line length (1 by default)
  42868. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42869. * @param xAxis defines the node hierarchy used to render the x-axis
  42870. * @param yAxis defines the node hierarchy used to render the y-axis
  42871. * @param zAxis defines the node hierarchy used to render the z-axis
  42872. */
  42873. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42874. /**
  42875. * Force the viewer to update
  42876. * @param position defines the position of the viewer
  42877. * @param xaxis defines the x axis of the viewer
  42878. * @param yaxis defines the y axis of the viewer
  42879. * @param zaxis defines the z axis of the viewer
  42880. */
  42881. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42882. /**
  42883. * Creates an instance of this axes viewer.
  42884. * @returns a new axes viewer with instanced meshes
  42885. */
  42886. createInstance(): AxesViewer;
  42887. /** Releases resources */
  42888. dispose(): void;
  42889. private static _SetRenderingGroupId;
  42890. }
  42891. }
  42892. declare module BABYLON.Debug {
  42893. /**
  42894. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42895. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42896. */
  42897. export class BoneAxesViewer extends AxesViewer {
  42898. /**
  42899. * Gets or sets the target mesh where to display the axes viewer
  42900. */
  42901. mesh: Nullable<Mesh>;
  42902. /**
  42903. * Gets or sets the target bone where to display the axes viewer
  42904. */
  42905. bone: Nullable<Bone>;
  42906. /** Gets current position */
  42907. pos: Vector3;
  42908. /** Gets direction of X axis */
  42909. xaxis: Vector3;
  42910. /** Gets direction of Y axis */
  42911. yaxis: Vector3;
  42912. /** Gets direction of Z axis */
  42913. zaxis: Vector3;
  42914. /**
  42915. * Creates a new BoneAxesViewer
  42916. * @param scene defines the hosting scene
  42917. * @param bone defines the target bone
  42918. * @param mesh defines the target mesh
  42919. * @param scaleLines defines a scaling factor for line length (1 by default)
  42920. */
  42921. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42922. /**
  42923. * Force the viewer to update
  42924. */
  42925. update(): void;
  42926. /** Releases resources */
  42927. dispose(): void;
  42928. }
  42929. }
  42930. declare module BABYLON {
  42931. /**
  42932. * Interface used to define scene explorer extensibility option
  42933. */
  42934. export interface IExplorerExtensibilityOption {
  42935. /**
  42936. * Define the option label
  42937. */
  42938. label: string;
  42939. /**
  42940. * Defines the action to execute on click
  42941. */
  42942. action: (entity: any) => void;
  42943. }
  42944. /**
  42945. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42946. */
  42947. export interface IExplorerExtensibilityGroup {
  42948. /**
  42949. * Defines a predicate to test if a given type mut be extended
  42950. */
  42951. predicate: (entity: any) => boolean;
  42952. /**
  42953. * Gets the list of options added to a type
  42954. */
  42955. entries: IExplorerExtensibilityOption[];
  42956. }
  42957. /**
  42958. * Interface used to define the options to use to create the Inspector
  42959. */
  42960. export interface IInspectorOptions {
  42961. /**
  42962. * Display in overlay mode (default: false)
  42963. */
  42964. overlay?: boolean;
  42965. /**
  42966. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42967. */
  42968. globalRoot?: HTMLElement;
  42969. /**
  42970. * Display the Scene explorer
  42971. */
  42972. showExplorer?: boolean;
  42973. /**
  42974. * Display the property inspector
  42975. */
  42976. showInspector?: boolean;
  42977. /**
  42978. * Display in embed mode (both panes on the right)
  42979. */
  42980. embedMode?: boolean;
  42981. /**
  42982. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42983. */
  42984. handleResize?: boolean;
  42985. /**
  42986. * Allow the panes to popup (default: true)
  42987. */
  42988. enablePopup?: boolean;
  42989. /**
  42990. * Allow the panes to be closed by users (default: true)
  42991. */
  42992. enableClose?: boolean;
  42993. /**
  42994. * Optional list of extensibility entries
  42995. */
  42996. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42997. /**
  42998. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42999. */
  43000. inspectorURL?: string;
  43001. }
  43002. interface Scene {
  43003. /**
  43004. * @hidden
  43005. * Backing field
  43006. */
  43007. _debugLayer: DebugLayer;
  43008. /**
  43009. * Gets the debug layer (aka Inspector) associated with the scene
  43010. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43011. */
  43012. debugLayer: DebugLayer;
  43013. }
  43014. /**
  43015. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43016. * what is happening in your scene
  43017. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43018. */
  43019. export class DebugLayer {
  43020. /**
  43021. * Define the url to get the inspector script from.
  43022. * By default it uses the babylonjs CDN.
  43023. * @ignoreNaming
  43024. */
  43025. static InspectorURL: string;
  43026. private _scene;
  43027. private BJSINSPECTOR;
  43028. private _onPropertyChangedObservable?;
  43029. /**
  43030. * Observable triggered when a property is changed through the inspector.
  43031. */
  43032. readonly onPropertyChangedObservable: any;
  43033. /**
  43034. * Instantiates a new debug layer.
  43035. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43036. * what is happening in your scene
  43037. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43038. * @param scene Defines the scene to inspect
  43039. */
  43040. constructor(scene: Scene);
  43041. /** Creates the inspector window. */
  43042. private _createInspector;
  43043. /**
  43044. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43045. * @param entity defines the entity to select
  43046. * @param lineContainerTitle defines the specific block to highlight
  43047. */
  43048. select(entity: any, lineContainerTitle?: string): void;
  43049. /** Get the inspector from bundle or global */
  43050. private _getGlobalInspector;
  43051. /**
  43052. * Get if the inspector is visible or not.
  43053. * @returns true if visible otherwise, false
  43054. */
  43055. isVisible(): boolean;
  43056. /**
  43057. * Hide the inspector and close its window.
  43058. */
  43059. hide(): void;
  43060. /**
  43061. * Launch the debugLayer.
  43062. * @param config Define the configuration of the inspector
  43063. * @return a promise fulfilled when the debug layer is visible
  43064. */
  43065. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43066. }
  43067. }
  43068. declare module BABYLON {
  43069. /**
  43070. * Class containing static functions to help procedurally build meshes
  43071. */
  43072. export class BoxBuilder {
  43073. /**
  43074. * Creates a box mesh
  43075. * * The parameter `size` sets the size (float) of each box side (default 1)
  43076. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43077. * * 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)
  43078. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43080. * * 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
  43081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43082. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43083. * @param name defines the name of the mesh
  43084. * @param options defines the options used to create the mesh
  43085. * @param scene defines the hosting scene
  43086. * @returns the box mesh
  43087. */
  43088. static CreateBox(name: string, options: {
  43089. size?: number;
  43090. width?: number;
  43091. height?: number;
  43092. depth?: number;
  43093. faceUV?: Vector4[];
  43094. faceColors?: Color4[];
  43095. sideOrientation?: number;
  43096. frontUVs?: Vector4;
  43097. backUVs?: Vector4;
  43098. wrap?: boolean;
  43099. topBaseAt?: number;
  43100. bottomBaseAt?: number;
  43101. updatable?: boolean;
  43102. }, scene?: Nullable<Scene>): Mesh;
  43103. }
  43104. }
  43105. declare module BABYLON {
  43106. /**
  43107. * Class containing static functions to help procedurally build meshes
  43108. */
  43109. export class SphereBuilder {
  43110. /**
  43111. * Creates a sphere mesh
  43112. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43113. * * 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`)
  43114. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43115. * * 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
  43116. * * 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)
  43117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43118. * * 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
  43119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43120. * @param name defines the name of the mesh
  43121. * @param options defines the options used to create the mesh
  43122. * @param scene defines the hosting scene
  43123. * @returns the sphere mesh
  43124. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43125. */
  43126. static CreateSphere(name: string, options: {
  43127. segments?: number;
  43128. diameter?: number;
  43129. diameterX?: number;
  43130. diameterY?: number;
  43131. diameterZ?: number;
  43132. arc?: number;
  43133. slice?: number;
  43134. sideOrientation?: number;
  43135. frontUVs?: Vector4;
  43136. backUVs?: Vector4;
  43137. updatable?: boolean;
  43138. }, scene?: Nullable<Scene>): Mesh;
  43139. }
  43140. }
  43141. declare module BABYLON.Debug {
  43142. /**
  43143. * Used to show the physics impostor around the specific mesh
  43144. */
  43145. export class PhysicsViewer {
  43146. /** @hidden */
  43147. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43148. /** @hidden */
  43149. protected _meshes: Array<Nullable<AbstractMesh>>;
  43150. /** @hidden */
  43151. protected _scene: Nullable<Scene>;
  43152. /** @hidden */
  43153. protected _numMeshes: number;
  43154. /** @hidden */
  43155. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43156. private _renderFunction;
  43157. private _utilityLayer;
  43158. private _debugBoxMesh;
  43159. private _debugSphereMesh;
  43160. private _debugCylinderMesh;
  43161. private _debugMaterial;
  43162. private _debugMeshMeshes;
  43163. /**
  43164. * Creates a new PhysicsViewer
  43165. * @param scene defines the hosting scene
  43166. */
  43167. constructor(scene: Scene);
  43168. /** @hidden */
  43169. protected _updateDebugMeshes(): void;
  43170. /**
  43171. * Renders a specified physic impostor
  43172. * @param impostor defines the impostor to render
  43173. * @param targetMesh defines the mesh represented by the impostor
  43174. * @returns the new debug mesh used to render the impostor
  43175. */
  43176. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43177. /**
  43178. * Hides a specified physic impostor
  43179. * @param impostor defines the impostor to hide
  43180. */
  43181. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43182. private _getDebugMaterial;
  43183. private _getDebugBoxMesh;
  43184. private _getDebugSphereMesh;
  43185. private _getDebugCylinderMesh;
  43186. private _getDebugMeshMesh;
  43187. private _getDebugMesh;
  43188. /** Releases all resources */
  43189. dispose(): void;
  43190. }
  43191. }
  43192. declare module BABYLON {
  43193. /**
  43194. * Class containing static functions to help procedurally build meshes
  43195. */
  43196. export class LinesBuilder {
  43197. /**
  43198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43199. * * 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
  43200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43205. * * 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
  43206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43209. * @param name defines the name of the new line system
  43210. * @param options defines the options used to create the line system
  43211. * @param scene defines the hosting scene
  43212. * @returns a new line system mesh
  43213. */
  43214. static CreateLineSystem(name: string, options: {
  43215. lines: Vector3[][];
  43216. updatable?: boolean;
  43217. instance?: Nullable<LinesMesh>;
  43218. colors?: Nullable<Color4[][]>;
  43219. useVertexAlpha?: boolean;
  43220. }, scene: Nullable<Scene>): LinesMesh;
  43221. /**
  43222. * Creates a line mesh
  43223. * 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
  43224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43225. * * The parameter `points` is an array successive Vector3
  43226. * * 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
  43227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43229. * * When updating an instance, remember that only point positions can change, not the number of points
  43230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43232. * @param name defines the name of the new line system
  43233. * @param options defines the options used to create the line system
  43234. * @param scene defines the hosting scene
  43235. * @returns a new line mesh
  43236. */
  43237. static CreateLines(name: string, options: {
  43238. points: Vector3[];
  43239. updatable?: boolean;
  43240. instance?: Nullable<LinesMesh>;
  43241. colors?: Color4[];
  43242. useVertexAlpha?: boolean;
  43243. }, scene?: Nullable<Scene>): LinesMesh;
  43244. /**
  43245. * Creates a dashed line mesh
  43246. * * 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
  43247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43248. * * The parameter `points` is an array successive Vector3
  43249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43252. * * 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
  43253. * * When updating an instance, remember that only point positions can change, not the number of points
  43254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43255. * @param name defines the name of the mesh
  43256. * @param options defines the options used to create the mesh
  43257. * @param scene defines the hosting scene
  43258. * @returns the dashed line mesh
  43259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43260. */
  43261. static CreateDashedLines(name: string, options: {
  43262. points: Vector3[];
  43263. dashSize?: number;
  43264. gapSize?: number;
  43265. dashNb?: number;
  43266. updatable?: boolean;
  43267. instance?: LinesMesh;
  43268. }, scene?: Nullable<Scene>): LinesMesh;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /**
  43273. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43274. * in order to better appreciate the issue one might have.
  43275. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43276. */
  43277. export class RayHelper {
  43278. /**
  43279. * Defines the ray we are currently tryin to visualize.
  43280. */
  43281. ray: Nullable<Ray>;
  43282. private _renderPoints;
  43283. private _renderLine;
  43284. private _renderFunction;
  43285. private _scene;
  43286. private _updateToMeshFunction;
  43287. private _attachedToMesh;
  43288. private _meshSpaceDirection;
  43289. private _meshSpaceOrigin;
  43290. /**
  43291. * Helper function to create a colored helper in a scene in one line.
  43292. * @param ray Defines the ray we are currently tryin to visualize
  43293. * @param scene Defines the scene the ray is used in
  43294. * @param color Defines the color we want to see the ray in
  43295. * @returns The newly created ray helper.
  43296. */
  43297. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43298. /**
  43299. * Instantiate a new ray helper.
  43300. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43301. * in order to better appreciate the issue one might have.
  43302. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43303. * @param ray Defines the ray we are currently tryin to visualize
  43304. */
  43305. constructor(ray: Ray);
  43306. /**
  43307. * Shows the ray we are willing to debug.
  43308. * @param scene Defines the scene the ray needs to be rendered in
  43309. * @param color Defines the color the ray needs to be rendered in
  43310. */
  43311. show(scene: Scene, color?: Color3): void;
  43312. /**
  43313. * Hides the ray we are debugging.
  43314. */
  43315. hide(): void;
  43316. private _render;
  43317. /**
  43318. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43319. * @param mesh Defines the mesh we want the helper attached to
  43320. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43321. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43322. * @param length Defines the length of the ray
  43323. */
  43324. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43325. /**
  43326. * Detach the ray helper from the mesh it has previously been attached to.
  43327. */
  43328. detachFromMesh(): void;
  43329. private _updateToMesh;
  43330. /**
  43331. * Dispose the helper and release its associated resources.
  43332. */
  43333. dispose(): void;
  43334. }
  43335. }
  43336. declare module BABYLON.Debug {
  43337. /**
  43338. * Class used to render a debug view of a given skeleton
  43339. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43340. */
  43341. export class SkeletonViewer {
  43342. /** defines the skeleton to render */
  43343. skeleton: Skeleton;
  43344. /** defines the mesh attached to the skeleton */
  43345. mesh: AbstractMesh;
  43346. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43347. autoUpdateBonesMatrices: boolean;
  43348. /** defines the rendering group id to use with the viewer */
  43349. renderingGroupId: number;
  43350. /** Gets or sets the color used to render the skeleton */
  43351. color: Color3;
  43352. private _scene;
  43353. private _debugLines;
  43354. private _debugMesh;
  43355. private _isEnabled;
  43356. private _renderFunction;
  43357. private _utilityLayer;
  43358. /**
  43359. * Returns the mesh used to render the bones
  43360. */
  43361. readonly debugMesh: Nullable<LinesMesh>;
  43362. /**
  43363. * Creates a new SkeletonViewer
  43364. * @param skeleton defines the skeleton to render
  43365. * @param mesh defines the mesh attached to the skeleton
  43366. * @param scene defines the hosting scene
  43367. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43368. * @param renderingGroupId defines the rendering group id to use with the viewer
  43369. */
  43370. constructor(
  43371. /** defines the skeleton to render */
  43372. skeleton: Skeleton,
  43373. /** defines the mesh attached to the skeleton */
  43374. mesh: AbstractMesh, scene: Scene,
  43375. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43376. autoUpdateBonesMatrices?: boolean,
  43377. /** defines the rendering group id to use with the viewer */
  43378. renderingGroupId?: number);
  43379. /** Gets or sets a boolean indicating if the viewer is enabled */
  43380. isEnabled: boolean;
  43381. private _getBonePosition;
  43382. private _getLinesForBonesWithLength;
  43383. private _getLinesForBonesNoLength;
  43384. /** Update the viewer to sync with current skeleton state */
  43385. update(): void;
  43386. /** Release associated resources */
  43387. dispose(): void;
  43388. }
  43389. }
  43390. declare module BABYLON {
  43391. /**
  43392. * Options to create the null engine
  43393. */
  43394. export class NullEngineOptions {
  43395. /**
  43396. * Render width (Default: 512)
  43397. */
  43398. renderWidth: number;
  43399. /**
  43400. * Render height (Default: 256)
  43401. */
  43402. renderHeight: number;
  43403. /**
  43404. * Texture size (Default: 512)
  43405. */
  43406. textureSize: number;
  43407. /**
  43408. * If delta time between frames should be constant
  43409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43410. */
  43411. deterministicLockstep: boolean;
  43412. /**
  43413. * Maximum about of steps between frames (Default: 4)
  43414. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43415. */
  43416. lockstepMaxSteps: number;
  43417. }
  43418. /**
  43419. * The null engine class provides support for headless version of babylon.js.
  43420. * This can be used in server side scenario or for testing purposes
  43421. */
  43422. export class NullEngine extends Engine {
  43423. private _options;
  43424. /**
  43425. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43426. */
  43427. isDeterministicLockStep(): boolean;
  43428. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43429. getLockstepMaxSteps(): number;
  43430. /**
  43431. * Sets hardware scaling, used to save performance if needed
  43432. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43433. */
  43434. getHardwareScalingLevel(): number;
  43435. constructor(options?: NullEngineOptions);
  43436. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43437. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43438. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43439. getRenderWidth(useScreen?: boolean): number;
  43440. getRenderHeight(useScreen?: boolean): number;
  43441. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43442. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43443. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43444. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43445. bindSamplers(effect: Effect): void;
  43446. enableEffect(effect: Effect): void;
  43447. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43448. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43449. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43450. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43451. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43452. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43453. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43454. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43455. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43456. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43457. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43458. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43459. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43460. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43461. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43462. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43463. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43464. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43465. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43466. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43467. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43468. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43469. bindBuffers(vertexBuffers: {
  43470. [key: string]: VertexBuffer;
  43471. }, indexBuffer: DataBuffer, effect: Effect): void;
  43472. wipeCaches(bruteForce?: boolean): void;
  43473. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43474. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43475. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43476. /** @hidden */
  43477. _createTexture(): WebGLTexture;
  43478. /** @hidden */
  43479. _releaseTexture(texture: InternalTexture): void;
  43480. 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;
  43481. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43485. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43486. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43487. areAllEffectsReady(): boolean;
  43488. /**
  43489. * @hidden
  43490. * Get the current error code of the webGL context
  43491. * @returns the error code
  43492. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43493. */
  43494. getError(): number;
  43495. /** @hidden */
  43496. _getUnpackAlignement(): number;
  43497. /** @hidden */
  43498. _unpackFlipY(value: boolean): void;
  43499. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43500. /**
  43501. * Updates a dynamic vertex buffer.
  43502. * @param vertexBuffer the vertex buffer to update
  43503. * @param data the data used to update the vertex buffer
  43504. * @param byteOffset the byte offset of the data (optional)
  43505. * @param byteLength the byte length of the data (optional)
  43506. */
  43507. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43508. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43509. /** @hidden */
  43510. _bindTexture(channel: number, texture: InternalTexture): void;
  43511. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43512. releaseEffects(): void;
  43513. displayLoadingUI(): void;
  43514. hideLoadingUI(): void;
  43515. /** @hidden */
  43516. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43517. /** @hidden */
  43518. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43519. /** @hidden */
  43520. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43521. /** @hidden */
  43522. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43523. }
  43524. }
  43525. declare module BABYLON {
  43526. /** @hidden */
  43527. export class _OcclusionDataStorage {
  43528. /** @hidden */
  43529. occlusionInternalRetryCounter: number;
  43530. /** @hidden */
  43531. isOcclusionQueryInProgress: boolean;
  43532. /** @hidden */
  43533. isOccluded: boolean;
  43534. /** @hidden */
  43535. occlusionRetryCount: number;
  43536. /** @hidden */
  43537. occlusionType: number;
  43538. /** @hidden */
  43539. occlusionQueryAlgorithmType: number;
  43540. }
  43541. interface Engine {
  43542. /**
  43543. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43544. * @return the new query
  43545. */
  43546. createQuery(): WebGLQuery;
  43547. /**
  43548. * Delete and release a webGL query
  43549. * @param query defines the query to delete
  43550. * @return the current engine
  43551. */
  43552. deleteQuery(query: WebGLQuery): Engine;
  43553. /**
  43554. * Check if a given query has resolved and got its value
  43555. * @param query defines the query to check
  43556. * @returns true if the query got its value
  43557. */
  43558. isQueryResultAvailable(query: WebGLQuery): boolean;
  43559. /**
  43560. * Gets the value of a given query
  43561. * @param query defines the query to check
  43562. * @returns the value of the query
  43563. */
  43564. getQueryResult(query: WebGLQuery): number;
  43565. /**
  43566. * Initiates an occlusion query
  43567. * @param algorithmType defines the algorithm to use
  43568. * @param query defines the query to use
  43569. * @returns the current engine
  43570. * @see http://doc.babylonjs.com/features/occlusionquery
  43571. */
  43572. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43573. /**
  43574. * Ends an occlusion query
  43575. * @see http://doc.babylonjs.com/features/occlusionquery
  43576. * @param algorithmType defines the algorithm to use
  43577. * @returns the current engine
  43578. */
  43579. endOcclusionQuery(algorithmType: number): Engine;
  43580. /**
  43581. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43582. * Please note that only one query can be issued at a time
  43583. * @returns a time token used to track the time span
  43584. */
  43585. startTimeQuery(): Nullable<_TimeToken>;
  43586. /**
  43587. * Ends a time query
  43588. * @param token defines the token used to measure the time span
  43589. * @returns the time spent (in ns)
  43590. */
  43591. endTimeQuery(token: _TimeToken): int;
  43592. /** @hidden */
  43593. _currentNonTimestampToken: Nullable<_TimeToken>;
  43594. /** @hidden */
  43595. _createTimeQuery(): WebGLQuery;
  43596. /** @hidden */
  43597. _deleteTimeQuery(query: WebGLQuery): void;
  43598. /** @hidden */
  43599. _getGlAlgorithmType(algorithmType: number): number;
  43600. /** @hidden */
  43601. _getTimeQueryResult(query: WebGLQuery): any;
  43602. /** @hidden */
  43603. _getTimeQueryAvailability(query: WebGLQuery): any;
  43604. }
  43605. interface AbstractMesh {
  43606. /**
  43607. * Backing filed
  43608. * @hidden
  43609. */
  43610. __occlusionDataStorage: _OcclusionDataStorage;
  43611. /**
  43612. * Access property
  43613. * @hidden
  43614. */
  43615. _occlusionDataStorage: _OcclusionDataStorage;
  43616. /**
  43617. * 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.
  43618. * The default value is -1 which means don't break the query and wait till the result
  43619. * @see http://doc.babylonjs.com/features/occlusionquery
  43620. */
  43621. occlusionRetryCount: number;
  43622. /**
  43623. * 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:
  43624. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43625. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43626. * * 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.
  43627. * @see http://doc.babylonjs.com/features/occlusionquery
  43628. */
  43629. occlusionType: number;
  43630. /**
  43631. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43632. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43633. * * 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.
  43634. * @see http://doc.babylonjs.com/features/occlusionquery
  43635. */
  43636. occlusionQueryAlgorithmType: number;
  43637. /**
  43638. * 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
  43639. * @see http://doc.babylonjs.com/features/occlusionquery
  43640. */
  43641. isOccluded: boolean;
  43642. /**
  43643. * Flag to check the progress status of the query
  43644. * @see http://doc.babylonjs.com/features/occlusionquery
  43645. */
  43646. isOcclusionQueryInProgress: boolean;
  43647. }
  43648. }
  43649. declare module BABYLON {
  43650. /** @hidden */
  43651. export var _forceTransformFeedbackToBundle: boolean;
  43652. interface Engine {
  43653. /**
  43654. * Creates a webGL transform feedback object
  43655. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43656. * @returns the webGL transform feedback object
  43657. */
  43658. createTransformFeedback(): WebGLTransformFeedback;
  43659. /**
  43660. * Delete a webGL transform feedback object
  43661. * @param value defines the webGL transform feedback object to delete
  43662. */
  43663. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43664. /**
  43665. * Bind a webGL transform feedback object to the webgl context
  43666. * @param value defines the webGL transform feedback object to bind
  43667. */
  43668. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43669. /**
  43670. * Begins a transform feedback operation
  43671. * @param usePoints defines if points or triangles must be used
  43672. */
  43673. beginTransformFeedback(usePoints: boolean): void;
  43674. /**
  43675. * Ends a transform feedback operation
  43676. */
  43677. endTransformFeedback(): void;
  43678. /**
  43679. * Specify the varyings to use with transform feedback
  43680. * @param program defines the associated webGL program
  43681. * @param value defines the list of strings representing the varying names
  43682. */
  43683. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43684. /**
  43685. * Bind a webGL buffer for a transform feedback operation
  43686. * @param value defines the webGL buffer to bind
  43687. */
  43688. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43689. }
  43690. }
  43691. declare module BABYLON {
  43692. /**
  43693. * Creation options of the multi render target texture.
  43694. */
  43695. export interface IMultiRenderTargetOptions {
  43696. /**
  43697. * Define if the texture needs to create mip maps after render.
  43698. */
  43699. generateMipMaps?: boolean;
  43700. /**
  43701. * Define the types of all the draw buffers we want to create
  43702. */
  43703. types?: number[];
  43704. /**
  43705. * Define the sampling modes of all the draw buffers we want to create
  43706. */
  43707. samplingModes?: number[];
  43708. /**
  43709. * Define if a depth buffer is required
  43710. */
  43711. generateDepthBuffer?: boolean;
  43712. /**
  43713. * Define if a stencil buffer is required
  43714. */
  43715. generateStencilBuffer?: boolean;
  43716. /**
  43717. * Define if a depth texture is required instead of a depth buffer
  43718. */
  43719. generateDepthTexture?: boolean;
  43720. /**
  43721. * Define the number of desired draw buffers
  43722. */
  43723. textureCount?: number;
  43724. /**
  43725. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43726. */
  43727. doNotChangeAspectRatio?: boolean;
  43728. /**
  43729. * Define the default type of the buffers we are creating
  43730. */
  43731. defaultType?: number;
  43732. }
  43733. /**
  43734. * A multi render target, like a render target provides the ability to render to a texture.
  43735. * Unlike the render target, it can render to several draw buffers in one draw.
  43736. * This is specially interesting in deferred rendering or for any effects requiring more than
  43737. * just one color from a single pass.
  43738. */
  43739. export class MultiRenderTarget extends RenderTargetTexture {
  43740. private _internalTextures;
  43741. private _textures;
  43742. private _multiRenderTargetOptions;
  43743. /**
  43744. * Get if draw buffers are currently supported by the used hardware and browser.
  43745. */
  43746. readonly isSupported: boolean;
  43747. /**
  43748. * Get the list of textures generated by the multi render target.
  43749. */
  43750. readonly textures: Texture[];
  43751. /**
  43752. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43753. */
  43754. readonly depthTexture: Texture;
  43755. /**
  43756. * Set the wrapping mode on U of all the textures we are rendering to.
  43757. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43758. */
  43759. wrapU: number;
  43760. /**
  43761. * Set the wrapping mode on V of all the textures we are rendering to.
  43762. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43763. */
  43764. wrapV: number;
  43765. /**
  43766. * Instantiate a new multi render target texture.
  43767. * A multi render target, like a render target provides the ability to render to a texture.
  43768. * Unlike the render target, it can render to several draw buffers in one draw.
  43769. * This is specially interesting in deferred rendering or for any effects requiring more than
  43770. * just one color from a single pass.
  43771. * @param name Define the name of the texture
  43772. * @param size Define the size of the buffers to render to
  43773. * @param count Define the number of target we are rendering into
  43774. * @param scene Define the scene the texture belongs to
  43775. * @param options Define the options used to create the multi render target
  43776. */
  43777. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43778. /** @hidden */
  43779. _rebuild(): void;
  43780. private _createInternalTextures;
  43781. private _createTextures;
  43782. /**
  43783. * Define the number of samples used if MSAA is enabled.
  43784. */
  43785. samples: number;
  43786. /**
  43787. * Resize all the textures in the multi render target.
  43788. * Be carrefull as it will recreate all the data in the new texture.
  43789. * @param size Define the new size
  43790. */
  43791. resize(size: any): void;
  43792. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43793. /**
  43794. * Dispose the render targets and their associated resources
  43795. */
  43796. dispose(): void;
  43797. /**
  43798. * Release all the underlying texture used as draw buffers.
  43799. */
  43800. releaseInternalTextures(): void;
  43801. }
  43802. }
  43803. declare module BABYLON {
  43804. interface Engine {
  43805. /**
  43806. * Unbind a list of render target textures from the webGL context
  43807. * This is used only when drawBuffer extension or webGL2 are active
  43808. * @param textures defines the render target textures to unbind
  43809. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43810. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43811. */
  43812. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43813. /**
  43814. * Create a multi render target texture
  43815. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43816. * @param size defines the size of the texture
  43817. * @param options defines the creation options
  43818. * @returns the cube texture as an InternalTexture
  43819. */
  43820. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43821. /**
  43822. * Update the sample count for a given multiple render target texture
  43823. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43824. * @param textures defines the textures to update
  43825. * @param samples defines the sample count to set
  43826. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43827. */
  43828. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43829. }
  43830. }
  43831. declare module BABYLON {
  43832. /** @hidden */
  43833. export var rgbdEncodePixelShader: {
  43834. name: string;
  43835. shader: string;
  43836. };
  43837. }
  43838. declare module BABYLON {
  43839. /** @hidden */
  43840. export var rgbdDecodePixelShader: {
  43841. name: string;
  43842. shader: string;
  43843. };
  43844. }
  43845. declare module BABYLON {
  43846. /**
  43847. * Raw texture data and descriptor sufficient for WebGL texture upload
  43848. */
  43849. export interface EnvironmentTextureInfo {
  43850. /**
  43851. * Version of the environment map
  43852. */
  43853. version: number;
  43854. /**
  43855. * Width of image
  43856. */
  43857. width: number;
  43858. /**
  43859. * Irradiance information stored in the file.
  43860. */
  43861. irradiance: any;
  43862. /**
  43863. * Specular information stored in the file.
  43864. */
  43865. specular: any;
  43866. }
  43867. /**
  43868. * Defines One Image in the file. It requires only the position in the file
  43869. * as well as the length.
  43870. */
  43871. interface BufferImageData {
  43872. /**
  43873. * Length of the image data.
  43874. */
  43875. length: number;
  43876. /**
  43877. * Position of the data from the null terminator delimiting the end of the JSON.
  43878. */
  43879. position: number;
  43880. }
  43881. /**
  43882. * Defines the specular data enclosed in the file.
  43883. * This corresponds to the version 1 of the data.
  43884. */
  43885. export interface EnvironmentTextureSpecularInfoV1 {
  43886. /**
  43887. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43888. */
  43889. specularDataPosition?: number;
  43890. /**
  43891. * This contains all the images data needed to reconstruct the cubemap.
  43892. */
  43893. mipmaps: Array<BufferImageData>;
  43894. /**
  43895. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43896. */
  43897. lodGenerationScale: number;
  43898. }
  43899. /**
  43900. * Sets of helpers addressing the serialization and deserialization of environment texture
  43901. * stored in a BabylonJS env file.
  43902. * Those files are usually stored as .env files.
  43903. */
  43904. export class EnvironmentTextureTools {
  43905. /**
  43906. * Magic number identifying the env file.
  43907. */
  43908. private static _MagicBytes;
  43909. /**
  43910. * Gets the environment info from an env file.
  43911. * @param data The array buffer containing the .env bytes.
  43912. * @returns the environment file info (the json header) if successfully parsed.
  43913. */
  43914. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43915. /**
  43916. * Creates an environment texture from a loaded cube texture.
  43917. * @param texture defines the cube texture to convert in env file
  43918. * @return a promise containing the environment data if succesfull.
  43919. */
  43920. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43921. /**
  43922. * Creates a JSON representation of the spherical data.
  43923. * @param texture defines the texture containing the polynomials
  43924. * @return the JSON representation of the spherical info
  43925. */
  43926. private static _CreateEnvTextureIrradiance;
  43927. /**
  43928. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43929. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43930. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43931. * @return the views described by info providing access to the underlying buffer
  43932. */
  43933. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43934. /**
  43935. * Uploads the texture info contained in the env file to the GPU.
  43936. * @param texture defines the internal texture to upload to
  43937. * @param arrayBuffer defines the buffer cotaining the data to load
  43938. * @param info defines the texture info retrieved through the GetEnvInfo method
  43939. * @returns a promise
  43940. */
  43941. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43942. /**
  43943. * Uploads the levels of image data to the GPU.
  43944. * @param texture defines the internal texture to upload to
  43945. * @param imageData defines the array buffer views of image data [mipmap][face]
  43946. * @returns a promise
  43947. */
  43948. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43949. /**
  43950. * Uploads spherical polynomials information to the texture.
  43951. * @param texture defines the texture we are trying to upload the information to
  43952. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43953. */
  43954. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43955. /** @hidden */
  43956. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43957. }
  43958. }
  43959. declare module BABYLON {
  43960. /**
  43961. * Contains position and normal vectors for a vertex
  43962. */
  43963. export class PositionNormalVertex {
  43964. /** the position of the vertex (defaut: 0,0,0) */
  43965. position: Vector3;
  43966. /** the normal of the vertex (defaut: 0,1,0) */
  43967. normal: Vector3;
  43968. /**
  43969. * Creates a PositionNormalVertex
  43970. * @param position the position of the vertex (defaut: 0,0,0)
  43971. * @param normal the normal of the vertex (defaut: 0,1,0)
  43972. */
  43973. constructor(
  43974. /** the position of the vertex (defaut: 0,0,0) */
  43975. position?: Vector3,
  43976. /** the normal of the vertex (defaut: 0,1,0) */
  43977. normal?: Vector3);
  43978. /**
  43979. * Clones the PositionNormalVertex
  43980. * @returns the cloned PositionNormalVertex
  43981. */
  43982. clone(): PositionNormalVertex;
  43983. }
  43984. /**
  43985. * Contains position, normal and uv vectors for a vertex
  43986. */
  43987. export class PositionNormalTextureVertex {
  43988. /** the position of the vertex (defaut: 0,0,0) */
  43989. position: Vector3;
  43990. /** the normal of the vertex (defaut: 0,1,0) */
  43991. normal: Vector3;
  43992. /** the uv of the vertex (default: 0,0) */
  43993. uv: Vector2;
  43994. /**
  43995. * Creates a PositionNormalTextureVertex
  43996. * @param position the position of the vertex (defaut: 0,0,0)
  43997. * @param normal the normal of the vertex (defaut: 0,1,0)
  43998. * @param uv the uv of the vertex (default: 0,0)
  43999. */
  44000. constructor(
  44001. /** the position of the vertex (defaut: 0,0,0) */
  44002. position?: Vector3,
  44003. /** the normal of the vertex (defaut: 0,1,0) */
  44004. normal?: Vector3,
  44005. /** the uv of the vertex (default: 0,0) */
  44006. uv?: Vector2);
  44007. /**
  44008. * Clones the PositionNormalTextureVertex
  44009. * @returns the cloned PositionNormalTextureVertex
  44010. */
  44011. clone(): PositionNormalTextureVertex;
  44012. }
  44013. }
  44014. declare module BABYLON {
  44015. /** @hidden */
  44016. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44017. private _genericAttributeLocation;
  44018. private _varyingLocationCount;
  44019. private _varyingLocationMap;
  44020. private _replacements;
  44021. private _textureCount;
  44022. private _uniforms;
  44023. lineProcessor(line: string): string;
  44024. attributeProcessor(attribute: string): string;
  44025. varyingProcessor(varying: string, isFragment: boolean): string;
  44026. uniformProcessor(uniform: string): string;
  44027. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44028. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44029. }
  44030. }
  44031. declare module BABYLON {
  44032. /**
  44033. * Container for accessors for natively-stored mesh data buffers.
  44034. */
  44035. class NativeDataBuffer extends DataBuffer {
  44036. /**
  44037. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44038. */
  44039. nativeIndexBuffer?: any;
  44040. /**
  44041. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44042. */
  44043. nativeVertexBuffer?: any;
  44044. }
  44045. /** @hidden */
  44046. export class NativeEngine extends Engine {
  44047. private readonly _native;
  44048. getHardwareScalingLevel(): number;
  44049. constructor();
  44050. /**
  44051. * Can be used to override the current requestAnimationFrame requester.
  44052. * @hidden
  44053. */
  44054. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44055. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44056. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44057. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44058. recordVertexArrayObject(vertexBuffers: {
  44059. [key: string]: VertexBuffer;
  44060. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44061. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44062. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44063. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44064. /**
  44065. * Draw a list of indexed primitives
  44066. * @param fillMode defines the primitive to use
  44067. * @param indexStart defines the starting index
  44068. * @param indexCount defines the number of index to draw
  44069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44070. */
  44071. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44072. /**
  44073. * Draw a list of unindexed primitives
  44074. * @param fillMode defines the primitive to use
  44075. * @param verticesStart defines the index of first vertex to draw
  44076. * @param verticesCount defines the count of vertices to draw
  44077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44078. */
  44079. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44080. createPipelineContext(): IPipelineContext;
  44081. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44082. /** @hidden */
  44083. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44084. /** @hidden */
  44085. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44086. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44087. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44088. protected _setProgram(program: WebGLProgram): void;
  44089. _releaseEffect(effect: Effect): void;
  44090. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44091. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44092. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44093. bindSamplers(effect: Effect): void;
  44094. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44095. getRenderWidth(useScreen?: boolean): number;
  44096. getRenderHeight(useScreen?: boolean): number;
  44097. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44098. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44099. /**
  44100. * Set the z offset to apply to current rendering
  44101. * @param value defines the offset to apply
  44102. */
  44103. setZOffset(value: number): void;
  44104. /**
  44105. * Gets the current value of the zOffset
  44106. * @returns the current zOffset state
  44107. */
  44108. getZOffset(): number;
  44109. /**
  44110. * Enable or disable depth buffering
  44111. * @param enable defines the state to set
  44112. */
  44113. setDepthBuffer(enable: boolean): void;
  44114. /**
  44115. * Gets a boolean indicating if depth writing is enabled
  44116. * @returns the current depth writing state
  44117. */
  44118. getDepthWrite(): boolean;
  44119. /**
  44120. * Enable or disable depth writing
  44121. * @param enable defines the state to set
  44122. */
  44123. setDepthWrite(enable: boolean): void;
  44124. /**
  44125. * Enable or disable color writing
  44126. * @param enable defines the state to set
  44127. */
  44128. setColorWrite(enable: boolean): void;
  44129. /**
  44130. * Gets a boolean indicating if color writing is enabled
  44131. * @returns the current color writing state
  44132. */
  44133. getColorWrite(): boolean;
  44134. /**
  44135. * Sets alpha constants used by some alpha blending modes
  44136. * @param r defines the red component
  44137. * @param g defines the green component
  44138. * @param b defines the blue component
  44139. * @param a defines the alpha component
  44140. */
  44141. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44142. /**
  44143. * Sets the current alpha mode
  44144. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44145. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44147. */
  44148. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44149. /**
  44150. * Gets the current alpha mode
  44151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44152. * @returns the current alpha mode
  44153. */
  44154. getAlphaMode(): number;
  44155. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44156. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44157. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44158. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44159. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44160. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44161. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44162. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44163. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44164. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44165. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44166. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44167. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44168. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44169. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44170. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44171. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44172. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44173. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44174. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44175. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44176. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44177. wipeCaches(bruteForce?: boolean): void;
  44178. _createTexture(): WebGLTexture;
  44179. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44180. /**
  44181. * Usually called from BABYLON.Texture.ts.
  44182. * Passed information to create a WebGLTexture
  44183. * @param urlArg defines a value which contains one of the following:
  44184. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44185. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44186. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44187. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44188. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44189. * @param scene needed for loading to the correct scene
  44190. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44191. * @param onLoad optional callback to be called upon successful completion
  44192. * @param onError optional callback to be called upon failure
  44193. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44194. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44195. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44196. * @param forcedExtension defines the extension to use to pick the right loader
  44197. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44198. */
  44199. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44200. /**
  44201. * Creates a cube texture
  44202. * @param rootUrl defines the url where the files to load is located
  44203. * @param scene defines the current scene
  44204. * @param files defines the list of files to load (1 per face)
  44205. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44206. * @param onLoad defines an optional callback raised when the texture is loaded
  44207. * @param onError defines an optional callback raised if there is an issue to load the texture
  44208. * @param format defines the format of the data
  44209. * @param forcedExtension defines the extension to use to pick the right loader
  44210. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44211. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44212. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44213. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44214. * @returns the cube texture as an InternalTexture
  44215. */
  44216. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44217. private _getSamplingFilter;
  44218. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44219. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44220. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44221. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44222. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44223. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44224. /**
  44225. * Updates a dynamic vertex buffer.
  44226. * @param vertexBuffer the vertex buffer to update
  44227. * @param data the data used to update the vertex buffer
  44228. * @param byteOffset the byte offset of the data (optional)
  44229. * @param byteLength the byte length of the data (optional)
  44230. */
  44231. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44232. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44233. private _updateAnisotropicLevel;
  44234. private _getAddressMode;
  44235. /** @hidden */
  44236. _bindTexture(channel: number, texture: InternalTexture): void;
  44237. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44238. releaseEffects(): void;
  44239. /** @hidden */
  44240. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44241. /** @hidden */
  44242. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44243. /** @hidden */
  44244. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44245. /** @hidden */
  44246. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44247. }
  44248. }
  44249. declare module BABYLON {
  44250. /**
  44251. * Gather the list of clipboard event types as constants.
  44252. */
  44253. export class ClipboardEventTypes {
  44254. /**
  44255. * The clipboard event is fired when a copy command is active (pressed).
  44256. */
  44257. static readonly COPY: number;
  44258. /**
  44259. * The clipboard event is fired when a cut command is active (pressed).
  44260. */
  44261. static readonly CUT: number;
  44262. /**
  44263. * The clipboard event is fired when a paste command is active (pressed).
  44264. */
  44265. static readonly PASTE: number;
  44266. }
  44267. /**
  44268. * This class is used to store clipboard related info for the onClipboardObservable event.
  44269. */
  44270. export class ClipboardInfo {
  44271. /**
  44272. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44273. */
  44274. type: number;
  44275. /**
  44276. * Defines the related dom event
  44277. */
  44278. event: ClipboardEvent;
  44279. /**
  44280. *Creates an instance of ClipboardInfo.
  44281. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44282. * @param event Defines the related dom event
  44283. */
  44284. constructor(
  44285. /**
  44286. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44287. */
  44288. type: number,
  44289. /**
  44290. * Defines the related dom event
  44291. */
  44292. event: ClipboardEvent);
  44293. /**
  44294. * Get the clipboard event's type from the keycode.
  44295. * @param keyCode Defines the keyCode for the current keyboard event.
  44296. * @return {number}
  44297. */
  44298. static GetTypeFromCharacter(keyCode: number): number;
  44299. }
  44300. }
  44301. declare module BABYLON {
  44302. /**
  44303. * Google Daydream controller
  44304. */
  44305. export class DaydreamController extends WebVRController {
  44306. /**
  44307. * Base Url for the controller model.
  44308. */
  44309. static MODEL_BASE_URL: string;
  44310. /**
  44311. * File name for the controller model.
  44312. */
  44313. static MODEL_FILENAME: string;
  44314. /**
  44315. * Gamepad Id prefix used to identify Daydream Controller.
  44316. */
  44317. static readonly GAMEPAD_ID_PREFIX: string;
  44318. /**
  44319. * Creates a new DaydreamController from a gamepad
  44320. * @param vrGamepad the gamepad that the controller should be created from
  44321. */
  44322. constructor(vrGamepad: any);
  44323. /**
  44324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44325. * @param scene scene in which to add meshes
  44326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44327. */
  44328. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44329. /**
  44330. * Called once for each button that changed state since the last frame
  44331. * @param buttonIdx Which button index changed
  44332. * @param state New state of the button
  44333. * @param changes Which properties on the state changed since last frame
  44334. */
  44335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44336. }
  44337. }
  44338. declare module BABYLON {
  44339. /**
  44340. * Gear VR Controller
  44341. */
  44342. export class GearVRController extends WebVRController {
  44343. /**
  44344. * Base Url for the controller model.
  44345. */
  44346. static MODEL_BASE_URL: string;
  44347. /**
  44348. * File name for the controller model.
  44349. */
  44350. static MODEL_FILENAME: string;
  44351. /**
  44352. * Gamepad Id prefix used to identify this controller.
  44353. */
  44354. static readonly GAMEPAD_ID_PREFIX: string;
  44355. private readonly _buttonIndexToObservableNameMap;
  44356. /**
  44357. * Creates a new GearVRController from a gamepad
  44358. * @param vrGamepad the gamepad that the controller should be created from
  44359. */
  44360. constructor(vrGamepad: any);
  44361. /**
  44362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44363. * @param scene scene in which to add meshes
  44364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44365. */
  44366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44367. /**
  44368. * Called once for each button that changed state since the last frame
  44369. * @param buttonIdx Which button index changed
  44370. * @param state New state of the button
  44371. * @param changes Which properties on the state changed since last frame
  44372. */
  44373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44374. }
  44375. }
  44376. declare module BABYLON {
  44377. /**
  44378. * Class containing static functions to help procedurally build meshes
  44379. */
  44380. export class PolyhedronBuilder {
  44381. /**
  44382. * Creates a polyhedron mesh
  44383. * * 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
  44384. * * The parameter `size` (positive float, default 1) sets the polygon size
  44385. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44386. * * 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`
  44387. * * 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
  44388. * * 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)`)
  44389. * * 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
  44390. * * 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
  44391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44392. * * 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
  44393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 polyhedron mesh
  44398. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44399. */
  44400. static CreatePolyhedron(name: string, options: {
  44401. type?: number;
  44402. size?: number;
  44403. sizeX?: number;
  44404. sizeY?: number;
  44405. sizeZ?: number;
  44406. custom?: any;
  44407. faceUV?: Vector4[];
  44408. faceColors?: Color4[];
  44409. flat?: boolean;
  44410. updatable?: boolean;
  44411. sideOrientation?: number;
  44412. frontUVs?: Vector4;
  44413. backUVs?: Vector4;
  44414. }, scene?: Nullable<Scene>): Mesh;
  44415. }
  44416. }
  44417. declare module BABYLON {
  44418. /**
  44419. * Gizmo that enables scaling a mesh along 3 axis
  44420. */
  44421. export class ScaleGizmo extends Gizmo {
  44422. /**
  44423. * Internal gizmo used for interactions on the x axis
  44424. */
  44425. xGizmo: AxisScaleGizmo;
  44426. /**
  44427. * Internal gizmo used for interactions on the y axis
  44428. */
  44429. yGizmo: AxisScaleGizmo;
  44430. /**
  44431. * Internal gizmo used for interactions on the z axis
  44432. */
  44433. zGizmo: AxisScaleGizmo;
  44434. /**
  44435. * Internal gizmo used to scale all axis equally
  44436. */
  44437. uniformScaleGizmo: AxisScaleGizmo;
  44438. private _meshAttached;
  44439. private _updateGizmoRotationToMatchAttachedMesh;
  44440. private _snapDistance;
  44441. private _scaleRatio;
  44442. private _uniformScalingMesh;
  44443. private _octahedron;
  44444. /** Fires an event when any of it's sub gizmos are dragged */
  44445. onDragStartObservable: Observable<unknown>;
  44446. /** Fires an event when any of it's sub gizmos are released from dragging */
  44447. onDragEndObservable: Observable<unknown>;
  44448. attachedMesh: Nullable<AbstractMesh>;
  44449. /**
  44450. * Creates a ScaleGizmo
  44451. * @param gizmoLayer The utility layer the gizmo will be added to
  44452. */
  44453. constructor(gizmoLayer?: UtilityLayerRenderer);
  44454. updateGizmoRotationToMatchAttachedMesh: boolean;
  44455. /**
  44456. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44457. */
  44458. snapDistance: number;
  44459. /**
  44460. * Ratio for the scale of the gizmo (Default: 1)
  44461. */
  44462. scaleRatio: number;
  44463. /**
  44464. * Disposes of the gizmo
  44465. */
  44466. dispose(): void;
  44467. }
  44468. }
  44469. declare module BABYLON {
  44470. /**
  44471. * Single axis scale gizmo
  44472. */
  44473. export class AxisScaleGizmo extends Gizmo {
  44474. /**
  44475. * Drag behavior responsible for the gizmos dragging interactions
  44476. */
  44477. dragBehavior: PointerDragBehavior;
  44478. private _pointerObserver;
  44479. /**
  44480. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44481. */
  44482. snapDistance: number;
  44483. /**
  44484. * Event that fires each time the gizmo snaps to a new location.
  44485. * * snapDistance is the the change in distance
  44486. */
  44487. onSnapObservable: Observable<{
  44488. snapDistance: number;
  44489. }>;
  44490. /**
  44491. * If the scaling operation should be done on all axis (default: false)
  44492. */
  44493. uniformScaling: boolean;
  44494. private _isEnabled;
  44495. private _parent;
  44496. private _arrow;
  44497. private _coloredMaterial;
  44498. private _hoverMaterial;
  44499. /**
  44500. * Creates an AxisScaleGizmo
  44501. * @param gizmoLayer The utility layer the gizmo will be added to
  44502. * @param dragAxis The axis which the gizmo will be able to scale on
  44503. * @param color The color of the gizmo
  44504. */
  44505. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44507. /**
  44508. * If the gizmo is enabled
  44509. */
  44510. isEnabled: boolean;
  44511. /**
  44512. * Disposes of the gizmo
  44513. */
  44514. dispose(): void;
  44515. /**
  44516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44517. * @param mesh The mesh to replace the default mesh of the gizmo
  44518. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44519. */
  44520. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44521. }
  44522. }
  44523. declare module BABYLON {
  44524. /**
  44525. * Bounding box gizmo
  44526. */
  44527. export class BoundingBoxGizmo extends Gizmo {
  44528. private _lineBoundingBox;
  44529. private _rotateSpheresParent;
  44530. private _scaleBoxesParent;
  44531. private _boundingDimensions;
  44532. private _renderObserver;
  44533. private _pointerObserver;
  44534. private _scaleDragSpeed;
  44535. private _tmpQuaternion;
  44536. private _tmpVector;
  44537. private _tmpRotationMatrix;
  44538. /**
  44539. * 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)
  44540. */
  44541. ignoreChildren: boolean;
  44542. /**
  44543. * 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)
  44544. */
  44545. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44546. /**
  44547. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44548. */
  44549. rotationSphereSize: number;
  44550. /**
  44551. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44552. */
  44553. scaleBoxSize: number;
  44554. /**
  44555. * 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)
  44556. */
  44557. fixedDragMeshScreenSize: boolean;
  44558. /**
  44559. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44560. */
  44561. fixedDragMeshScreenSizeDistanceFactor: number;
  44562. /**
  44563. * Fired when a rotation sphere or scale box is dragged
  44564. */
  44565. onDragStartObservable: Observable<{}>;
  44566. /**
  44567. * Fired when a scale box is dragged
  44568. */
  44569. onScaleBoxDragObservable: Observable<{}>;
  44570. /**
  44571. * Fired when a scale box drag is ended
  44572. */
  44573. onScaleBoxDragEndObservable: Observable<{}>;
  44574. /**
  44575. * Fired when a rotation sphere is dragged
  44576. */
  44577. onRotationSphereDragObservable: Observable<{}>;
  44578. /**
  44579. * Fired when a rotation sphere drag is ended
  44580. */
  44581. onRotationSphereDragEndObservable: Observable<{}>;
  44582. /**
  44583. * 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)
  44584. */
  44585. scalePivot: Nullable<Vector3>;
  44586. /**
  44587. * Mesh used as a pivot to rotate the attached mesh
  44588. */
  44589. private _anchorMesh;
  44590. private _existingMeshScale;
  44591. private _dragMesh;
  44592. private pointerDragBehavior;
  44593. private coloredMaterial;
  44594. private hoverColoredMaterial;
  44595. /**
  44596. * Sets the color of the bounding box gizmo
  44597. * @param color the color to set
  44598. */
  44599. setColor(color: Color3): void;
  44600. /**
  44601. * Creates an BoundingBoxGizmo
  44602. * @param gizmoLayer The utility layer the gizmo will be added to
  44603. * @param color The color of the gizmo
  44604. */
  44605. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44606. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44607. private _selectNode;
  44608. /**
  44609. * Updates the bounding box information for the Gizmo
  44610. */
  44611. updateBoundingBox(): void;
  44612. private _updateRotationSpheres;
  44613. private _updateScaleBoxes;
  44614. /**
  44615. * Enables rotation on the specified axis and disables rotation on the others
  44616. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44617. */
  44618. setEnabledRotationAxis(axis: string): void;
  44619. /**
  44620. * Enables/disables scaling
  44621. * @param enable if scaling should be enabled
  44622. */
  44623. setEnabledScaling(enable: boolean): void;
  44624. private _updateDummy;
  44625. /**
  44626. * Enables a pointer drag behavior on the bounding box of the gizmo
  44627. */
  44628. enableDragBehavior(): void;
  44629. /**
  44630. * Disposes of the gizmo
  44631. */
  44632. dispose(): void;
  44633. /**
  44634. * 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)
  44635. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44636. * @returns the bounding box mesh with the passed in mesh as a child
  44637. */
  44638. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44639. /**
  44640. * CustomMeshes are not supported by this gizmo
  44641. * @param mesh The mesh to replace the default mesh of the gizmo
  44642. */
  44643. setCustomMesh(mesh: Mesh): void;
  44644. }
  44645. }
  44646. declare module BABYLON {
  44647. /**
  44648. * Single plane rotation gizmo
  44649. */
  44650. export class PlaneRotationGizmo extends Gizmo {
  44651. /**
  44652. * Drag behavior responsible for the gizmos dragging interactions
  44653. */
  44654. dragBehavior: PointerDragBehavior;
  44655. private _pointerObserver;
  44656. /**
  44657. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44658. */
  44659. snapDistance: number;
  44660. /**
  44661. * Event that fires each time the gizmo snaps to a new location.
  44662. * * snapDistance is the the change in distance
  44663. */
  44664. onSnapObservable: Observable<{
  44665. snapDistance: number;
  44666. }>;
  44667. private _isEnabled;
  44668. private _parent;
  44669. /**
  44670. * Creates a PlaneRotationGizmo
  44671. * @param gizmoLayer The utility layer the gizmo will be added to
  44672. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44673. * @param color The color of the gizmo
  44674. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44675. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44676. */
  44677. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44679. /**
  44680. * If the gizmo is enabled
  44681. */
  44682. isEnabled: boolean;
  44683. /**
  44684. * Disposes of the gizmo
  44685. */
  44686. dispose(): void;
  44687. }
  44688. }
  44689. declare module BABYLON {
  44690. /**
  44691. * Gizmo that enables rotating a mesh along 3 axis
  44692. */
  44693. export class RotationGizmo extends Gizmo {
  44694. /**
  44695. * Internal gizmo used for interactions on the x axis
  44696. */
  44697. xGizmo: PlaneRotationGizmo;
  44698. /**
  44699. * Internal gizmo used for interactions on the y axis
  44700. */
  44701. yGizmo: PlaneRotationGizmo;
  44702. /**
  44703. * Internal gizmo used for interactions on the z axis
  44704. */
  44705. zGizmo: PlaneRotationGizmo;
  44706. /** Fires an event when any of it's sub gizmos are dragged */
  44707. onDragStartObservable: Observable<unknown>;
  44708. /** Fires an event when any of it's sub gizmos are released from dragging */
  44709. onDragEndObservable: Observable<unknown>;
  44710. private _meshAttached;
  44711. attachedMesh: Nullable<AbstractMesh>;
  44712. /**
  44713. * Creates a RotationGizmo
  44714. * @param gizmoLayer The utility layer the gizmo will be added to
  44715. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44716. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44717. */
  44718. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44719. updateGizmoRotationToMatchAttachedMesh: boolean;
  44720. /**
  44721. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44722. */
  44723. snapDistance: number;
  44724. /**
  44725. * Ratio for the scale of the gizmo (Default: 1)
  44726. */
  44727. scaleRatio: number;
  44728. /**
  44729. * Disposes of the gizmo
  44730. */
  44731. dispose(): void;
  44732. /**
  44733. * CustomMeshes are not supported by this gizmo
  44734. * @param mesh The mesh to replace the default mesh of the gizmo
  44735. */
  44736. setCustomMesh(mesh: Mesh): void;
  44737. }
  44738. }
  44739. declare module BABYLON {
  44740. /**
  44741. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44742. */
  44743. export class GizmoManager implements IDisposable {
  44744. private scene;
  44745. /**
  44746. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44747. */
  44748. gizmos: {
  44749. positionGizmo: Nullable<PositionGizmo>;
  44750. rotationGizmo: Nullable<RotationGizmo>;
  44751. scaleGizmo: Nullable<ScaleGizmo>;
  44752. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44753. };
  44754. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44755. clearGizmoOnEmptyPointerEvent: boolean;
  44756. /** Fires an event when the manager is attached to a mesh */
  44757. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44758. private _gizmosEnabled;
  44759. private _pointerObserver;
  44760. private _attachedMesh;
  44761. private _boundingBoxColor;
  44762. private _defaultUtilityLayer;
  44763. private _defaultKeepDepthUtilityLayer;
  44764. /**
  44765. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44766. */
  44767. boundingBoxDragBehavior: SixDofDragBehavior;
  44768. /**
  44769. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44770. */
  44771. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44772. /**
  44773. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44774. */
  44775. usePointerToAttachGizmos: boolean;
  44776. /**
  44777. * Utility layer that the bounding box gizmo belongs to
  44778. */
  44779. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44780. /**
  44781. * Utility layer that all gizmos besides bounding box belong to
  44782. */
  44783. readonly utilityLayer: UtilityLayerRenderer;
  44784. /**
  44785. * Instatiates a gizmo manager
  44786. * @param scene the scene to overlay the gizmos on top of
  44787. */
  44788. constructor(scene: Scene);
  44789. /**
  44790. * Attaches a set of gizmos to the specified mesh
  44791. * @param mesh The mesh the gizmo's should be attached to
  44792. */
  44793. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44794. /**
  44795. * If the position gizmo is enabled
  44796. */
  44797. positionGizmoEnabled: boolean;
  44798. /**
  44799. * If the rotation gizmo is enabled
  44800. */
  44801. rotationGizmoEnabled: boolean;
  44802. /**
  44803. * If the scale gizmo is enabled
  44804. */
  44805. scaleGizmoEnabled: boolean;
  44806. /**
  44807. * If the boundingBox gizmo is enabled
  44808. */
  44809. boundingBoxGizmoEnabled: boolean;
  44810. /**
  44811. * Disposes of the gizmo manager
  44812. */
  44813. dispose(): void;
  44814. }
  44815. }
  44816. declare module BABYLON {
  44817. /**
  44818. * A directional light is defined by a direction (what a surprise!).
  44819. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44820. * 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.
  44821. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44822. */
  44823. export class DirectionalLight extends ShadowLight {
  44824. private _shadowFrustumSize;
  44825. /**
  44826. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44827. */
  44828. /**
  44829. * Specifies a fix frustum size for the shadow generation.
  44830. */
  44831. shadowFrustumSize: number;
  44832. private _shadowOrthoScale;
  44833. /**
  44834. * Gets the shadow projection scale against the optimal computed one.
  44835. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44836. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44837. */
  44838. /**
  44839. * Sets the shadow projection scale against the optimal computed one.
  44840. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44841. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44842. */
  44843. shadowOrthoScale: number;
  44844. /**
  44845. * Automatically compute the projection matrix to best fit (including all the casters)
  44846. * on each frame.
  44847. */
  44848. autoUpdateExtends: boolean;
  44849. private _orthoLeft;
  44850. private _orthoRight;
  44851. private _orthoTop;
  44852. private _orthoBottom;
  44853. /**
  44854. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44855. * The directional light is emitted from everywhere in the given direction.
  44856. * It can cast shadows.
  44857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44858. * @param name The friendly name of the light
  44859. * @param direction The direction of the light
  44860. * @param scene The scene the light belongs to
  44861. */
  44862. constructor(name: string, direction: Vector3, scene: Scene);
  44863. /**
  44864. * Returns the string "DirectionalLight".
  44865. * @return The class name
  44866. */
  44867. getClassName(): string;
  44868. /**
  44869. * Returns the integer 1.
  44870. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44871. */
  44872. getTypeID(): number;
  44873. /**
  44874. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44875. * Returns the DirectionalLight Shadow projection matrix.
  44876. */
  44877. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44878. /**
  44879. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44880. * Returns the DirectionalLight Shadow projection matrix.
  44881. */
  44882. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44883. /**
  44884. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44885. * Returns the DirectionalLight Shadow projection matrix.
  44886. */
  44887. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44888. protected _buildUniformLayout(): void;
  44889. /**
  44890. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44891. * @param effect The effect to update
  44892. * @param lightIndex The index of the light in the effect to update
  44893. * @returns The directional light
  44894. */
  44895. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44896. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44897. /**
  44898. * Gets the minZ used for shadow according to both the scene and the light.
  44899. *
  44900. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44901. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44902. * @param activeCamera The camera we are returning the min for
  44903. * @returns the depth min z
  44904. */
  44905. getDepthMinZ(activeCamera: Camera): number;
  44906. /**
  44907. * Gets the maxZ used for shadow according to both the scene and the light.
  44908. *
  44909. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44910. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44911. * @param activeCamera The camera we are returning the max for
  44912. * @returns the depth max z
  44913. */
  44914. getDepthMaxZ(activeCamera: Camera): number;
  44915. /**
  44916. * Prepares the list of defines specific to the light type.
  44917. * @param defines the list of defines
  44918. * @param lightIndex defines the index of the light for the effect
  44919. */
  44920. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /**
  44925. * Class containing static functions to help procedurally build meshes
  44926. */
  44927. export class HemisphereBuilder {
  44928. /**
  44929. * Creates a hemisphere mesh
  44930. * @param name defines the name of the mesh
  44931. * @param options defines the options used to create the mesh
  44932. * @param scene defines the hosting scene
  44933. * @returns the hemisphere mesh
  44934. */
  44935. static CreateHemisphere(name: string, options: {
  44936. segments?: number;
  44937. diameter?: number;
  44938. sideOrientation?: number;
  44939. }, scene: any): Mesh;
  44940. }
  44941. }
  44942. declare module BABYLON {
  44943. /**
  44944. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44945. * These values define a cone of light starting from the position, emitting toward the direction.
  44946. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44947. * and the exponent defines the speed of the decay of the light with distance (reach).
  44948. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44949. */
  44950. export class SpotLight extends ShadowLight {
  44951. private _angle;
  44952. private _innerAngle;
  44953. private _cosHalfAngle;
  44954. private _lightAngleScale;
  44955. private _lightAngleOffset;
  44956. /**
  44957. * Gets the cone angle of the spot light in Radians.
  44958. */
  44959. /**
  44960. * Sets the cone angle of the spot light in Radians.
  44961. */
  44962. angle: number;
  44963. /**
  44964. * Only used in gltf falloff mode, this defines the angle where
  44965. * the directional falloff will start before cutting at angle which could be seen
  44966. * as outer angle.
  44967. */
  44968. /**
  44969. * Only used in gltf falloff mode, this defines the angle where
  44970. * the directional falloff will start before cutting at angle which could be seen
  44971. * as outer angle.
  44972. */
  44973. innerAngle: number;
  44974. private _shadowAngleScale;
  44975. /**
  44976. * Allows scaling the angle of the light for shadow generation only.
  44977. */
  44978. /**
  44979. * Allows scaling the angle of the light for shadow generation only.
  44980. */
  44981. shadowAngleScale: number;
  44982. /**
  44983. * The light decay speed with the distance from the emission spot.
  44984. */
  44985. exponent: number;
  44986. private _projectionTextureMatrix;
  44987. /**
  44988. * Allows reading the projecton texture
  44989. */
  44990. readonly projectionTextureMatrix: Matrix;
  44991. protected _projectionTextureLightNear: number;
  44992. /**
  44993. * Gets the near clip of the Spotlight for texture projection.
  44994. */
  44995. /**
  44996. * Sets the near clip of the Spotlight for texture projection.
  44997. */
  44998. projectionTextureLightNear: number;
  44999. protected _projectionTextureLightFar: number;
  45000. /**
  45001. * Gets the far clip of the Spotlight for texture projection.
  45002. */
  45003. /**
  45004. * Sets the far clip of the Spotlight for texture projection.
  45005. */
  45006. projectionTextureLightFar: number;
  45007. protected _projectionTextureUpDirection: Vector3;
  45008. /**
  45009. * Gets the Up vector of the Spotlight for texture projection.
  45010. */
  45011. /**
  45012. * Sets the Up vector of the Spotlight for texture projection.
  45013. */
  45014. projectionTextureUpDirection: Vector3;
  45015. private _projectionTexture;
  45016. /**
  45017. * Gets the projection texture of the light.
  45018. */
  45019. /**
  45020. * Sets the projection texture of the light.
  45021. */
  45022. projectionTexture: Nullable<BaseTexture>;
  45023. private _projectionTextureViewLightDirty;
  45024. private _projectionTextureProjectionLightDirty;
  45025. private _projectionTextureDirty;
  45026. private _projectionTextureViewTargetVector;
  45027. private _projectionTextureViewLightMatrix;
  45028. private _projectionTextureProjectionLightMatrix;
  45029. private _projectionTextureScalingMatrix;
  45030. /**
  45031. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45032. * It can cast shadows.
  45033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45034. * @param name The light friendly name
  45035. * @param position The position of the spot light in the scene
  45036. * @param direction The direction of the light in the scene
  45037. * @param angle The cone angle of the light in Radians
  45038. * @param exponent The light decay speed with the distance from the emission spot
  45039. * @param scene The scene the lights belongs to
  45040. */
  45041. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45042. /**
  45043. * Returns the string "SpotLight".
  45044. * @returns the class name
  45045. */
  45046. getClassName(): string;
  45047. /**
  45048. * Returns the integer 2.
  45049. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45050. */
  45051. getTypeID(): number;
  45052. /**
  45053. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45054. */
  45055. protected _setDirection(value: Vector3): void;
  45056. /**
  45057. * Overrides the position setter to recompute the projection texture view light Matrix.
  45058. */
  45059. protected _setPosition(value: Vector3): void;
  45060. /**
  45061. * 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.
  45062. * Returns the SpotLight.
  45063. */
  45064. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45065. protected _computeProjectionTextureViewLightMatrix(): void;
  45066. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45067. /**
  45068. * Main function for light texture projection matrix computing.
  45069. */
  45070. protected _computeProjectionTextureMatrix(): void;
  45071. protected _buildUniformLayout(): void;
  45072. private _computeAngleValues;
  45073. /**
  45074. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45075. * @param effect The effect to update
  45076. * @param lightIndex The index of the light in the effect to update
  45077. * @returns The spot light
  45078. */
  45079. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45080. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45081. /**
  45082. * Disposes the light and the associated resources.
  45083. */
  45084. dispose(): void;
  45085. /**
  45086. * Prepares the list of defines specific to the light type.
  45087. * @param defines the list of defines
  45088. * @param lightIndex defines the index of the light for the effect
  45089. */
  45090. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. /**
  45095. * Gizmo that enables viewing a light
  45096. */
  45097. export class LightGizmo extends Gizmo {
  45098. private _lightMesh;
  45099. private _material;
  45100. private cachedPosition;
  45101. private cachedForward;
  45102. /**
  45103. * Creates a LightGizmo
  45104. * @param gizmoLayer The utility layer the gizmo will be added to
  45105. */
  45106. constructor(gizmoLayer?: UtilityLayerRenderer);
  45107. private _light;
  45108. /**
  45109. * The light that the gizmo is attached to
  45110. */
  45111. light: Nullable<Light>;
  45112. /**
  45113. * Gets the material used to render the light gizmo
  45114. */
  45115. readonly material: StandardMaterial;
  45116. /**
  45117. * @hidden
  45118. * Updates the gizmo to match the attached mesh's position/rotation
  45119. */
  45120. protected _update(): void;
  45121. private static _Scale;
  45122. /**
  45123. * Creates the lines for a light mesh
  45124. */
  45125. private static _createLightLines;
  45126. /**
  45127. * Disposes of the light gizmo
  45128. */
  45129. dispose(): void;
  45130. private static _CreateHemisphericLightMesh;
  45131. private static _CreatePointLightMesh;
  45132. private static _CreateSpotLightMesh;
  45133. private static _CreateDirectionalLightMesh;
  45134. }
  45135. }
  45136. declare module BABYLON {
  45137. /** @hidden */
  45138. export var backgroundFragmentDeclaration: {
  45139. name: string;
  45140. shader: string;
  45141. };
  45142. }
  45143. declare module BABYLON {
  45144. /** @hidden */
  45145. export var backgroundUboDeclaration: {
  45146. name: string;
  45147. shader: string;
  45148. };
  45149. }
  45150. declare module BABYLON {
  45151. /** @hidden */
  45152. export var backgroundPixelShader: {
  45153. name: string;
  45154. shader: string;
  45155. };
  45156. }
  45157. declare module BABYLON {
  45158. /** @hidden */
  45159. export var backgroundVertexDeclaration: {
  45160. name: string;
  45161. shader: string;
  45162. };
  45163. }
  45164. declare module BABYLON {
  45165. /** @hidden */
  45166. export var backgroundVertexShader: {
  45167. name: string;
  45168. shader: string;
  45169. };
  45170. }
  45171. declare module BABYLON {
  45172. /**
  45173. * Background material used to create an efficient environement around your scene.
  45174. */
  45175. export class BackgroundMaterial extends PushMaterial {
  45176. /**
  45177. * Standard reflectance value at parallel view angle.
  45178. */
  45179. static StandardReflectance0: number;
  45180. /**
  45181. * Standard reflectance value at grazing angle.
  45182. */
  45183. static StandardReflectance90: number;
  45184. protected _primaryColor: Color3;
  45185. /**
  45186. * Key light Color (multiply against the environement texture)
  45187. */
  45188. primaryColor: Color3;
  45189. protected __perceptualColor: Nullable<Color3>;
  45190. /**
  45191. * Experimental Internal Use Only.
  45192. *
  45193. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45194. * This acts as a helper to set the primary color to a more "human friendly" value.
  45195. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45196. * output color as close as possible from the chosen value.
  45197. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45198. * part of lighting setup.)
  45199. */
  45200. _perceptualColor: Nullable<Color3>;
  45201. protected _primaryColorShadowLevel: float;
  45202. /**
  45203. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45204. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45205. */
  45206. primaryColorShadowLevel: float;
  45207. protected _primaryColorHighlightLevel: float;
  45208. /**
  45209. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45210. * The primary color is used at the level chosen to define what the white area would look.
  45211. */
  45212. primaryColorHighlightLevel: float;
  45213. protected _reflectionTexture: Nullable<BaseTexture>;
  45214. /**
  45215. * Reflection Texture used in the material.
  45216. * Should be author in a specific way for the best result (refer to the documentation).
  45217. */
  45218. reflectionTexture: Nullable<BaseTexture>;
  45219. protected _reflectionBlur: float;
  45220. /**
  45221. * Reflection Texture level of blur.
  45222. *
  45223. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45224. * texture twice.
  45225. */
  45226. reflectionBlur: float;
  45227. protected _diffuseTexture: Nullable<BaseTexture>;
  45228. /**
  45229. * Diffuse Texture used in the material.
  45230. * Should be author in a specific way for the best result (refer to the documentation).
  45231. */
  45232. diffuseTexture: Nullable<BaseTexture>;
  45233. protected _shadowLights: Nullable<IShadowLight[]>;
  45234. /**
  45235. * Specify the list of lights casting shadow on the material.
  45236. * All scene shadow lights will be included if null.
  45237. */
  45238. shadowLights: Nullable<IShadowLight[]>;
  45239. protected _shadowLevel: float;
  45240. /**
  45241. * Helps adjusting the shadow to a softer level if required.
  45242. * 0 means black shadows and 1 means no shadows.
  45243. */
  45244. shadowLevel: float;
  45245. protected _sceneCenter: Vector3;
  45246. /**
  45247. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45248. * It is usually zero but might be interesting to modify according to your setup.
  45249. */
  45250. sceneCenter: Vector3;
  45251. protected _opacityFresnel: boolean;
  45252. /**
  45253. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45254. * This helps ensuring a nice transition when the camera goes under the ground.
  45255. */
  45256. opacityFresnel: boolean;
  45257. protected _reflectionFresnel: boolean;
  45258. /**
  45259. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45260. * This helps adding a mirror texture on the ground.
  45261. */
  45262. reflectionFresnel: boolean;
  45263. protected _reflectionFalloffDistance: number;
  45264. /**
  45265. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45266. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45267. */
  45268. reflectionFalloffDistance: number;
  45269. protected _reflectionAmount: number;
  45270. /**
  45271. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45272. */
  45273. reflectionAmount: number;
  45274. protected _reflectionReflectance0: number;
  45275. /**
  45276. * This specifies the weight of the reflection at grazing angle.
  45277. */
  45278. reflectionReflectance0: number;
  45279. protected _reflectionReflectance90: number;
  45280. /**
  45281. * This specifies the weight of the reflection at a perpendicular point of view.
  45282. */
  45283. reflectionReflectance90: number;
  45284. /**
  45285. * Sets the reflection reflectance fresnel values according to the default standard
  45286. * empirically know to work well :-)
  45287. */
  45288. reflectionStandardFresnelWeight: number;
  45289. protected _useRGBColor: boolean;
  45290. /**
  45291. * Helps to directly use the maps channels instead of their level.
  45292. */
  45293. useRGBColor: boolean;
  45294. protected _enableNoise: boolean;
  45295. /**
  45296. * This helps reducing the banding effect that could occur on the background.
  45297. */
  45298. enableNoise: boolean;
  45299. /**
  45300. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45301. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45302. * Recommended to be keep at 1.0 except for special cases.
  45303. */
  45304. fovMultiplier: number;
  45305. private _fovMultiplier;
  45306. /**
  45307. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45308. */
  45309. useEquirectangularFOV: boolean;
  45310. private _maxSimultaneousLights;
  45311. /**
  45312. * Number of Simultaneous lights allowed on the material.
  45313. */
  45314. maxSimultaneousLights: int;
  45315. /**
  45316. * Default configuration related to image processing available in the Background Material.
  45317. */
  45318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45319. /**
  45320. * Keep track of the image processing observer to allow dispose and replace.
  45321. */
  45322. private _imageProcessingObserver;
  45323. /**
  45324. * Attaches a new image processing configuration to the PBR Material.
  45325. * @param configuration (if null the scene configuration will be use)
  45326. */
  45327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45328. /**
  45329. * Gets the image processing configuration used either in this material.
  45330. */
  45331. /**
  45332. * Sets the Default image processing configuration used either in the this material.
  45333. *
  45334. * If sets to null, the scene one is in use.
  45335. */
  45336. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45337. /**
  45338. * Gets wether the color curves effect is enabled.
  45339. */
  45340. /**
  45341. * Sets wether the color curves effect is enabled.
  45342. */
  45343. cameraColorCurvesEnabled: boolean;
  45344. /**
  45345. * Gets wether the color grading effect is enabled.
  45346. */
  45347. /**
  45348. * Gets wether the color grading effect is enabled.
  45349. */
  45350. cameraColorGradingEnabled: boolean;
  45351. /**
  45352. * Gets wether tonemapping is enabled or not.
  45353. */
  45354. /**
  45355. * Sets wether tonemapping is enabled or not
  45356. */
  45357. cameraToneMappingEnabled: boolean;
  45358. /**
  45359. * The camera exposure used on this material.
  45360. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45361. * This corresponds to a photographic exposure.
  45362. */
  45363. /**
  45364. * The camera exposure used on this material.
  45365. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45366. * This corresponds to a photographic exposure.
  45367. */
  45368. cameraExposure: float;
  45369. /**
  45370. * Gets The camera contrast used on this material.
  45371. */
  45372. /**
  45373. * Sets The camera contrast used on this material.
  45374. */
  45375. cameraContrast: float;
  45376. /**
  45377. * Gets the Color Grading 2D Lookup Texture.
  45378. */
  45379. /**
  45380. * Sets the Color Grading 2D Lookup Texture.
  45381. */
  45382. cameraColorGradingTexture: Nullable<BaseTexture>;
  45383. /**
  45384. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45385. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45386. * 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;
  45387. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45388. */
  45389. /**
  45390. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45391. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45392. * 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;
  45393. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45394. */
  45395. cameraColorCurves: Nullable<ColorCurves>;
  45396. /**
  45397. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45398. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45399. */
  45400. switchToBGR: boolean;
  45401. private _renderTargets;
  45402. private _reflectionControls;
  45403. private _white;
  45404. private _primaryShadowColor;
  45405. private _primaryHighlightColor;
  45406. /**
  45407. * Instantiates a Background Material in the given scene
  45408. * @param name The friendly name of the material
  45409. * @param scene The scene to add the material to
  45410. */
  45411. constructor(name: string, scene: Scene);
  45412. /**
  45413. * Gets a boolean indicating that current material needs to register RTT
  45414. */
  45415. readonly hasRenderTargetTextures: boolean;
  45416. /**
  45417. * The entire material has been created in order to prevent overdraw.
  45418. * @returns false
  45419. */
  45420. needAlphaTesting(): boolean;
  45421. /**
  45422. * The entire material has been created in order to prevent overdraw.
  45423. * @returns true if blending is enable
  45424. */
  45425. needAlphaBlending(): boolean;
  45426. /**
  45427. * Checks wether the material is ready to be rendered for a given mesh.
  45428. * @param mesh The mesh to render
  45429. * @param subMesh The submesh to check against
  45430. * @param useInstances Specify wether or not the material is used with instances
  45431. * @returns true if all the dependencies are ready (Textures, Effects...)
  45432. */
  45433. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45434. /**
  45435. * Compute the primary color according to the chosen perceptual color.
  45436. */
  45437. private _computePrimaryColorFromPerceptualColor;
  45438. /**
  45439. * Compute the highlights and shadow colors according to their chosen levels.
  45440. */
  45441. private _computePrimaryColors;
  45442. /**
  45443. * Build the uniform buffer used in the material.
  45444. */
  45445. buildUniformLayout(): void;
  45446. /**
  45447. * Unbind the material.
  45448. */
  45449. unbind(): void;
  45450. /**
  45451. * Bind only the world matrix to the material.
  45452. * @param world The world matrix to bind.
  45453. */
  45454. bindOnlyWorldMatrix(world: Matrix): void;
  45455. /**
  45456. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45457. * @param world The world matrix to bind.
  45458. * @param subMesh The submesh to bind for.
  45459. */
  45460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45461. /**
  45462. * Checks to see if a texture is used in the material.
  45463. * @param texture - Base texture to use.
  45464. * @returns - Boolean specifying if a texture is used in the material.
  45465. */
  45466. hasTexture(texture: BaseTexture): boolean;
  45467. /**
  45468. * Dispose the material.
  45469. * @param forceDisposeEffect Force disposal of the associated effect.
  45470. * @param forceDisposeTextures Force disposal of the associated textures.
  45471. */
  45472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45473. /**
  45474. * Clones the material.
  45475. * @param name The cloned name.
  45476. * @returns The cloned material.
  45477. */
  45478. clone(name: string): BackgroundMaterial;
  45479. /**
  45480. * Serializes the current material to its JSON representation.
  45481. * @returns The JSON representation.
  45482. */
  45483. serialize(): any;
  45484. /**
  45485. * Gets the class name of the material
  45486. * @returns "BackgroundMaterial"
  45487. */
  45488. getClassName(): string;
  45489. /**
  45490. * Parse a JSON input to create back a background material.
  45491. * @param source The JSON data to parse
  45492. * @param scene The scene to create the parsed material in
  45493. * @param rootUrl The root url of the assets the material depends upon
  45494. * @returns the instantiated BackgroundMaterial.
  45495. */
  45496. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45497. }
  45498. }
  45499. declare module BABYLON {
  45500. /**
  45501. * Represents the different options available during the creation of
  45502. * a Environment helper.
  45503. *
  45504. * This can control the default ground, skybox and image processing setup of your scene.
  45505. */
  45506. export interface IEnvironmentHelperOptions {
  45507. /**
  45508. * Specifies wether or not to create a ground.
  45509. * True by default.
  45510. */
  45511. createGround: boolean;
  45512. /**
  45513. * Specifies the ground size.
  45514. * 15 by default.
  45515. */
  45516. groundSize: number;
  45517. /**
  45518. * The texture used on the ground for the main color.
  45519. * Comes from the BabylonJS CDN by default.
  45520. *
  45521. * Remarks: Can be either a texture or a url.
  45522. */
  45523. groundTexture: string | BaseTexture;
  45524. /**
  45525. * The color mixed in the ground texture by default.
  45526. * BabylonJS clearColor by default.
  45527. */
  45528. groundColor: Color3;
  45529. /**
  45530. * Specifies the ground opacity.
  45531. * 1 by default.
  45532. */
  45533. groundOpacity: number;
  45534. /**
  45535. * Enables the ground to receive shadows.
  45536. * True by default.
  45537. */
  45538. enableGroundShadow: boolean;
  45539. /**
  45540. * Helps preventing the shadow to be fully black on the ground.
  45541. * 0.5 by default.
  45542. */
  45543. groundShadowLevel: number;
  45544. /**
  45545. * Creates a mirror texture attach to the ground.
  45546. * false by default.
  45547. */
  45548. enableGroundMirror: boolean;
  45549. /**
  45550. * Specifies the ground mirror size ratio.
  45551. * 0.3 by default as the default kernel is 64.
  45552. */
  45553. groundMirrorSizeRatio: number;
  45554. /**
  45555. * Specifies the ground mirror blur kernel size.
  45556. * 64 by default.
  45557. */
  45558. groundMirrorBlurKernel: number;
  45559. /**
  45560. * Specifies the ground mirror visibility amount.
  45561. * 1 by default
  45562. */
  45563. groundMirrorAmount: number;
  45564. /**
  45565. * Specifies the ground mirror reflectance weight.
  45566. * This uses the standard weight of the background material to setup the fresnel effect
  45567. * of the mirror.
  45568. * 1 by default.
  45569. */
  45570. groundMirrorFresnelWeight: number;
  45571. /**
  45572. * Specifies the ground mirror Falloff distance.
  45573. * This can helps reducing the size of the reflection.
  45574. * 0 by Default.
  45575. */
  45576. groundMirrorFallOffDistance: number;
  45577. /**
  45578. * Specifies the ground mirror texture type.
  45579. * Unsigned Int by Default.
  45580. */
  45581. groundMirrorTextureType: number;
  45582. /**
  45583. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45584. * the shown objects.
  45585. */
  45586. groundYBias: number;
  45587. /**
  45588. * Specifies wether or not to create a skybox.
  45589. * True by default.
  45590. */
  45591. createSkybox: boolean;
  45592. /**
  45593. * Specifies the skybox size.
  45594. * 20 by default.
  45595. */
  45596. skyboxSize: number;
  45597. /**
  45598. * The texture used on the skybox for the main color.
  45599. * Comes from the BabylonJS CDN by default.
  45600. *
  45601. * Remarks: Can be either a texture or a url.
  45602. */
  45603. skyboxTexture: string | BaseTexture;
  45604. /**
  45605. * The color mixed in the skybox texture by default.
  45606. * BabylonJS clearColor by default.
  45607. */
  45608. skyboxColor: Color3;
  45609. /**
  45610. * The background rotation around the Y axis of the scene.
  45611. * This helps aligning the key lights of your scene with the background.
  45612. * 0 by default.
  45613. */
  45614. backgroundYRotation: number;
  45615. /**
  45616. * Compute automatically the size of the elements to best fit with the scene.
  45617. */
  45618. sizeAuto: boolean;
  45619. /**
  45620. * Default position of the rootMesh if autoSize is not true.
  45621. */
  45622. rootPosition: Vector3;
  45623. /**
  45624. * Sets up the image processing in the scene.
  45625. * true by default.
  45626. */
  45627. setupImageProcessing: boolean;
  45628. /**
  45629. * The texture used as your environment texture in the scene.
  45630. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45631. *
  45632. * Remarks: Can be either a texture or a url.
  45633. */
  45634. environmentTexture: string | BaseTexture;
  45635. /**
  45636. * The value of the exposure to apply to the scene.
  45637. * 0.6 by default if setupImageProcessing is true.
  45638. */
  45639. cameraExposure: number;
  45640. /**
  45641. * The value of the contrast to apply to the scene.
  45642. * 1.6 by default if setupImageProcessing is true.
  45643. */
  45644. cameraContrast: number;
  45645. /**
  45646. * Specifies wether or not tonemapping should be enabled in the scene.
  45647. * true by default if setupImageProcessing is true.
  45648. */
  45649. toneMappingEnabled: boolean;
  45650. }
  45651. /**
  45652. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45653. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45654. * It also helps with the default setup of your imageProcessing configuration.
  45655. */
  45656. export class EnvironmentHelper {
  45657. /**
  45658. * Default ground texture URL.
  45659. */
  45660. private static _groundTextureCDNUrl;
  45661. /**
  45662. * Default skybox texture URL.
  45663. */
  45664. private static _skyboxTextureCDNUrl;
  45665. /**
  45666. * Default environment texture URL.
  45667. */
  45668. private static _environmentTextureCDNUrl;
  45669. /**
  45670. * Creates the default options for the helper.
  45671. */
  45672. private static _getDefaultOptions;
  45673. private _rootMesh;
  45674. /**
  45675. * Gets the root mesh created by the helper.
  45676. */
  45677. readonly rootMesh: Mesh;
  45678. private _skybox;
  45679. /**
  45680. * Gets the skybox created by the helper.
  45681. */
  45682. readonly skybox: Nullable<Mesh>;
  45683. private _skyboxTexture;
  45684. /**
  45685. * Gets the skybox texture created by the helper.
  45686. */
  45687. readonly skyboxTexture: Nullable<BaseTexture>;
  45688. private _skyboxMaterial;
  45689. /**
  45690. * Gets the skybox material created by the helper.
  45691. */
  45692. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45693. private _ground;
  45694. /**
  45695. * Gets the ground mesh created by the helper.
  45696. */
  45697. readonly ground: Nullable<Mesh>;
  45698. private _groundTexture;
  45699. /**
  45700. * Gets the ground texture created by the helper.
  45701. */
  45702. readonly groundTexture: Nullable<BaseTexture>;
  45703. private _groundMirror;
  45704. /**
  45705. * Gets the ground mirror created by the helper.
  45706. */
  45707. readonly groundMirror: Nullable<MirrorTexture>;
  45708. /**
  45709. * Gets the ground mirror render list to helps pushing the meshes
  45710. * you wish in the ground reflection.
  45711. */
  45712. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45713. private _groundMaterial;
  45714. /**
  45715. * Gets the ground material created by the helper.
  45716. */
  45717. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45718. /**
  45719. * Stores the creation options.
  45720. */
  45721. private readonly _scene;
  45722. private _options;
  45723. /**
  45724. * This observable will be notified with any error during the creation of the environment,
  45725. * mainly texture creation errors.
  45726. */
  45727. onErrorObservable: Observable<{
  45728. message?: string;
  45729. exception?: any;
  45730. }>;
  45731. /**
  45732. * constructor
  45733. * @param options Defines the options we want to customize the helper
  45734. * @param scene The scene to add the material to
  45735. */
  45736. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45737. /**
  45738. * Updates the background according to the new options
  45739. * @param options
  45740. */
  45741. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45742. /**
  45743. * Sets the primary color of all the available elements.
  45744. * @param color the main color to affect to the ground and the background
  45745. */
  45746. setMainColor(color: Color3): void;
  45747. /**
  45748. * Setup the image processing according to the specified options.
  45749. */
  45750. private _setupImageProcessing;
  45751. /**
  45752. * Setup the environment texture according to the specified options.
  45753. */
  45754. private _setupEnvironmentTexture;
  45755. /**
  45756. * Setup the background according to the specified options.
  45757. */
  45758. private _setupBackground;
  45759. /**
  45760. * Get the scene sizes according to the setup.
  45761. */
  45762. private _getSceneSize;
  45763. /**
  45764. * Setup the ground according to the specified options.
  45765. */
  45766. private _setupGround;
  45767. /**
  45768. * Setup the ground material according to the specified options.
  45769. */
  45770. private _setupGroundMaterial;
  45771. /**
  45772. * Setup the ground diffuse texture according to the specified options.
  45773. */
  45774. private _setupGroundDiffuseTexture;
  45775. /**
  45776. * Setup the ground mirror texture according to the specified options.
  45777. */
  45778. private _setupGroundMirrorTexture;
  45779. /**
  45780. * Setup the ground to receive the mirror texture.
  45781. */
  45782. private _setupMirrorInGroundMaterial;
  45783. /**
  45784. * Setup the skybox according to the specified options.
  45785. */
  45786. private _setupSkybox;
  45787. /**
  45788. * Setup the skybox material according to the specified options.
  45789. */
  45790. private _setupSkyboxMaterial;
  45791. /**
  45792. * Setup the skybox reflection texture according to the specified options.
  45793. */
  45794. private _setupSkyboxReflectionTexture;
  45795. private _errorHandler;
  45796. /**
  45797. * Dispose all the elements created by the Helper.
  45798. */
  45799. dispose(): void;
  45800. }
  45801. }
  45802. declare module BABYLON {
  45803. /**
  45804. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45805. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45806. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45807. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45808. */
  45809. export class PhotoDome extends TransformNode {
  45810. /**
  45811. * Define the image as a Monoscopic panoramic 360 image.
  45812. */
  45813. static readonly MODE_MONOSCOPIC: number;
  45814. /**
  45815. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45816. */
  45817. static readonly MODE_TOPBOTTOM: number;
  45818. /**
  45819. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45820. */
  45821. static readonly MODE_SIDEBYSIDE: number;
  45822. private _useDirectMapping;
  45823. /**
  45824. * The texture being displayed on the sphere
  45825. */
  45826. protected _photoTexture: Texture;
  45827. /**
  45828. * Gets or sets the texture being displayed on the sphere
  45829. */
  45830. photoTexture: Texture;
  45831. /**
  45832. * Observable raised when an error occured while loading the 360 image
  45833. */
  45834. onLoadErrorObservable: Observable<string>;
  45835. /**
  45836. * The skybox material
  45837. */
  45838. protected _material: BackgroundMaterial;
  45839. /**
  45840. * The surface used for the skybox
  45841. */
  45842. protected _mesh: Mesh;
  45843. /**
  45844. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45845. * Also see the options.resolution property.
  45846. */
  45847. fovMultiplier: number;
  45848. private _imageMode;
  45849. /**
  45850. * Gets or set the current video mode for the video. It can be:
  45851. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45852. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45853. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45854. */
  45855. imageMode: number;
  45856. /**
  45857. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45858. * @param name Element's name, child elements will append suffixes for their own names.
  45859. * @param urlsOfPhoto defines the url of the photo to display
  45860. * @param options defines an object containing optional or exposed sub element properties
  45861. * @param onError defines a callback called when an error occured while loading the texture
  45862. */
  45863. constructor(name: string, urlOfPhoto: string, options: {
  45864. resolution?: number;
  45865. size?: number;
  45866. useDirectMapping?: boolean;
  45867. faceForward?: boolean;
  45868. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45869. private _onBeforeCameraRenderObserver;
  45870. private _changeImageMode;
  45871. /**
  45872. * Releases resources associated with this node.
  45873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45875. */
  45876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45877. }
  45878. }
  45879. declare module BABYLON {
  45880. /**
  45881. * Class used to host texture specific utilities
  45882. */
  45883. export class BRDFTextureTools {
  45884. /**
  45885. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45886. * @param texture the texture to expand.
  45887. */
  45888. private static _ExpandDefaultBRDFTexture;
  45889. /**
  45890. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45891. * @param scene defines the hosting scene
  45892. * @returns the environment BRDF texture
  45893. */
  45894. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45895. private static _environmentBRDFBase64Texture;
  45896. }
  45897. }
  45898. declare module BABYLON {
  45899. /**
  45900. * @hidden
  45901. */
  45902. export interface IMaterialClearCoatDefines {
  45903. CLEARCOAT: boolean;
  45904. CLEARCOAT_DEFAULTIOR: boolean;
  45905. CLEARCOAT_TEXTURE: boolean;
  45906. CLEARCOAT_TEXTUREDIRECTUV: number;
  45907. CLEARCOAT_BUMP: boolean;
  45908. CLEARCOAT_BUMPDIRECTUV: number;
  45909. CLEARCOAT_TINT: boolean;
  45910. CLEARCOAT_TINT_TEXTURE: boolean;
  45911. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45912. /** @hidden */
  45913. _areTexturesDirty: boolean;
  45914. }
  45915. /**
  45916. * Define the code related to the clear coat parameters of the pbr material.
  45917. */
  45918. export class PBRClearCoatConfiguration {
  45919. /**
  45920. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45921. * The default fits with a polyurethane material.
  45922. */
  45923. private static readonly _DefaultIndexOfRefraction;
  45924. private _isEnabled;
  45925. /**
  45926. * Defines if the clear coat is enabled in the material.
  45927. */
  45928. isEnabled: boolean;
  45929. /**
  45930. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45931. */
  45932. intensity: number;
  45933. /**
  45934. * Defines the clear coat layer roughness.
  45935. */
  45936. roughness: number;
  45937. private _indexOfRefraction;
  45938. /**
  45939. * Defines the index of refraction of the clear coat.
  45940. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45941. * The default fits with a polyurethane material.
  45942. * Changing the default value is more performance intensive.
  45943. */
  45944. indexOfRefraction: number;
  45945. private _texture;
  45946. /**
  45947. * Stores the clear coat values in a texture.
  45948. */
  45949. texture: Nullable<BaseTexture>;
  45950. private _bumpTexture;
  45951. /**
  45952. * Define the clear coat specific bump texture.
  45953. */
  45954. bumpTexture: Nullable<BaseTexture>;
  45955. private _isTintEnabled;
  45956. /**
  45957. * Defines if the clear coat tint is enabled in the material.
  45958. */
  45959. isTintEnabled: boolean;
  45960. /**
  45961. * Defines the clear coat tint of the material.
  45962. * This is only use if tint is enabled
  45963. */
  45964. tintColor: Color3;
  45965. /**
  45966. * Defines the distance at which the tint color should be found in the
  45967. * clear coat media.
  45968. * This is only use if tint is enabled
  45969. */
  45970. tintColorAtDistance: number;
  45971. /**
  45972. * Defines the clear coat layer thickness.
  45973. * This is only use if tint is enabled
  45974. */
  45975. tintThickness: number;
  45976. private _tintTexture;
  45977. /**
  45978. * Stores the clear tint values in a texture.
  45979. * rgb is tint
  45980. * a is a thickness factor
  45981. */
  45982. tintTexture: Nullable<BaseTexture>;
  45983. /** @hidden */
  45984. private _internalMarkAllSubMeshesAsTexturesDirty;
  45985. /** @hidden */
  45986. _markAllSubMeshesAsTexturesDirty(): void;
  45987. /**
  45988. * Instantiate a new istance of clear coat configuration.
  45989. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45990. */
  45991. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45992. /**
  45993. * Gets wehter the submesh is ready to be used or not.
  45994. * @param defines the list of "defines" to update.
  45995. * @param scene defines the scene the material belongs to.
  45996. * @param engine defines the engine the material belongs to.
  45997. * @param disableBumpMap defines wether the material disables bump or not.
  45998. * @returns - boolean indicating that the submesh is ready or not.
  45999. */
  46000. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46001. /**
  46002. * Checks to see if a texture is used in the material.
  46003. * @param defines the list of "defines" to update.
  46004. * @param scene defines the scene to the material belongs to.
  46005. */
  46006. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46007. /**
  46008. * Binds the material data.
  46009. * @param uniformBuffer defines the Uniform buffer to fill in.
  46010. * @param scene defines the scene the material belongs to.
  46011. * @param engine defines the engine the material belongs to.
  46012. * @param disableBumpMap defines wether the material disables bump or not.
  46013. * @param isFrozen defines wether the material is frozen or not.
  46014. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46015. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46016. */
  46017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46018. /**
  46019. * Checks to see if a texture is used in the material.
  46020. * @param texture - Base texture to use.
  46021. * @returns - Boolean specifying if a texture is used in the material.
  46022. */
  46023. hasTexture(texture: BaseTexture): boolean;
  46024. /**
  46025. * Returns an array of the actively used textures.
  46026. * @param activeTextures Array of BaseTextures
  46027. */
  46028. getActiveTextures(activeTextures: BaseTexture[]): void;
  46029. /**
  46030. * Returns the animatable textures.
  46031. * @param animatables Array of animatable textures.
  46032. */
  46033. getAnimatables(animatables: IAnimatable[]): void;
  46034. /**
  46035. * Disposes the resources of the material.
  46036. * @param forceDisposeTextures - Forces the disposal of all textures.
  46037. */
  46038. dispose(forceDisposeTextures?: boolean): void;
  46039. /**
  46040. * Get the current class name of the texture useful for serialization or dynamic coding.
  46041. * @returns "PBRClearCoatConfiguration"
  46042. */
  46043. getClassName(): string;
  46044. /**
  46045. * Add fallbacks to the effect fallbacks list.
  46046. * @param defines defines the Base texture to use.
  46047. * @param fallbacks defines the current fallback list.
  46048. * @param currentRank defines the current fallback rank.
  46049. * @returns the new fallback rank.
  46050. */
  46051. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46052. /**
  46053. * Add the required uniforms to the current list.
  46054. * @param uniforms defines the current uniform list.
  46055. */
  46056. static AddUniforms(uniforms: string[]): void;
  46057. /**
  46058. * Add the required samplers to the current list.
  46059. * @param samplers defines the current sampler list.
  46060. */
  46061. static AddSamplers(samplers: string[]): void;
  46062. /**
  46063. * Add the required uniforms to the current buffer.
  46064. * @param uniformBuffer defines the current uniform buffer.
  46065. */
  46066. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46067. /**
  46068. * Makes a duplicate of the current configuration into another one.
  46069. * @param clearCoatConfiguration define the config where to copy the info
  46070. */
  46071. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46072. /**
  46073. * Serializes this clear coat configuration.
  46074. * @returns - An object with the serialized config.
  46075. */
  46076. serialize(): any;
  46077. /**
  46078. * Parses a anisotropy Configuration from a serialized object.
  46079. * @param source - Serialized object.
  46080. * @param scene Defines the scene we are parsing for
  46081. * @param rootUrl Defines the rootUrl to load from
  46082. */
  46083. parse(source: any, scene: Scene, rootUrl: string): void;
  46084. }
  46085. }
  46086. declare module BABYLON {
  46087. /**
  46088. * @hidden
  46089. */
  46090. export interface IMaterialAnisotropicDefines {
  46091. ANISOTROPIC: boolean;
  46092. ANISOTROPIC_TEXTURE: boolean;
  46093. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46094. MAINUV1: boolean;
  46095. _areTexturesDirty: boolean;
  46096. _needUVs: boolean;
  46097. }
  46098. /**
  46099. * Define the code related to the anisotropic parameters of the pbr material.
  46100. */
  46101. export class PBRAnisotropicConfiguration {
  46102. private _isEnabled;
  46103. /**
  46104. * Defines if the anisotropy is enabled in the material.
  46105. */
  46106. isEnabled: boolean;
  46107. /**
  46108. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46109. */
  46110. intensity: number;
  46111. /**
  46112. * Defines if the effect is along the tangents, bitangents or in between.
  46113. * By default, the effect is "strectching" the highlights along the tangents.
  46114. */
  46115. direction: Vector2;
  46116. private _texture;
  46117. /**
  46118. * Stores the anisotropy values in a texture.
  46119. * rg is direction (like normal from -1 to 1)
  46120. * b is a intensity
  46121. */
  46122. texture: Nullable<BaseTexture>;
  46123. /** @hidden */
  46124. private _internalMarkAllSubMeshesAsTexturesDirty;
  46125. /** @hidden */
  46126. _markAllSubMeshesAsTexturesDirty(): void;
  46127. /**
  46128. * Instantiate a new istance of anisotropy configuration.
  46129. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46130. */
  46131. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46132. /**
  46133. * Specifies that the submesh is ready to be used.
  46134. * @param defines the list of "defines" to update.
  46135. * @param scene defines the scene the material belongs to.
  46136. * @returns - boolean indicating that the submesh is ready or not.
  46137. */
  46138. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46139. /**
  46140. * Checks to see if a texture is used in the material.
  46141. * @param defines the list of "defines" to update.
  46142. * @param mesh the mesh we are preparing the defines for.
  46143. * @param scene defines the scene the material belongs to.
  46144. */
  46145. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46146. /**
  46147. * Binds the material data.
  46148. * @param uniformBuffer defines the Uniform buffer to fill in.
  46149. * @param scene defines the scene the material belongs to.
  46150. * @param isFrozen defines wether the material is frozen or not.
  46151. */
  46152. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46153. /**
  46154. * Checks to see if a texture is used in the material.
  46155. * @param texture - Base texture to use.
  46156. * @returns - Boolean specifying if a texture is used in the material.
  46157. */
  46158. hasTexture(texture: BaseTexture): boolean;
  46159. /**
  46160. * Returns an array of the actively used textures.
  46161. * @param activeTextures Array of BaseTextures
  46162. */
  46163. getActiveTextures(activeTextures: BaseTexture[]): void;
  46164. /**
  46165. * Returns the animatable textures.
  46166. * @param animatables Array of animatable textures.
  46167. */
  46168. getAnimatables(animatables: IAnimatable[]): void;
  46169. /**
  46170. * Disposes the resources of the material.
  46171. * @param forceDisposeTextures - Forces the disposal of all textures.
  46172. */
  46173. dispose(forceDisposeTextures?: boolean): void;
  46174. /**
  46175. * Get the current class name of the texture useful for serialization or dynamic coding.
  46176. * @returns "PBRAnisotropicConfiguration"
  46177. */
  46178. getClassName(): string;
  46179. /**
  46180. * Add fallbacks to the effect fallbacks list.
  46181. * @param defines defines the Base texture to use.
  46182. * @param fallbacks defines the current fallback list.
  46183. * @param currentRank defines the current fallback rank.
  46184. * @returns the new fallback rank.
  46185. */
  46186. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46187. /**
  46188. * Add the required uniforms to the current list.
  46189. * @param uniforms defines the current uniform list.
  46190. */
  46191. static AddUniforms(uniforms: string[]): void;
  46192. /**
  46193. * Add the required uniforms to the current buffer.
  46194. * @param uniformBuffer defines the current uniform buffer.
  46195. */
  46196. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46197. /**
  46198. * Add the required samplers to the current list.
  46199. * @param samplers defines the current sampler list.
  46200. */
  46201. static AddSamplers(samplers: string[]): void;
  46202. /**
  46203. * Makes a duplicate of the current configuration into another one.
  46204. * @param anisotropicConfiguration define the config where to copy the info
  46205. */
  46206. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46207. /**
  46208. * Serializes this anisotropy configuration.
  46209. * @returns - An object with the serialized config.
  46210. */
  46211. serialize(): any;
  46212. /**
  46213. * Parses a anisotropy Configuration from a serialized object.
  46214. * @param source - Serialized object.
  46215. * @param scene Defines the scene we are parsing for
  46216. * @param rootUrl Defines the rootUrl to load from
  46217. */
  46218. parse(source: any, scene: Scene, rootUrl: string): void;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /**
  46223. * @hidden
  46224. */
  46225. export interface IMaterialBRDFDefines {
  46226. BRDF_V_HEIGHT_CORRELATED: boolean;
  46227. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46228. SPHERICAL_HARMONICS: boolean;
  46229. /** @hidden */
  46230. _areMiscDirty: boolean;
  46231. }
  46232. /**
  46233. * Define the code related to the BRDF parameters of the pbr material.
  46234. */
  46235. export class PBRBRDFConfiguration {
  46236. /**
  46237. * Default value used for the energy conservation.
  46238. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46239. */
  46240. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46241. /**
  46242. * Default value used for the Smith Visibility Height Correlated mode.
  46243. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46244. */
  46245. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46246. /**
  46247. * Default value used for the IBL diffuse part.
  46248. * This can help switching back to the polynomials mode globally which is a tiny bit
  46249. * less GPU intensive at the drawback of a lower quality.
  46250. */
  46251. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46252. private _useEnergyConservation;
  46253. /**
  46254. * Defines if the material uses energy conservation.
  46255. */
  46256. useEnergyConservation: boolean;
  46257. private _useSmithVisibilityHeightCorrelated;
  46258. /**
  46259. * LEGACY Mode set to false
  46260. * Defines if the material uses height smith correlated visibility term.
  46261. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46262. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46263. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46264. * Not relying on height correlated will also disable energy conservation.
  46265. */
  46266. useSmithVisibilityHeightCorrelated: boolean;
  46267. private _useSphericalHarmonics;
  46268. /**
  46269. * LEGACY Mode set to false
  46270. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46271. * diffuse part of the IBL.
  46272. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46273. * to the ground truth.
  46274. */
  46275. useSphericalHarmonics: boolean;
  46276. /** @hidden */
  46277. private _internalMarkAllSubMeshesAsMiscDirty;
  46278. /** @hidden */
  46279. _markAllSubMeshesAsMiscDirty(): void;
  46280. /**
  46281. * Instantiate a new istance of clear coat configuration.
  46282. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46283. */
  46284. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46285. /**
  46286. * Checks to see if a texture is used in the material.
  46287. * @param defines the list of "defines" to update.
  46288. */
  46289. prepareDefines(defines: IMaterialBRDFDefines): void;
  46290. /**
  46291. * Get the current class name of the texture useful for serialization or dynamic coding.
  46292. * @returns "PBRClearCoatConfiguration"
  46293. */
  46294. getClassName(): string;
  46295. /**
  46296. * Makes a duplicate of the current configuration into another one.
  46297. * @param brdfConfiguration define the config where to copy the info
  46298. */
  46299. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46300. /**
  46301. * Serializes this BRDF configuration.
  46302. * @returns - An object with the serialized config.
  46303. */
  46304. serialize(): any;
  46305. /**
  46306. * Parses a anisotropy Configuration from a serialized object.
  46307. * @param source - Serialized object.
  46308. * @param scene Defines the scene we are parsing for
  46309. * @param rootUrl Defines the rootUrl to load from
  46310. */
  46311. parse(source: any, scene: Scene, rootUrl: string): void;
  46312. }
  46313. }
  46314. declare module BABYLON {
  46315. /**
  46316. * @hidden
  46317. */
  46318. export interface IMaterialSheenDefines {
  46319. SHEEN: boolean;
  46320. SHEEN_TEXTURE: boolean;
  46321. SHEEN_TEXTUREDIRECTUV: number;
  46322. SHEEN_LINKWITHALBEDO: boolean;
  46323. /** @hidden */
  46324. _areTexturesDirty: boolean;
  46325. }
  46326. /**
  46327. * Define the code related to the Sheen parameters of the pbr material.
  46328. */
  46329. export class PBRSheenConfiguration {
  46330. private _isEnabled;
  46331. /**
  46332. * Defines if the material uses sheen.
  46333. */
  46334. isEnabled: boolean;
  46335. private _linkSheenWithAlbedo;
  46336. /**
  46337. * Defines if the sheen is linked to the sheen color.
  46338. */
  46339. linkSheenWithAlbedo: boolean;
  46340. /**
  46341. * Defines the sheen intensity.
  46342. */
  46343. intensity: number;
  46344. /**
  46345. * Defines the sheen color.
  46346. */
  46347. color: Color3;
  46348. private _texture;
  46349. /**
  46350. * Stores the sheen tint values in a texture.
  46351. * rgb is tint
  46352. * a is a intensity
  46353. */
  46354. texture: Nullable<BaseTexture>;
  46355. /** @hidden */
  46356. private _internalMarkAllSubMeshesAsTexturesDirty;
  46357. /** @hidden */
  46358. _markAllSubMeshesAsTexturesDirty(): void;
  46359. /**
  46360. * Instantiate a new istance of clear coat configuration.
  46361. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46362. */
  46363. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46364. /**
  46365. * Specifies that the submesh is ready to be used.
  46366. * @param defines the list of "defines" to update.
  46367. * @param scene defines the scene the material belongs to.
  46368. * @returns - boolean indicating that the submesh is ready or not.
  46369. */
  46370. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46371. /**
  46372. * Checks to see if a texture is used in the material.
  46373. * @param defines the list of "defines" to update.
  46374. * @param scene defines the scene the material belongs to.
  46375. */
  46376. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46377. /**
  46378. * Binds the material data.
  46379. * @param uniformBuffer defines the Uniform buffer to fill in.
  46380. * @param scene defines the scene the material belongs to.
  46381. * @param isFrozen defines wether the material is frozen or not.
  46382. */
  46383. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46384. /**
  46385. * Checks to see if a texture is used in the material.
  46386. * @param texture - Base texture to use.
  46387. * @returns - Boolean specifying if a texture is used in the material.
  46388. */
  46389. hasTexture(texture: BaseTexture): boolean;
  46390. /**
  46391. * Returns an array of the actively used textures.
  46392. * @param activeTextures Array of BaseTextures
  46393. */
  46394. getActiveTextures(activeTextures: BaseTexture[]): void;
  46395. /**
  46396. * Returns the animatable textures.
  46397. * @param animatables Array of animatable textures.
  46398. */
  46399. getAnimatables(animatables: IAnimatable[]): void;
  46400. /**
  46401. * Disposes the resources of the material.
  46402. * @param forceDisposeTextures - Forces the disposal of all textures.
  46403. */
  46404. dispose(forceDisposeTextures?: boolean): void;
  46405. /**
  46406. * Get the current class name of the texture useful for serialization or dynamic coding.
  46407. * @returns "PBRSheenConfiguration"
  46408. */
  46409. getClassName(): string;
  46410. /**
  46411. * Add fallbacks to the effect fallbacks list.
  46412. * @param defines defines the Base texture to use.
  46413. * @param fallbacks defines the current fallback list.
  46414. * @param currentRank defines the current fallback rank.
  46415. * @returns the new fallback rank.
  46416. */
  46417. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46418. /**
  46419. * Add the required uniforms to the current list.
  46420. * @param uniforms defines the current uniform list.
  46421. */
  46422. static AddUniforms(uniforms: string[]): void;
  46423. /**
  46424. * Add the required uniforms to the current buffer.
  46425. * @param uniformBuffer defines the current uniform buffer.
  46426. */
  46427. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46428. /**
  46429. * Add the required samplers to the current list.
  46430. * @param samplers defines the current sampler list.
  46431. */
  46432. static AddSamplers(samplers: string[]): void;
  46433. /**
  46434. * Makes a duplicate of the current configuration into another one.
  46435. * @param sheenConfiguration define the config where to copy the info
  46436. */
  46437. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46438. /**
  46439. * Serializes this BRDF configuration.
  46440. * @returns - An object with the serialized config.
  46441. */
  46442. serialize(): any;
  46443. /**
  46444. * Parses a anisotropy Configuration from a serialized object.
  46445. * @param source - Serialized object.
  46446. * @param scene Defines the scene we are parsing for
  46447. * @param rootUrl Defines the rootUrl to load from
  46448. */
  46449. parse(source: any, scene: Scene, rootUrl: string): void;
  46450. }
  46451. }
  46452. declare module BABYLON {
  46453. /**
  46454. * @hidden
  46455. */
  46456. export interface IMaterialSubSurfaceDefines {
  46457. SUBSURFACE: boolean;
  46458. SS_REFRACTION: boolean;
  46459. SS_TRANSLUCENCY: boolean;
  46460. SS_SCATERRING: boolean;
  46461. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46462. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46463. SS_REFRACTIONMAP_3D: boolean;
  46464. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46465. SS_LODINREFRACTIONALPHA: boolean;
  46466. SS_GAMMAREFRACTION: boolean;
  46467. SS_RGBDREFRACTION: boolean;
  46468. SS_LINEARSPECULARREFRACTION: boolean;
  46469. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46470. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46471. /** @hidden */
  46472. _areTexturesDirty: boolean;
  46473. }
  46474. /**
  46475. * Define the code related to the sub surface parameters of the pbr material.
  46476. */
  46477. export class PBRSubSurfaceConfiguration {
  46478. private _isRefractionEnabled;
  46479. /**
  46480. * Defines if the refraction is enabled in the material.
  46481. */
  46482. isRefractionEnabled: boolean;
  46483. private _isTranslucencyEnabled;
  46484. /**
  46485. * Defines if the translucency is enabled in the material.
  46486. */
  46487. isTranslucencyEnabled: boolean;
  46488. private _isScatteringEnabled;
  46489. /**
  46490. * Defines the refraction intensity of the material.
  46491. * The refraction when enabled replaces the Diffuse part of the material.
  46492. * The intensity helps transitionning between diffuse and refraction.
  46493. */
  46494. refractionIntensity: number;
  46495. /**
  46496. * Defines the translucency intensity of the material.
  46497. * When translucency has been enabled, this defines how much of the "translucency"
  46498. * is addded to the diffuse part of the material.
  46499. */
  46500. translucencyIntensity: number;
  46501. /**
  46502. * Defines the scattering intensity of the material.
  46503. * When scattering has been enabled, this defines how much of the "scattered light"
  46504. * is addded to the diffuse part of the material.
  46505. */
  46506. scatteringIntensity: number;
  46507. private _thicknessTexture;
  46508. /**
  46509. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46510. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46511. * 0 would mean minimumThickness
  46512. * 1 would mean maximumThickness
  46513. * The other channels might be use as a mask to vary the different effects intensity.
  46514. */
  46515. thicknessTexture: Nullable<BaseTexture>;
  46516. private _refractionTexture;
  46517. /**
  46518. * Defines the texture to use for refraction.
  46519. */
  46520. refractionTexture: Nullable<BaseTexture>;
  46521. private _indexOfRefraction;
  46522. /**
  46523. * Defines the index of refraction used in the material.
  46524. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46525. */
  46526. indexOfRefraction: number;
  46527. private _invertRefractionY;
  46528. /**
  46529. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46530. */
  46531. invertRefractionY: boolean;
  46532. private _linkRefractionWithTransparency;
  46533. /**
  46534. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46535. * Materials half opaque for instance using refraction could benefit from this control.
  46536. */
  46537. linkRefractionWithTransparency: boolean;
  46538. /**
  46539. * Defines the minimum thickness stored in the thickness map.
  46540. * If no thickness map is defined, this value will be used to simulate thickness.
  46541. */
  46542. minimumThickness: number;
  46543. /**
  46544. * Defines the maximum thickness stored in the thickness map.
  46545. */
  46546. maximumThickness: number;
  46547. /**
  46548. * Defines the volume tint of the material.
  46549. * This is used for both translucency and scattering.
  46550. */
  46551. tintColor: Color3;
  46552. /**
  46553. * Defines the distance at which the tint color should be found in the media.
  46554. * This is used for refraction only.
  46555. */
  46556. tintColorAtDistance: number;
  46557. /**
  46558. * Defines how far each channel transmit through the media.
  46559. * It is defined as a color to simplify it selection.
  46560. */
  46561. diffusionDistance: Color3;
  46562. private _useMaskFromThicknessTexture;
  46563. /**
  46564. * Stores the intensity of the different subsurface effects in the thickness texture.
  46565. * * the green channel is the translucency intensity.
  46566. * * the blue channel is the scattering intensity.
  46567. * * the alpha channel is the refraction intensity.
  46568. */
  46569. useMaskFromThicknessTexture: boolean;
  46570. /** @hidden */
  46571. private _internalMarkAllSubMeshesAsTexturesDirty;
  46572. /** @hidden */
  46573. _markAllSubMeshesAsTexturesDirty(): void;
  46574. /**
  46575. * Instantiate a new istance of sub surface configuration.
  46576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46577. */
  46578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46579. /**
  46580. * Gets wehter the submesh is ready to be used or not.
  46581. * @param defines the list of "defines" to update.
  46582. * @param scene defines the scene the material belongs to.
  46583. * @returns - boolean indicating that the submesh is ready or not.
  46584. */
  46585. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46586. /**
  46587. * Checks to see if a texture is used in the material.
  46588. * @param defines the list of "defines" to update.
  46589. * @param scene defines the scene to the material belongs to.
  46590. */
  46591. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46592. /**
  46593. * Binds the material data.
  46594. * @param uniformBuffer defines the Uniform buffer to fill in.
  46595. * @param scene defines the scene the material belongs to.
  46596. * @param engine defines the engine the material belongs to.
  46597. * @param isFrozen defines wether the material is frozen or not.
  46598. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46599. */
  46600. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46601. /**
  46602. * Unbinds the material from the mesh.
  46603. * @param activeEffect defines the effect that should be unbound from.
  46604. * @returns true if unbound, otherwise false
  46605. */
  46606. unbind(activeEffect: Effect): boolean;
  46607. /**
  46608. * Returns the texture used for refraction or null if none is used.
  46609. * @param scene defines the scene the material belongs to.
  46610. * @returns - Refraction texture if present. If no refraction texture and refraction
  46611. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46612. */
  46613. private _getRefractionTexture;
  46614. /**
  46615. * Returns true if alpha blending should be disabled.
  46616. */
  46617. readonly disableAlphaBlending: boolean;
  46618. /**
  46619. * Fills the list of render target textures.
  46620. * @param renderTargets the list of render targets to update
  46621. */
  46622. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46623. /**
  46624. * Checks to see if a texture is used in the material.
  46625. * @param texture - Base texture to use.
  46626. * @returns - Boolean specifying if a texture is used in the material.
  46627. */
  46628. hasTexture(texture: BaseTexture): boolean;
  46629. /**
  46630. * Gets a boolean indicating that current material needs to register RTT
  46631. * @returns true if this uses a render target otherwise false.
  46632. */
  46633. hasRenderTargetTextures(): boolean;
  46634. /**
  46635. * Returns an array of the actively used textures.
  46636. * @param activeTextures Array of BaseTextures
  46637. */
  46638. getActiveTextures(activeTextures: BaseTexture[]): void;
  46639. /**
  46640. * Returns the animatable textures.
  46641. * @param animatables Array of animatable textures.
  46642. */
  46643. getAnimatables(animatables: IAnimatable[]): void;
  46644. /**
  46645. * Disposes the resources of the material.
  46646. * @param forceDisposeTextures - Forces the disposal of all textures.
  46647. */
  46648. dispose(forceDisposeTextures?: boolean): void;
  46649. /**
  46650. * Get the current class name of the texture useful for serialization or dynamic coding.
  46651. * @returns "PBRSubSurfaceConfiguration"
  46652. */
  46653. getClassName(): string;
  46654. /**
  46655. * Add fallbacks to the effect fallbacks list.
  46656. * @param defines defines the Base texture to use.
  46657. * @param fallbacks defines the current fallback list.
  46658. * @param currentRank defines the current fallback rank.
  46659. * @returns the new fallback rank.
  46660. */
  46661. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46662. /**
  46663. * Add the required uniforms to the current list.
  46664. * @param uniforms defines the current uniform list.
  46665. */
  46666. static AddUniforms(uniforms: string[]): void;
  46667. /**
  46668. * Add the required samplers to the current list.
  46669. * @param samplers defines the current sampler list.
  46670. */
  46671. static AddSamplers(samplers: string[]): void;
  46672. /**
  46673. * Add the required uniforms to the current buffer.
  46674. * @param uniformBuffer defines the current uniform buffer.
  46675. */
  46676. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46677. /**
  46678. * Makes a duplicate of the current configuration into another one.
  46679. * @param configuration define the config where to copy the info
  46680. */
  46681. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46682. /**
  46683. * Serializes this Sub Surface configuration.
  46684. * @returns - An object with the serialized config.
  46685. */
  46686. serialize(): any;
  46687. /**
  46688. * Parses a anisotropy Configuration from a serialized object.
  46689. * @param source - Serialized object.
  46690. * @param scene Defines the scene we are parsing for
  46691. * @param rootUrl Defines the rootUrl to load from
  46692. */
  46693. parse(source: any, scene: Scene, rootUrl: string): void;
  46694. }
  46695. }
  46696. declare module BABYLON {
  46697. /** @hidden */
  46698. export var pbrFragmentDeclaration: {
  46699. name: string;
  46700. shader: string;
  46701. };
  46702. }
  46703. declare module BABYLON {
  46704. /** @hidden */
  46705. export var pbrUboDeclaration: {
  46706. name: string;
  46707. shader: string;
  46708. };
  46709. }
  46710. declare module BABYLON {
  46711. /** @hidden */
  46712. export var pbrFragmentExtraDeclaration: {
  46713. name: string;
  46714. shader: string;
  46715. };
  46716. }
  46717. declare module BABYLON {
  46718. /** @hidden */
  46719. export var pbrFragmentSamplersDeclaration: {
  46720. name: string;
  46721. shader: string;
  46722. };
  46723. }
  46724. declare module BABYLON {
  46725. /** @hidden */
  46726. export var pbrHelperFunctions: {
  46727. name: string;
  46728. shader: string;
  46729. };
  46730. }
  46731. declare module BABYLON {
  46732. /** @hidden */
  46733. export var harmonicsFunctions: {
  46734. name: string;
  46735. shader: string;
  46736. };
  46737. }
  46738. declare module BABYLON {
  46739. /** @hidden */
  46740. export var pbrDirectLightingSetupFunctions: {
  46741. name: string;
  46742. shader: string;
  46743. };
  46744. }
  46745. declare module BABYLON {
  46746. /** @hidden */
  46747. export var pbrDirectLightingFalloffFunctions: {
  46748. name: string;
  46749. shader: string;
  46750. };
  46751. }
  46752. declare module BABYLON {
  46753. /** @hidden */
  46754. export var pbrBRDFFunctions: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module BABYLON {
  46760. /** @hidden */
  46761. export var pbrDirectLightingFunctions: {
  46762. name: string;
  46763. shader: string;
  46764. };
  46765. }
  46766. declare module BABYLON {
  46767. /** @hidden */
  46768. export var pbrIBLFunctions: {
  46769. name: string;
  46770. shader: string;
  46771. };
  46772. }
  46773. declare module BABYLON {
  46774. /** @hidden */
  46775. export var pbrDebug: {
  46776. name: string;
  46777. shader: string;
  46778. };
  46779. }
  46780. declare module BABYLON {
  46781. /** @hidden */
  46782. export var pbrPixelShader: {
  46783. name: string;
  46784. shader: string;
  46785. };
  46786. }
  46787. declare module BABYLON {
  46788. /** @hidden */
  46789. export var pbrVertexDeclaration: {
  46790. name: string;
  46791. shader: string;
  46792. };
  46793. }
  46794. declare module BABYLON {
  46795. /** @hidden */
  46796. export var pbrVertexShader: {
  46797. name: string;
  46798. shader: string;
  46799. };
  46800. }
  46801. declare module BABYLON {
  46802. /**
  46803. * Manages the defines for the PBR Material.
  46804. * @hidden
  46805. */
  46806. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46807. PBR: boolean;
  46808. MAINUV1: boolean;
  46809. MAINUV2: boolean;
  46810. UV1: boolean;
  46811. UV2: boolean;
  46812. ALBEDO: boolean;
  46813. ALBEDODIRECTUV: number;
  46814. VERTEXCOLOR: boolean;
  46815. AMBIENT: boolean;
  46816. AMBIENTDIRECTUV: number;
  46817. AMBIENTINGRAYSCALE: boolean;
  46818. OPACITY: boolean;
  46819. VERTEXALPHA: boolean;
  46820. OPACITYDIRECTUV: number;
  46821. OPACITYRGB: boolean;
  46822. ALPHATEST: boolean;
  46823. DEPTHPREPASS: boolean;
  46824. ALPHABLEND: boolean;
  46825. ALPHAFROMALBEDO: boolean;
  46826. ALPHATESTVALUE: string;
  46827. SPECULAROVERALPHA: boolean;
  46828. RADIANCEOVERALPHA: boolean;
  46829. ALPHAFRESNEL: boolean;
  46830. LINEARALPHAFRESNEL: boolean;
  46831. PREMULTIPLYALPHA: boolean;
  46832. EMISSIVE: boolean;
  46833. EMISSIVEDIRECTUV: number;
  46834. REFLECTIVITY: boolean;
  46835. REFLECTIVITYDIRECTUV: number;
  46836. SPECULARTERM: boolean;
  46837. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46838. MICROSURFACEAUTOMATIC: boolean;
  46839. LODBASEDMICROSFURACE: boolean;
  46840. MICROSURFACEMAP: boolean;
  46841. MICROSURFACEMAPDIRECTUV: number;
  46842. METALLICWORKFLOW: boolean;
  46843. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46844. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46845. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46846. AOSTOREINMETALMAPRED: boolean;
  46847. ENVIRONMENTBRDF: boolean;
  46848. ENVIRONMENTBRDF_RGBD: boolean;
  46849. NORMAL: boolean;
  46850. TANGENT: boolean;
  46851. BUMP: boolean;
  46852. BUMPDIRECTUV: number;
  46853. OBJECTSPACE_NORMALMAP: boolean;
  46854. PARALLAX: boolean;
  46855. PARALLAXOCCLUSION: boolean;
  46856. NORMALXYSCALE: boolean;
  46857. LIGHTMAP: boolean;
  46858. LIGHTMAPDIRECTUV: number;
  46859. USELIGHTMAPASSHADOWMAP: boolean;
  46860. GAMMALIGHTMAP: boolean;
  46861. REFLECTION: boolean;
  46862. REFLECTIONMAP_3D: boolean;
  46863. REFLECTIONMAP_SPHERICAL: boolean;
  46864. REFLECTIONMAP_PLANAR: boolean;
  46865. REFLECTIONMAP_CUBIC: boolean;
  46866. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46867. REFLECTIONMAP_PROJECTION: boolean;
  46868. REFLECTIONMAP_SKYBOX: boolean;
  46869. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46870. REFLECTIONMAP_EXPLICIT: boolean;
  46871. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46872. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46873. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46874. INVERTCUBICMAP: boolean;
  46875. USESPHERICALFROMREFLECTIONMAP: boolean;
  46876. USEIRRADIANCEMAP: boolean;
  46877. SPHERICAL_HARMONICS: boolean;
  46878. USESPHERICALINVERTEX: boolean;
  46879. REFLECTIONMAP_OPPOSITEZ: boolean;
  46880. LODINREFLECTIONALPHA: boolean;
  46881. GAMMAREFLECTION: boolean;
  46882. RGBDREFLECTION: boolean;
  46883. LINEARSPECULARREFLECTION: boolean;
  46884. RADIANCEOCCLUSION: boolean;
  46885. HORIZONOCCLUSION: boolean;
  46886. INSTANCES: boolean;
  46887. NUM_BONE_INFLUENCERS: number;
  46888. BonesPerMesh: number;
  46889. BONETEXTURE: boolean;
  46890. NONUNIFORMSCALING: boolean;
  46891. MORPHTARGETS: boolean;
  46892. MORPHTARGETS_NORMAL: boolean;
  46893. MORPHTARGETS_TANGENT: boolean;
  46894. MORPHTARGETS_UV: boolean;
  46895. NUM_MORPH_INFLUENCERS: number;
  46896. IMAGEPROCESSING: boolean;
  46897. VIGNETTE: boolean;
  46898. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46899. VIGNETTEBLENDMODEOPAQUE: boolean;
  46900. TONEMAPPING: boolean;
  46901. TONEMAPPING_ACES: boolean;
  46902. CONTRAST: boolean;
  46903. COLORCURVES: boolean;
  46904. COLORGRADING: boolean;
  46905. COLORGRADING3D: boolean;
  46906. SAMPLER3DGREENDEPTH: boolean;
  46907. SAMPLER3DBGRMAP: boolean;
  46908. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46909. EXPOSURE: boolean;
  46910. MULTIVIEW: boolean;
  46911. USEPHYSICALLIGHTFALLOFF: boolean;
  46912. USEGLTFLIGHTFALLOFF: boolean;
  46913. TWOSIDEDLIGHTING: boolean;
  46914. SHADOWFLOAT: boolean;
  46915. CLIPPLANE: boolean;
  46916. CLIPPLANE2: boolean;
  46917. CLIPPLANE3: boolean;
  46918. CLIPPLANE4: boolean;
  46919. POINTSIZE: boolean;
  46920. FOG: boolean;
  46921. LOGARITHMICDEPTH: boolean;
  46922. FORCENORMALFORWARD: boolean;
  46923. SPECULARAA: boolean;
  46924. CLEARCOAT: boolean;
  46925. CLEARCOAT_DEFAULTIOR: boolean;
  46926. CLEARCOAT_TEXTURE: boolean;
  46927. CLEARCOAT_TEXTUREDIRECTUV: number;
  46928. CLEARCOAT_BUMP: boolean;
  46929. CLEARCOAT_BUMPDIRECTUV: number;
  46930. CLEARCOAT_TINT: boolean;
  46931. CLEARCOAT_TINT_TEXTURE: boolean;
  46932. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46933. ANISOTROPIC: boolean;
  46934. ANISOTROPIC_TEXTURE: boolean;
  46935. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46936. BRDF_V_HEIGHT_CORRELATED: boolean;
  46937. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46938. SHEEN: boolean;
  46939. SHEEN_TEXTURE: boolean;
  46940. SHEEN_TEXTUREDIRECTUV: number;
  46941. SHEEN_LINKWITHALBEDO: boolean;
  46942. SUBSURFACE: boolean;
  46943. SS_REFRACTION: boolean;
  46944. SS_TRANSLUCENCY: boolean;
  46945. SS_SCATERRING: boolean;
  46946. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46947. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46948. SS_REFRACTIONMAP_3D: boolean;
  46949. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46950. SS_LODINREFRACTIONALPHA: boolean;
  46951. SS_GAMMAREFRACTION: boolean;
  46952. SS_RGBDREFRACTION: boolean;
  46953. SS_LINEARSPECULARREFRACTION: boolean;
  46954. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46955. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46956. UNLIT: boolean;
  46957. DEBUGMODE: number;
  46958. /**
  46959. * Initializes the PBR Material defines.
  46960. */
  46961. constructor();
  46962. /**
  46963. * Resets the PBR Material defines.
  46964. */
  46965. reset(): void;
  46966. }
  46967. /**
  46968. * The Physically based material base class of BJS.
  46969. *
  46970. * This offers the main features of a standard PBR material.
  46971. * For more information, please refer to the documentation :
  46972. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46973. */
  46974. export abstract class PBRBaseMaterial extends PushMaterial {
  46975. /**
  46976. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46977. */
  46978. static readonly PBRMATERIAL_OPAQUE: number;
  46979. /**
  46980. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46981. */
  46982. static readonly PBRMATERIAL_ALPHATEST: number;
  46983. /**
  46984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46985. */
  46986. static readonly PBRMATERIAL_ALPHABLEND: number;
  46987. /**
  46988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46989. * They are also discarded below the alpha cutoff threshold to improve performances.
  46990. */
  46991. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46992. /**
  46993. * Defines the default value of how much AO map is occluding the analytical lights
  46994. * (point spot...).
  46995. */
  46996. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46997. /**
  46998. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46999. */
  47000. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47001. /**
  47002. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47003. * to enhance interoperability with other engines.
  47004. */
  47005. static readonly LIGHTFALLOFF_GLTF: number;
  47006. /**
  47007. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47008. * to enhance interoperability with other materials.
  47009. */
  47010. static readonly LIGHTFALLOFF_STANDARD: number;
  47011. /**
  47012. * Intensity of the direct lights e.g. the four lights available in your scene.
  47013. * This impacts both the direct diffuse and specular highlights.
  47014. */
  47015. protected _directIntensity: number;
  47016. /**
  47017. * Intensity of the emissive part of the material.
  47018. * This helps controlling the emissive effect without modifying the emissive color.
  47019. */
  47020. protected _emissiveIntensity: number;
  47021. /**
  47022. * Intensity of the environment e.g. how much the environment will light the object
  47023. * either through harmonics for rough material or through the refelction for shiny ones.
  47024. */
  47025. protected _environmentIntensity: number;
  47026. /**
  47027. * This is a special control allowing the reduction of the specular highlights coming from the
  47028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47029. */
  47030. protected _specularIntensity: number;
  47031. /**
  47032. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47033. */
  47034. private _lightingInfos;
  47035. /**
  47036. * Debug Control allowing disabling the bump map on this material.
  47037. */
  47038. protected _disableBumpMap: boolean;
  47039. /**
  47040. * AKA Diffuse Texture in standard nomenclature.
  47041. */
  47042. protected _albedoTexture: Nullable<BaseTexture>;
  47043. /**
  47044. * AKA Occlusion Texture in other nomenclature.
  47045. */
  47046. protected _ambientTexture: Nullable<BaseTexture>;
  47047. /**
  47048. * AKA Occlusion Texture Intensity in other nomenclature.
  47049. */
  47050. protected _ambientTextureStrength: number;
  47051. /**
  47052. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47053. * 1 means it completely occludes it
  47054. * 0 mean it has no impact
  47055. */
  47056. protected _ambientTextureImpactOnAnalyticalLights: number;
  47057. /**
  47058. * Stores the alpha values in a texture.
  47059. */
  47060. protected _opacityTexture: Nullable<BaseTexture>;
  47061. /**
  47062. * Stores the reflection values in a texture.
  47063. */
  47064. protected _reflectionTexture: Nullable<BaseTexture>;
  47065. /**
  47066. * Stores the emissive values in a texture.
  47067. */
  47068. protected _emissiveTexture: Nullable<BaseTexture>;
  47069. /**
  47070. * AKA Specular texture in other nomenclature.
  47071. */
  47072. protected _reflectivityTexture: Nullable<BaseTexture>;
  47073. /**
  47074. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47075. */
  47076. protected _metallicTexture: Nullable<BaseTexture>;
  47077. /**
  47078. * Specifies the metallic scalar of the metallic/roughness workflow.
  47079. * Can also be used to scale the metalness values of the metallic texture.
  47080. */
  47081. protected _metallic: Nullable<number>;
  47082. /**
  47083. * Specifies the roughness scalar of the metallic/roughness workflow.
  47084. * Can also be used to scale the roughness values of the metallic texture.
  47085. */
  47086. protected _roughness: Nullable<number>;
  47087. /**
  47088. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47089. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47090. */
  47091. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47092. /**
  47093. * Stores surface normal data used to displace a mesh in a texture.
  47094. */
  47095. protected _bumpTexture: Nullable<BaseTexture>;
  47096. /**
  47097. * Stores the pre-calculated light information of a mesh in a texture.
  47098. */
  47099. protected _lightmapTexture: Nullable<BaseTexture>;
  47100. /**
  47101. * The color of a material in ambient lighting.
  47102. */
  47103. protected _ambientColor: Color3;
  47104. /**
  47105. * AKA Diffuse Color in other nomenclature.
  47106. */
  47107. protected _albedoColor: Color3;
  47108. /**
  47109. * AKA Specular Color in other nomenclature.
  47110. */
  47111. protected _reflectivityColor: Color3;
  47112. /**
  47113. * The color applied when light is reflected from a material.
  47114. */
  47115. protected _reflectionColor: Color3;
  47116. /**
  47117. * The color applied when light is emitted from a material.
  47118. */
  47119. protected _emissiveColor: Color3;
  47120. /**
  47121. * AKA Glossiness in other nomenclature.
  47122. */
  47123. protected _microSurface: number;
  47124. /**
  47125. * Specifies that the material will use the light map as a show map.
  47126. */
  47127. protected _useLightmapAsShadowmap: boolean;
  47128. /**
  47129. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47130. * makes the reflect vector face the model (under horizon).
  47131. */
  47132. protected _useHorizonOcclusion: boolean;
  47133. /**
  47134. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47135. * too much the area relying on ambient texture to define their ambient occlusion.
  47136. */
  47137. protected _useRadianceOcclusion: boolean;
  47138. /**
  47139. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47140. */
  47141. protected _useAlphaFromAlbedoTexture: boolean;
  47142. /**
  47143. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47145. */
  47146. protected _useSpecularOverAlpha: boolean;
  47147. /**
  47148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47149. */
  47150. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47151. /**
  47152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47153. */
  47154. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47155. /**
  47156. * Specifies if the metallic texture contains the roughness information in its green channel.
  47157. */
  47158. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47159. /**
  47160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47161. */
  47162. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47163. /**
  47164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47165. */
  47166. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47167. /**
  47168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47169. */
  47170. protected _useAmbientInGrayScale: boolean;
  47171. /**
  47172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47173. * The material will try to infer what glossiness each pixel should be.
  47174. */
  47175. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47176. /**
  47177. * Defines the falloff type used in this material.
  47178. * It by default is Physical.
  47179. */
  47180. protected _lightFalloff: number;
  47181. /**
  47182. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47183. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47184. */
  47185. protected _useRadianceOverAlpha: boolean;
  47186. /**
  47187. * Allows using an object space normal map (instead of tangent space).
  47188. */
  47189. protected _useObjectSpaceNormalMap: boolean;
  47190. /**
  47191. * Allows using the bump map in parallax mode.
  47192. */
  47193. protected _useParallax: boolean;
  47194. /**
  47195. * Allows using the bump map in parallax occlusion mode.
  47196. */
  47197. protected _useParallaxOcclusion: boolean;
  47198. /**
  47199. * Controls the scale bias of the parallax mode.
  47200. */
  47201. protected _parallaxScaleBias: number;
  47202. /**
  47203. * If sets to true, disables all the lights affecting the material.
  47204. */
  47205. protected _disableLighting: boolean;
  47206. /**
  47207. * Number of Simultaneous lights allowed on the material.
  47208. */
  47209. protected _maxSimultaneousLights: number;
  47210. /**
  47211. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47212. */
  47213. protected _invertNormalMapX: boolean;
  47214. /**
  47215. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47216. */
  47217. protected _invertNormalMapY: boolean;
  47218. /**
  47219. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47220. */
  47221. protected _twoSidedLighting: boolean;
  47222. /**
  47223. * Defines the alpha limits in alpha test mode.
  47224. */
  47225. protected _alphaCutOff: number;
  47226. /**
  47227. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47228. */
  47229. protected _forceAlphaTest: boolean;
  47230. /**
  47231. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47232. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47233. */
  47234. protected _useAlphaFresnel: boolean;
  47235. /**
  47236. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47237. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47238. */
  47239. protected _useLinearAlphaFresnel: boolean;
  47240. /**
  47241. * The transparency mode of the material.
  47242. */
  47243. protected _transparencyMode: Nullable<number>;
  47244. /**
  47245. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47246. * from cos thetav and roughness:
  47247. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47248. */
  47249. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47250. /**
  47251. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47252. */
  47253. protected _forceIrradianceInFragment: boolean;
  47254. /**
  47255. * Force normal to face away from face.
  47256. */
  47257. protected _forceNormalForward: boolean;
  47258. /**
  47259. * Enables specular anti aliasing in the PBR shader.
  47260. * It will both interacts on the Geometry for analytical and IBL lighting.
  47261. * It also prefilter the roughness map based on the bump values.
  47262. */
  47263. protected _enableSpecularAntiAliasing: boolean;
  47264. /**
  47265. * Default configuration related to image processing available in the PBR Material.
  47266. */
  47267. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47268. /**
  47269. * Keep track of the image processing observer to allow dispose and replace.
  47270. */
  47271. private _imageProcessingObserver;
  47272. /**
  47273. * Attaches a new image processing configuration to the PBR Material.
  47274. * @param configuration
  47275. */
  47276. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47277. /**
  47278. * Stores the available render targets.
  47279. */
  47280. private _renderTargets;
  47281. /**
  47282. * Sets the global ambient color for the material used in lighting calculations.
  47283. */
  47284. private _globalAmbientColor;
  47285. /**
  47286. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47287. */
  47288. private _useLogarithmicDepth;
  47289. /**
  47290. * If set to true, no lighting calculations will be applied.
  47291. */
  47292. private _unlit;
  47293. private _debugMode;
  47294. /**
  47295. * @hidden
  47296. * This is reserved for the inspector.
  47297. * Defines the material debug mode.
  47298. * It helps seeing only some components of the material while troubleshooting.
  47299. */
  47300. debugMode: number;
  47301. /**
  47302. * @hidden
  47303. * This is reserved for the inspector.
  47304. * Specify from where on screen the debug mode should start.
  47305. * The value goes from -1 (full screen) to 1 (not visible)
  47306. * It helps with side by side comparison against the final render
  47307. * This defaults to -1
  47308. */
  47309. private debugLimit;
  47310. /**
  47311. * @hidden
  47312. * This is reserved for the inspector.
  47313. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47314. * You can use the factor to better multiply the final value.
  47315. */
  47316. private debugFactor;
  47317. /**
  47318. * Defines the clear coat layer parameters for the material.
  47319. */
  47320. readonly clearCoat: PBRClearCoatConfiguration;
  47321. /**
  47322. * Defines the anisotropic parameters for the material.
  47323. */
  47324. readonly anisotropy: PBRAnisotropicConfiguration;
  47325. /**
  47326. * Defines the BRDF parameters for the material.
  47327. */
  47328. readonly brdf: PBRBRDFConfiguration;
  47329. /**
  47330. * Defines the Sheen parameters for the material.
  47331. */
  47332. readonly sheen: PBRSheenConfiguration;
  47333. /**
  47334. * Defines the SubSurface parameters for the material.
  47335. */
  47336. readonly subSurface: PBRSubSurfaceConfiguration;
  47337. /**
  47338. * Custom callback helping to override the default shader used in the material.
  47339. */
  47340. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47341. protected _rebuildInParallel: boolean;
  47342. /**
  47343. * Instantiates a new PBRMaterial instance.
  47344. *
  47345. * @param name The material name
  47346. * @param scene The scene the material will be use in.
  47347. */
  47348. constructor(name: string, scene: Scene);
  47349. /**
  47350. * Gets a boolean indicating that current material needs to register RTT
  47351. */
  47352. readonly hasRenderTargetTextures: boolean;
  47353. /**
  47354. * Gets the name of the material class.
  47355. */
  47356. getClassName(): string;
  47357. /**
  47358. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47359. */
  47360. /**
  47361. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47362. */
  47363. useLogarithmicDepth: boolean;
  47364. /**
  47365. * Gets the current transparency mode.
  47366. */
  47367. /**
  47368. * Sets the transparency mode of the material.
  47369. *
  47370. * | Value | Type | Description |
  47371. * | ----- | ----------------------------------- | ----------- |
  47372. * | 0 | OPAQUE | |
  47373. * | 1 | ALPHATEST | |
  47374. * | 2 | ALPHABLEND | |
  47375. * | 3 | ALPHATESTANDBLEND | |
  47376. *
  47377. */
  47378. transparencyMode: Nullable<number>;
  47379. /**
  47380. * Returns true if alpha blending should be disabled.
  47381. */
  47382. private readonly _disableAlphaBlending;
  47383. /**
  47384. * Specifies whether or not this material should be rendered in alpha blend mode.
  47385. */
  47386. needAlphaBlending(): boolean;
  47387. /**
  47388. * Specifies if the mesh will require alpha blending.
  47389. * @param mesh - BJS mesh.
  47390. */
  47391. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47392. /**
  47393. * Specifies whether or not this material should be rendered in alpha test mode.
  47394. */
  47395. needAlphaTesting(): boolean;
  47396. /**
  47397. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47398. */
  47399. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47400. /**
  47401. * Gets the texture used for the alpha test.
  47402. */
  47403. getAlphaTestTexture(): Nullable<BaseTexture>;
  47404. /**
  47405. * Specifies that the submesh is ready to be used.
  47406. * @param mesh - BJS mesh.
  47407. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47408. * @param useInstances - Specifies that instances should be used.
  47409. * @returns - boolean indicating that the submesh is ready or not.
  47410. */
  47411. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47412. /**
  47413. * Specifies if the material uses metallic roughness workflow.
  47414. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47415. */
  47416. isMetallicWorkflow(): boolean;
  47417. private _prepareEffect;
  47418. private _prepareDefines;
  47419. /**
  47420. * Force shader compilation
  47421. */
  47422. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47423. clipPlane: boolean;
  47424. }>): void;
  47425. /**
  47426. * Initializes the uniform buffer layout for the shader.
  47427. */
  47428. buildUniformLayout(): void;
  47429. /**
  47430. * Unbinds the material from the mesh
  47431. */
  47432. unbind(): void;
  47433. /**
  47434. * Binds the submesh data.
  47435. * @param world - The world matrix.
  47436. * @param mesh - The BJS mesh.
  47437. * @param subMesh - A submesh of the BJS mesh.
  47438. */
  47439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47440. /**
  47441. * Returns the animatable textures.
  47442. * @returns - Array of animatable textures.
  47443. */
  47444. getAnimatables(): IAnimatable[];
  47445. /**
  47446. * Returns the texture used for reflections.
  47447. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47448. */
  47449. private _getReflectionTexture;
  47450. /**
  47451. * Returns an array of the actively used textures.
  47452. * @returns - Array of BaseTextures
  47453. */
  47454. getActiveTextures(): BaseTexture[];
  47455. /**
  47456. * Checks to see if a texture is used in the material.
  47457. * @param texture - Base texture to use.
  47458. * @returns - Boolean specifying if a texture is used in the material.
  47459. */
  47460. hasTexture(texture: BaseTexture): boolean;
  47461. /**
  47462. * Disposes the resources of the material.
  47463. * @param forceDisposeEffect - Forces the disposal of effects.
  47464. * @param forceDisposeTextures - Forces the disposal of all textures.
  47465. */
  47466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47467. }
  47468. }
  47469. declare module BABYLON {
  47470. /**
  47471. * The Physically based material of BJS.
  47472. *
  47473. * This offers the main features of a standard PBR material.
  47474. * For more information, please refer to the documentation :
  47475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47476. */
  47477. export class PBRMaterial extends PBRBaseMaterial {
  47478. /**
  47479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47480. */
  47481. static readonly PBRMATERIAL_OPAQUE: number;
  47482. /**
  47483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47484. */
  47485. static readonly PBRMATERIAL_ALPHATEST: number;
  47486. /**
  47487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47488. */
  47489. static readonly PBRMATERIAL_ALPHABLEND: number;
  47490. /**
  47491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47492. * They are also discarded below the alpha cutoff threshold to improve performances.
  47493. */
  47494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47495. /**
  47496. * Defines the default value of how much AO map is occluding the analytical lights
  47497. * (point spot...).
  47498. */
  47499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47500. /**
  47501. * Intensity of the direct lights e.g. the four lights available in your scene.
  47502. * This impacts both the direct diffuse and specular highlights.
  47503. */
  47504. directIntensity: number;
  47505. /**
  47506. * Intensity of the emissive part of the material.
  47507. * This helps controlling the emissive effect without modifying the emissive color.
  47508. */
  47509. emissiveIntensity: number;
  47510. /**
  47511. * Intensity of the environment e.g. how much the environment will light the object
  47512. * either through harmonics for rough material or through the refelction for shiny ones.
  47513. */
  47514. environmentIntensity: number;
  47515. /**
  47516. * This is a special control allowing the reduction of the specular highlights coming from the
  47517. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47518. */
  47519. specularIntensity: number;
  47520. /**
  47521. * Debug Control allowing disabling the bump map on this material.
  47522. */
  47523. disableBumpMap: boolean;
  47524. /**
  47525. * AKA Diffuse Texture in standard nomenclature.
  47526. */
  47527. albedoTexture: BaseTexture;
  47528. /**
  47529. * AKA Occlusion Texture in other nomenclature.
  47530. */
  47531. ambientTexture: BaseTexture;
  47532. /**
  47533. * AKA Occlusion Texture Intensity in other nomenclature.
  47534. */
  47535. ambientTextureStrength: number;
  47536. /**
  47537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47538. * 1 means it completely occludes it
  47539. * 0 mean it has no impact
  47540. */
  47541. ambientTextureImpactOnAnalyticalLights: number;
  47542. /**
  47543. * Stores the alpha values in a texture.
  47544. */
  47545. opacityTexture: BaseTexture;
  47546. /**
  47547. * Stores the reflection values in a texture.
  47548. */
  47549. reflectionTexture: Nullable<BaseTexture>;
  47550. /**
  47551. * Stores the emissive values in a texture.
  47552. */
  47553. emissiveTexture: BaseTexture;
  47554. /**
  47555. * AKA Specular texture in other nomenclature.
  47556. */
  47557. reflectivityTexture: BaseTexture;
  47558. /**
  47559. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47560. */
  47561. metallicTexture: BaseTexture;
  47562. /**
  47563. * Specifies the metallic scalar of the metallic/roughness workflow.
  47564. * Can also be used to scale the metalness values of the metallic texture.
  47565. */
  47566. metallic: Nullable<number>;
  47567. /**
  47568. * Specifies the roughness scalar of the metallic/roughness workflow.
  47569. * Can also be used to scale the roughness values of the metallic texture.
  47570. */
  47571. roughness: Nullable<number>;
  47572. /**
  47573. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47574. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47575. */
  47576. microSurfaceTexture: BaseTexture;
  47577. /**
  47578. * Stores surface normal data used to displace a mesh in a texture.
  47579. */
  47580. bumpTexture: BaseTexture;
  47581. /**
  47582. * Stores the pre-calculated light information of a mesh in a texture.
  47583. */
  47584. lightmapTexture: BaseTexture;
  47585. /**
  47586. * Stores the refracted light information in a texture.
  47587. */
  47588. refractionTexture: Nullable<BaseTexture>;
  47589. /**
  47590. * The color of a material in ambient lighting.
  47591. */
  47592. ambientColor: Color3;
  47593. /**
  47594. * AKA Diffuse Color in other nomenclature.
  47595. */
  47596. albedoColor: Color3;
  47597. /**
  47598. * AKA Specular Color in other nomenclature.
  47599. */
  47600. reflectivityColor: Color3;
  47601. /**
  47602. * The color reflected from the material.
  47603. */
  47604. reflectionColor: Color3;
  47605. /**
  47606. * The color emitted from the material.
  47607. */
  47608. emissiveColor: Color3;
  47609. /**
  47610. * AKA Glossiness in other nomenclature.
  47611. */
  47612. microSurface: number;
  47613. /**
  47614. * source material index of refraction (IOR)' / 'destination material IOR.
  47615. */
  47616. indexOfRefraction: number;
  47617. /**
  47618. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47619. */
  47620. invertRefractionY: boolean;
  47621. /**
  47622. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47623. * Materials half opaque for instance using refraction could benefit from this control.
  47624. */
  47625. linkRefractionWithTransparency: boolean;
  47626. /**
  47627. * If true, the light map contains occlusion information instead of lighting info.
  47628. */
  47629. useLightmapAsShadowmap: boolean;
  47630. /**
  47631. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47632. */
  47633. useAlphaFromAlbedoTexture: boolean;
  47634. /**
  47635. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47636. */
  47637. forceAlphaTest: boolean;
  47638. /**
  47639. * Defines the alpha limits in alpha test mode.
  47640. */
  47641. alphaCutOff: number;
  47642. /**
  47643. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47644. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47645. */
  47646. useSpecularOverAlpha: boolean;
  47647. /**
  47648. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47649. */
  47650. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47651. /**
  47652. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47653. */
  47654. useRoughnessFromMetallicTextureAlpha: boolean;
  47655. /**
  47656. * Specifies if the metallic texture contains the roughness information in its green channel.
  47657. */
  47658. useRoughnessFromMetallicTextureGreen: boolean;
  47659. /**
  47660. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47661. */
  47662. useMetallnessFromMetallicTextureBlue: boolean;
  47663. /**
  47664. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47665. */
  47666. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47667. /**
  47668. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47669. */
  47670. useAmbientInGrayScale: boolean;
  47671. /**
  47672. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47673. * The material will try to infer what glossiness each pixel should be.
  47674. */
  47675. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47676. /**
  47677. * BJS is using an harcoded light falloff based on a manually sets up range.
  47678. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47679. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47680. */
  47681. /**
  47682. * BJS is using an harcoded light falloff based on a manually sets up range.
  47683. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47684. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47685. */
  47686. usePhysicalLightFalloff: boolean;
  47687. /**
  47688. * In order to support the falloff compatibility with gltf, a special mode has been added
  47689. * to reproduce the gltf light falloff.
  47690. */
  47691. /**
  47692. * In order to support the falloff compatibility with gltf, a special mode has been added
  47693. * to reproduce the gltf light falloff.
  47694. */
  47695. useGLTFLightFalloff: boolean;
  47696. /**
  47697. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47698. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47699. */
  47700. useRadianceOverAlpha: boolean;
  47701. /**
  47702. * Allows using an object space normal map (instead of tangent space).
  47703. */
  47704. useObjectSpaceNormalMap: boolean;
  47705. /**
  47706. * Allows using the bump map in parallax mode.
  47707. */
  47708. useParallax: boolean;
  47709. /**
  47710. * Allows using the bump map in parallax occlusion mode.
  47711. */
  47712. useParallaxOcclusion: boolean;
  47713. /**
  47714. * Controls the scale bias of the parallax mode.
  47715. */
  47716. parallaxScaleBias: number;
  47717. /**
  47718. * If sets to true, disables all the lights affecting the material.
  47719. */
  47720. disableLighting: boolean;
  47721. /**
  47722. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47723. */
  47724. forceIrradianceInFragment: boolean;
  47725. /**
  47726. * Number of Simultaneous lights allowed on the material.
  47727. */
  47728. maxSimultaneousLights: number;
  47729. /**
  47730. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47731. */
  47732. invertNormalMapX: boolean;
  47733. /**
  47734. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47735. */
  47736. invertNormalMapY: boolean;
  47737. /**
  47738. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47739. */
  47740. twoSidedLighting: boolean;
  47741. /**
  47742. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47743. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47744. */
  47745. useAlphaFresnel: boolean;
  47746. /**
  47747. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47748. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47749. */
  47750. useLinearAlphaFresnel: boolean;
  47751. /**
  47752. * Let user defines the brdf lookup texture used for IBL.
  47753. * A default 8bit version is embedded but you could point at :
  47754. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47755. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47756. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47757. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47758. */
  47759. environmentBRDFTexture: Nullable<BaseTexture>;
  47760. /**
  47761. * Force normal to face away from face.
  47762. */
  47763. forceNormalForward: boolean;
  47764. /**
  47765. * Enables specular anti aliasing in the PBR shader.
  47766. * It will both interacts on the Geometry for analytical and IBL lighting.
  47767. * It also prefilter the roughness map based on the bump values.
  47768. */
  47769. enableSpecularAntiAliasing: boolean;
  47770. /**
  47771. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47772. * makes the reflect vector face the model (under horizon).
  47773. */
  47774. useHorizonOcclusion: boolean;
  47775. /**
  47776. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47777. * too much the area relying on ambient texture to define their ambient occlusion.
  47778. */
  47779. useRadianceOcclusion: boolean;
  47780. /**
  47781. * If set to true, no lighting calculations will be applied.
  47782. */
  47783. unlit: boolean;
  47784. /**
  47785. * Gets the image processing configuration used either in this material.
  47786. */
  47787. /**
  47788. * Sets the Default image processing configuration used either in the this material.
  47789. *
  47790. * If sets to null, the scene one is in use.
  47791. */
  47792. imageProcessingConfiguration: ImageProcessingConfiguration;
  47793. /**
  47794. * Gets wether the color curves effect is enabled.
  47795. */
  47796. /**
  47797. * Sets wether the color curves effect is enabled.
  47798. */
  47799. cameraColorCurvesEnabled: boolean;
  47800. /**
  47801. * Gets wether the color grading effect is enabled.
  47802. */
  47803. /**
  47804. * Gets wether the color grading effect is enabled.
  47805. */
  47806. cameraColorGradingEnabled: boolean;
  47807. /**
  47808. * Gets wether tonemapping is enabled or not.
  47809. */
  47810. /**
  47811. * Sets wether tonemapping is enabled or not
  47812. */
  47813. cameraToneMappingEnabled: boolean;
  47814. /**
  47815. * The camera exposure used on this material.
  47816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47817. * This corresponds to a photographic exposure.
  47818. */
  47819. /**
  47820. * The camera exposure used on this material.
  47821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47822. * This corresponds to a photographic exposure.
  47823. */
  47824. cameraExposure: number;
  47825. /**
  47826. * Gets The camera contrast used on this material.
  47827. */
  47828. /**
  47829. * Sets The camera contrast used on this material.
  47830. */
  47831. cameraContrast: number;
  47832. /**
  47833. * Gets the Color Grading 2D Lookup Texture.
  47834. */
  47835. /**
  47836. * Sets the Color Grading 2D Lookup Texture.
  47837. */
  47838. cameraColorGradingTexture: Nullable<BaseTexture>;
  47839. /**
  47840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47842. * 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;
  47843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47844. */
  47845. /**
  47846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47848. * 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;
  47849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47850. */
  47851. cameraColorCurves: Nullable<ColorCurves>;
  47852. /**
  47853. * Instantiates a new PBRMaterial instance.
  47854. *
  47855. * @param name The material name
  47856. * @param scene The scene the material will be use in.
  47857. */
  47858. constructor(name: string, scene: Scene);
  47859. /**
  47860. * Returns the name of this material class.
  47861. */
  47862. getClassName(): string;
  47863. /**
  47864. * Makes a duplicate of the current material.
  47865. * @param name - name to use for the new material.
  47866. */
  47867. clone(name: string): PBRMaterial;
  47868. /**
  47869. * Serializes this PBR Material.
  47870. * @returns - An object with the serialized material.
  47871. */
  47872. serialize(): any;
  47873. /**
  47874. * Parses a PBR Material from a serialized object.
  47875. * @param source - Serialized object.
  47876. * @param scene - BJS scene instance.
  47877. * @param rootUrl - url for the scene object
  47878. * @returns - PBRMaterial
  47879. */
  47880. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47881. }
  47882. }
  47883. declare module BABYLON {
  47884. /**
  47885. * Direct draw surface info
  47886. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47887. */
  47888. export interface DDSInfo {
  47889. /**
  47890. * Width of the texture
  47891. */
  47892. width: number;
  47893. /**
  47894. * Width of the texture
  47895. */
  47896. height: number;
  47897. /**
  47898. * Number of Mipmaps for the texture
  47899. * @see https://en.wikipedia.org/wiki/Mipmap
  47900. */
  47901. mipmapCount: number;
  47902. /**
  47903. * If the textures format is a known fourCC format
  47904. * @see https://www.fourcc.org/
  47905. */
  47906. isFourCC: boolean;
  47907. /**
  47908. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47909. */
  47910. isRGB: boolean;
  47911. /**
  47912. * If the texture is a lumincance format
  47913. */
  47914. isLuminance: boolean;
  47915. /**
  47916. * If this is a cube texture
  47917. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47918. */
  47919. isCube: boolean;
  47920. /**
  47921. * If the texture is a compressed format eg. FOURCC_DXT1
  47922. */
  47923. isCompressed: boolean;
  47924. /**
  47925. * The dxgiFormat of the texture
  47926. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47927. */
  47928. dxgiFormat: number;
  47929. /**
  47930. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47931. */
  47932. textureType: number;
  47933. /**
  47934. * Sphericle polynomial created for the dds texture
  47935. */
  47936. sphericalPolynomial?: SphericalPolynomial;
  47937. }
  47938. /**
  47939. * Class used to provide DDS decompression tools
  47940. */
  47941. export class DDSTools {
  47942. /**
  47943. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47944. */
  47945. static StoreLODInAlphaChannel: boolean;
  47946. /**
  47947. * Gets DDS information from an array buffer
  47948. * @param arrayBuffer defines the array buffer to read data from
  47949. * @returns the DDS information
  47950. */
  47951. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47952. private static _FloatView;
  47953. private static _Int32View;
  47954. private static _ToHalfFloat;
  47955. private static _FromHalfFloat;
  47956. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47957. private static _GetHalfFloatRGBAArrayBuffer;
  47958. private static _GetFloatRGBAArrayBuffer;
  47959. private static _GetFloatAsUIntRGBAArrayBuffer;
  47960. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47961. private static _GetRGBAArrayBuffer;
  47962. private static _ExtractLongWordOrder;
  47963. private static _GetRGBArrayBuffer;
  47964. private static _GetLuminanceArrayBuffer;
  47965. /**
  47966. * Uploads DDS Levels to a Babylon Texture
  47967. * @hidden
  47968. */
  47969. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47970. }
  47971. interface Engine {
  47972. /**
  47973. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47974. * @param rootUrl defines the url where the file to load is located
  47975. * @param scene defines the current scene
  47976. * @param lodScale defines scale to apply to the mip map selection
  47977. * @param lodOffset defines offset to apply to the mip map selection
  47978. * @param onLoad defines an optional callback raised when the texture is loaded
  47979. * @param onError defines an optional callback raised if there is an issue to load the texture
  47980. * @param format defines the format of the data
  47981. * @param forcedExtension defines the extension to use to pick the right loader
  47982. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47983. * @returns the cube texture as an InternalTexture
  47984. */
  47985. 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;
  47986. }
  47987. }
  47988. declare module BABYLON {
  47989. /**
  47990. * Implementation of the DDS Texture Loader.
  47991. * @hidden
  47992. */
  47993. export class _DDSTextureLoader implements IInternalTextureLoader {
  47994. /**
  47995. * Defines wether the loader supports cascade loading the different faces.
  47996. */
  47997. readonly supportCascades: boolean;
  47998. /**
  47999. * This returns if the loader support the current file information.
  48000. * @param extension defines the file extension of the file being loaded
  48001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48002. * @param fallback defines the fallback internal texture if any
  48003. * @param isBase64 defines whether the texture is encoded as a base64
  48004. * @param isBuffer defines whether the texture data are stored as a buffer
  48005. * @returns true if the loader can load the specified file
  48006. */
  48007. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48008. /**
  48009. * Transform the url before loading if required.
  48010. * @param rootUrl the url of the texture
  48011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48012. * @returns the transformed texture
  48013. */
  48014. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48015. /**
  48016. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48017. * @param rootUrl the url of the texture
  48018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48019. * @returns the fallback texture
  48020. */
  48021. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48022. /**
  48023. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48024. * @param data contains the texture data
  48025. * @param texture defines the BabylonJS internal texture
  48026. * @param createPolynomials will be true if polynomials have been requested
  48027. * @param onLoad defines the callback to trigger once the texture is ready
  48028. * @param onError defines the callback to trigger in case of error
  48029. */
  48030. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48031. /**
  48032. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48033. * @param data contains the texture data
  48034. * @param texture defines the BabylonJS internal texture
  48035. * @param callback defines the method to call once ready to upload
  48036. */
  48037. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48038. }
  48039. }
  48040. declare module BABYLON {
  48041. /**
  48042. * Implementation of the ENV Texture Loader.
  48043. * @hidden
  48044. */
  48045. export class _ENVTextureLoader implements IInternalTextureLoader {
  48046. /**
  48047. * Defines wether the loader supports cascade loading the different faces.
  48048. */
  48049. readonly supportCascades: boolean;
  48050. /**
  48051. * This returns if the loader support the current file information.
  48052. * @param extension defines the file extension of the file being loaded
  48053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48054. * @param fallback defines the fallback internal texture if any
  48055. * @param isBase64 defines whether the texture is encoded as a base64
  48056. * @param isBuffer defines whether the texture data are stored as a buffer
  48057. * @returns true if the loader can load the specified file
  48058. */
  48059. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48060. /**
  48061. * Transform the url before loading if required.
  48062. * @param rootUrl the url of the texture
  48063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48064. * @returns the transformed texture
  48065. */
  48066. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48067. /**
  48068. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48069. * @param rootUrl the url of the texture
  48070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48071. * @returns the fallback texture
  48072. */
  48073. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48074. /**
  48075. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48076. * @param data contains the texture data
  48077. * @param texture defines the BabylonJS internal texture
  48078. * @param createPolynomials will be true if polynomials have been requested
  48079. * @param onLoad defines the callback to trigger once the texture is ready
  48080. * @param onError defines the callback to trigger in case of error
  48081. */
  48082. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48083. /**
  48084. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48085. * @param data contains the texture data
  48086. * @param texture defines the BabylonJS internal texture
  48087. * @param callback defines the method to call once ready to upload
  48088. */
  48089. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48095. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48096. */
  48097. export class KhronosTextureContainer {
  48098. /** contents of the KTX container file */
  48099. arrayBuffer: any;
  48100. private static HEADER_LEN;
  48101. private static COMPRESSED_2D;
  48102. private static COMPRESSED_3D;
  48103. private static TEX_2D;
  48104. private static TEX_3D;
  48105. /**
  48106. * Gets the openGL type
  48107. */
  48108. glType: number;
  48109. /**
  48110. * Gets the openGL type size
  48111. */
  48112. glTypeSize: number;
  48113. /**
  48114. * Gets the openGL format
  48115. */
  48116. glFormat: number;
  48117. /**
  48118. * Gets the openGL internal format
  48119. */
  48120. glInternalFormat: number;
  48121. /**
  48122. * Gets the base internal format
  48123. */
  48124. glBaseInternalFormat: number;
  48125. /**
  48126. * Gets image width in pixel
  48127. */
  48128. pixelWidth: number;
  48129. /**
  48130. * Gets image height in pixel
  48131. */
  48132. pixelHeight: number;
  48133. /**
  48134. * Gets image depth in pixels
  48135. */
  48136. pixelDepth: number;
  48137. /**
  48138. * Gets the number of array elements
  48139. */
  48140. numberOfArrayElements: number;
  48141. /**
  48142. * Gets the number of faces
  48143. */
  48144. numberOfFaces: number;
  48145. /**
  48146. * Gets the number of mipmap levels
  48147. */
  48148. numberOfMipmapLevels: number;
  48149. /**
  48150. * Gets the bytes of key value data
  48151. */
  48152. bytesOfKeyValueData: number;
  48153. /**
  48154. * Gets the load type
  48155. */
  48156. loadType: number;
  48157. /**
  48158. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48159. */
  48160. isInvalid: boolean;
  48161. /**
  48162. * Creates a new KhronosTextureContainer
  48163. * @param arrayBuffer contents of the KTX container file
  48164. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48165. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48166. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48167. */
  48168. constructor(
  48169. /** contents of the KTX container file */
  48170. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48171. /**
  48172. * Uploads KTX content to a Babylon Texture.
  48173. * It is assumed that the texture has already been created & is currently bound
  48174. * @hidden
  48175. */
  48176. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48177. private _upload2DCompressedLevels;
  48178. }
  48179. }
  48180. declare module BABYLON {
  48181. /**
  48182. * Implementation of the KTX Texture Loader.
  48183. * @hidden
  48184. */
  48185. export class _KTXTextureLoader implements IInternalTextureLoader {
  48186. /**
  48187. * Defines wether the loader supports cascade loading the different faces.
  48188. */
  48189. readonly supportCascades: boolean;
  48190. /**
  48191. * This returns if the loader support the current file information.
  48192. * @param extension defines the file extension of the file being loaded
  48193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48194. * @param fallback defines the fallback internal texture if any
  48195. * @param isBase64 defines whether the texture is encoded as a base64
  48196. * @param isBuffer defines whether the texture data are stored as a buffer
  48197. * @returns true if the loader can load the specified file
  48198. */
  48199. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48200. /**
  48201. * Transform the url before loading if required.
  48202. * @param rootUrl the url of the texture
  48203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48204. * @returns the transformed texture
  48205. */
  48206. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48207. /**
  48208. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48209. * @param rootUrl the url of the texture
  48210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48211. * @returns the fallback texture
  48212. */
  48213. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48214. /**
  48215. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48216. * @param data contains the texture data
  48217. * @param texture defines the BabylonJS internal texture
  48218. * @param createPolynomials will be true if polynomials have been requested
  48219. * @param onLoad defines the callback to trigger once the texture is ready
  48220. * @param onError defines the callback to trigger in case of error
  48221. */
  48222. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48223. /**
  48224. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48225. * @param data contains the texture data
  48226. * @param texture defines the BabylonJS internal texture
  48227. * @param callback defines the method to call once ready to upload
  48228. */
  48229. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48230. }
  48231. }
  48232. declare module BABYLON {
  48233. /**
  48234. * Options for the default xr helper
  48235. */
  48236. export class WebXRDefaultExperienceOptions {
  48237. /**
  48238. * Floor meshes that should be used for teleporting
  48239. */
  48240. floorMeshes: Array<AbstractMesh>;
  48241. }
  48242. /**
  48243. * Default experience which provides a similar setup to the previous webVRExperience
  48244. */
  48245. export class WebXRDefaultExperience {
  48246. /**
  48247. * Base experience
  48248. */
  48249. baseExperience: WebXRExperienceHelper;
  48250. /**
  48251. * Input experience extension
  48252. */
  48253. input: WebXRInput;
  48254. /**
  48255. * Loads the controller models
  48256. */
  48257. controllerModelLoader: WebXRControllerModelLoader;
  48258. /**
  48259. * Enables laser pointer and selection
  48260. */
  48261. pointerSelection: WebXRControllerPointerSelection;
  48262. /**
  48263. * Enables teleportation
  48264. */
  48265. teleportation: WebXRControllerTeleportation;
  48266. /**
  48267. * Enables ui for enetering/exiting xr
  48268. */
  48269. enterExitUI: WebXREnterExitUI;
  48270. /**
  48271. * Default output canvas xr should render to
  48272. */
  48273. outputCanvas: WebXRManagedOutputCanvas;
  48274. /**
  48275. * Creates the default xr experience
  48276. * @param scene scene
  48277. * @param options options for basic configuration
  48278. * @returns resulting WebXRDefaultExperience
  48279. */
  48280. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48281. private constructor();
  48282. /**
  48283. * DIsposes of the experience helper
  48284. */
  48285. dispose(): void;
  48286. }
  48287. }
  48288. declare module BABYLON {
  48289. /** @hidden */
  48290. export var _forceSceneHelpersToBundle: boolean;
  48291. interface Scene {
  48292. /**
  48293. * Creates a default light for the scene.
  48294. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48295. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48296. */
  48297. createDefaultLight(replace?: boolean): void;
  48298. /**
  48299. * Creates a default camera for the scene.
  48300. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48301. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48302. * @param replace has default false, when true replaces the active camera in the scene
  48303. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48304. */
  48305. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48306. /**
  48307. * Creates a default camera and a default light.
  48308. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48309. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48310. * @param replace has the default false, when true replaces the active camera/light in the scene
  48311. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48312. */
  48313. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48314. /**
  48315. * Creates a new sky box
  48316. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48317. * @param environmentTexture defines the texture to use as environment texture
  48318. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48319. * @param scale defines the overall scale of the skybox
  48320. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48321. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48322. * @returns a new mesh holding the sky box
  48323. */
  48324. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48325. /**
  48326. * Creates a new environment
  48327. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48328. * @param options defines the options you can use to configure the environment
  48329. * @returns the new EnvironmentHelper
  48330. */
  48331. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48332. /**
  48333. * Creates a new VREXperienceHelper
  48334. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48335. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48336. * @returns a new VREXperienceHelper
  48337. */
  48338. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48339. /**
  48340. * Creates a new WebXRDefaultExperience
  48341. * @see http://doc.babylonjs.com/how_to/webxr
  48342. * @param options experience options
  48343. * @returns a promise for a new WebXRDefaultExperience
  48344. */
  48345. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48351. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48352. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48353. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48354. */
  48355. export class VideoDome extends TransformNode {
  48356. /**
  48357. * Define the video source as a Monoscopic panoramic 360 video.
  48358. */
  48359. static readonly MODE_MONOSCOPIC: number;
  48360. /**
  48361. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48362. */
  48363. static readonly MODE_TOPBOTTOM: number;
  48364. /**
  48365. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48366. */
  48367. static readonly MODE_SIDEBYSIDE: number;
  48368. private _halfDome;
  48369. private _useDirectMapping;
  48370. /**
  48371. * The video texture being displayed on the sphere
  48372. */
  48373. protected _videoTexture: VideoTexture;
  48374. /**
  48375. * Gets the video texture being displayed on the sphere
  48376. */
  48377. readonly videoTexture: VideoTexture;
  48378. /**
  48379. * The skybox material
  48380. */
  48381. protected _material: BackgroundMaterial;
  48382. /**
  48383. * The surface used for the skybox
  48384. */
  48385. protected _mesh: Mesh;
  48386. /**
  48387. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48388. */
  48389. private _halfDomeMask;
  48390. /**
  48391. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48392. * Also see the options.resolution property.
  48393. */
  48394. fovMultiplier: number;
  48395. private _videoMode;
  48396. /**
  48397. * Gets or set the current video mode for the video. It can be:
  48398. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48399. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48400. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48401. */
  48402. videoMode: number;
  48403. /**
  48404. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48405. *
  48406. */
  48407. /**
  48408. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48409. */
  48410. halfDome: boolean;
  48411. /**
  48412. * Oberserver used in Stereoscopic VR Mode.
  48413. */
  48414. private _onBeforeCameraRenderObserver;
  48415. /**
  48416. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48417. * @param name Element's name, child elements will append suffixes for their own names.
  48418. * @param urlsOrVideo defines the url(s) or the video element to use
  48419. * @param options An object containing optional or exposed sub element properties
  48420. */
  48421. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48422. resolution?: number;
  48423. clickToPlay?: boolean;
  48424. autoPlay?: boolean;
  48425. loop?: boolean;
  48426. size?: number;
  48427. poster?: string;
  48428. faceForward?: boolean;
  48429. useDirectMapping?: boolean;
  48430. halfDomeMode?: boolean;
  48431. }, scene: Scene);
  48432. private _changeVideoMode;
  48433. /**
  48434. * Releases resources associated with this node.
  48435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48437. */
  48438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48439. }
  48440. }
  48441. declare module BABYLON {
  48442. /**
  48443. * This class can be used to get instrumentation data from a Babylon engine
  48444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48445. */
  48446. export class EngineInstrumentation implements IDisposable {
  48447. /**
  48448. * Define the instrumented engine.
  48449. */
  48450. engine: Engine;
  48451. private _captureGPUFrameTime;
  48452. private _gpuFrameTimeToken;
  48453. private _gpuFrameTime;
  48454. private _captureShaderCompilationTime;
  48455. private _shaderCompilationTime;
  48456. private _onBeginFrameObserver;
  48457. private _onEndFrameObserver;
  48458. private _onBeforeShaderCompilationObserver;
  48459. private _onAfterShaderCompilationObserver;
  48460. /**
  48461. * Gets the perf counter used for GPU frame time
  48462. */
  48463. readonly gpuFrameTimeCounter: PerfCounter;
  48464. /**
  48465. * Gets the GPU frame time capture status
  48466. */
  48467. /**
  48468. * Enable or disable the GPU frame time capture
  48469. */
  48470. captureGPUFrameTime: boolean;
  48471. /**
  48472. * Gets the perf counter used for shader compilation time
  48473. */
  48474. readonly shaderCompilationTimeCounter: PerfCounter;
  48475. /**
  48476. * Gets the shader compilation time capture status
  48477. */
  48478. /**
  48479. * Enable or disable the shader compilation time capture
  48480. */
  48481. captureShaderCompilationTime: boolean;
  48482. /**
  48483. * Instantiates a new engine instrumentation.
  48484. * This class can be used to get instrumentation data from a Babylon engine
  48485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48486. * @param engine Defines the engine to instrument
  48487. */
  48488. constructor(
  48489. /**
  48490. * Define the instrumented engine.
  48491. */
  48492. engine: Engine);
  48493. /**
  48494. * Dispose and release associated resources.
  48495. */
  48496. dispose(): void;
  48497. }
  48498. }
  48499. declare module BABYLON {
  48500. /**
  48501. * This class can be used to get instrumentation data from a Babylon engine
  48502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48503. */
  48504. export class SceneInstrumentation implements IDisposable {
  48505. /**
  48506. * Defines the scene to instrument
  48507. */
  48508. scene: Scene;
  48509. private _captureActiveMeshesEvaluationTime;
  48510. private _activeMeshesEvaluationTime;
  48511. private _captureRenderTargetsRenderTime;
  48512. private _renderTargetsRenderTime;
  48513. private _captureFrameTime;
  48514. private _frameTime;
  48515. private _captureRenderTime;
  48516. private _renderTime;
  48517. private _captureInterFrameTime;
  48518. private _interFrameTime;
  48519. private _captureParticlesRenderTime;
  48520. private _particlesRenderTime;
  48521. private _captureSpritesRenderTime;
  48522. private _spritesRenderTime;
  48523. private _capturePhysicsTime;
  48524. private _physicsTime;
  48525. private _captureAnimationsTime;
  48526. private _animationsTime;
  48527. private _captureCameraRenderTime;
  48528. private _cameraRenderTime;
  48529. private _onBeforeActiveMeshesEvaluationObserver;
  48530. private _onAfterActiveMeshesEvaluationObserver;
  48531. private _onBeforeRenderTargetsRenderObserver;
  48532. private _onAfterRenderTargetsRenderObserver;
  48533. private _onAfterRenderObserver;
  48534. private _onBeforeDrawPhaseObserver;
  48535. private _onAfterDrawPhaseObserver;
  48536. private _onBeforeAnimationsObserver;
  48537. private _onBeforeParticlesRenderingObserver;
  48538. private _onAfterParticlesRenderingObserver;
  48539. private _onBeforeSpritesRenderingObserver;
  48540. private _onAfterSpritesRenderingObserver;
  48541. private _onBeforePhysicsObserver;
  48542. private _onAfterPhysicsObserver;
  48543. private _onAfterAnimationsObserver;
  48544. private _onBeforeCameraRenderObserver;
  48545. private _onAfterCameraRenderObserver;
  48546. /**
  48547. * Gets the perf counter used for active meshes evaluation time
  48548. */
  48549. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48550. /**
  48551. * Gets the active meshes evaluation time capture status
  48552. */
  48553. /**
  48554. * Enable or disable the active meshes evaluation time capture
  48555. */
  48556. captureActiveMeshesEvaluationTime: boolean;
  48557. /**
  48558. * Gets the perf counter used for render targets render time
  48559. */
  48560. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48561. /**
  48562. * Gets the render targets render time capture status
  48563. */
  48564. /**
  48565. * Enable or disable the render targets render time capture
  48566. */
  48567. captureRenderTargetsRenderTime: boolean;
  48568. /**
  48569. * Gets the perf counter used for particles render time
  48570. */
  48571. readonly particlesRenderTimeCounter: PerfCounter;
  48572. /**
  48573. * Gets the particles render time capture status
  48574. */
  48575. /**
  48576. * Enable or disable the particles render time capture
  48577. */
  48578. captureParticlesRenderTime: boolean;
  48579. /**
  48580. * Gets the perf counter used for sprites render time
  48581. */
  48582. readonly spritesRenderTimeCounter: PerfCounter;
  48583. /**
  48584. * Gets the sprites render time capture status
  48585. */
  48586. /**
  48587. * Enable or disable the sprites render time capture
  48588. */
  48589. captureSpritesRenderTime: boolean;
  48590. /**
  48591. * Gets the perf counter used for physics time
  48592. */
  48593. readonly physicsTimeCounter: PerfCounter;
  48594. /**
  48595. * Gets the physics time capture status
  48596. */
  48597. /**
  48598. * Enable or disable the physics time capture
  48599. */
  48600. capturePhysicsTime: boolean;
  48601. /**
  48602. * Gets the perf counter used for animations time
  48603. */
  48604. readonly animationsTimeCounter: PerfCounter;
  48605. /**
  48606. * Gets the animations time capture status
  48607. */
  48608. /**
  48609. * Enable or disable the animations time capture
  48610. */
  48611. captureAnimationsTime: boolean;
  48612. /**
  48613. * Gets the perf counter used for frame time capture
  48614. */
  48615. readonly frameTimeCounter: PerfCounter;
  48616. /**
  48617. * Gets the frame time capture status
  48618. */
  48619. /**
  48620. * Enable or disable the frame time capture
  48621. */
  48622. captureFrameTime: boolean;
  48623. /**
  48624. * Gets the perf counter used for inter-frames time capture
  48625. */
  48626. readonly interFrameTimeCounter: PerfCounter;
  48627. /**
  48628. * Gets the inter-frames time capture status
  48629. */
  48630. /**
  48631. * Enable or disable the inter-frames time capture
  48632. */
  48633. captureInterFrameTime: boolean;
  48634. /**
  48635. * Gets the perf counter used for render time capture
  48636. */
  48637. readonly renderTimeCounter: PerfCounter;
  48638. /**
  48639. * Gets the render time capture status
  48640. */
  48641. /**
  48642. * Enable or disable the render time capture
  48643. */
  48644. captureRenderTime: boolean;
  48645. /**
  48646. * Gets the perf counter used for camera render time capture
  48647. */
  48648. readonly cameraRenderTimeCounter: PerfCounter;
  48649. /**
  48650. * Gets the camera render time capture status
  48651. */
  48652. /**
  48653. * Enable or disable the camera render time capture
  48654. */
  48655. captureCameraRenderTime: boolean;
  48656. /**
  48657. * Gets the perf counter used for draw calls
  48658. */
  48659. readonly drawCallsCounter: PerfCounter;
  48660. /**
  48661. * Instantiates a new scene instrumentation.
  48662. * This class can be used to get instrumentation data from a Babylon engine
  48663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48664. * @param scene Defines the scene to instrument
  48665. */
  48666. constructor(
  48667. /**
  48668. * Defines the scene to instrument
  48669. */
  48670. scene: Scene);
  48671. /**
  48672. * Dispose and release associated resources.
  48673. */
  48674. dispose(): void;
  48675. }
  48676. }
  48677. declare module BABYLON {
  48678. /** @hidden */
  48679. export var glowMapGenerationPixelShader: {
  48680. name: string;
  48681. shader: string;
  48682. };
  48683. }
  48684. declare module BABYLON {
  48685. /** @hidden */
  48686. export var glowMapGenerationVertexShader: {
  48687. name: string;
  48688. shader: string;
  48689. };
  48690. }
  48691. declare module BABYLON {
  48692. /**
  48693. * Effect layer options. This helps customizing the behaviour
  48694. * of the effect layer.
  48695. */
  48696. export interface IEffectLayerOptions {
  48697. /**
  48698. * Multiplication factor apply to the canvas size to compute the render target size
  48699. * used to generated the objects (the smaller the faster).
  48700. */
  48701. mainTextureRatio: number;
  48702. /**
  48703. * Enforces a fixed size texture to ensure effect stability across devices.
  48704. */
  48705. mainTextureFixedSize?: number;
  48706. /**
  48707. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48708. */
  48709. alphaBlendingMode: number;
  48710. /**
  48711. * The camera attached to the layer.
  48712. */
  48713. camera: Nullable<Camera>;
  48714. /**
  48715. * The rendering group to draw the layer in.
  48716. */
  48717. renderingGroupId: number;
  48718. }
  48719. /**
  48720. * The effect layer Helps adding post process effect blended with the main pass.
  48721. *
  48722. * This can be for instance use to generate glow or higlight effects on the scene.
  48723. *
  48724. * The effect layer class can not be used directly and is intented to inherited from to be
  48725. * customized per effects.
  48726. */
  48727. export abstract class EffectLayer {
  48728. private _vertexBuffers;
  48729. private _indexBuffer;
  48730. private _cachedDefines;
  48731. private _effectLayerMapGenerationEffect;
  48732. private _effectLayerOptions;
  48733. private _mergeEffect;
  48734. protected _scene: Scene;
  48735. protected _engine: Engine;
  48736. protected _maxSize: number;
  48737. protected _mainTextureDesiredSize: ISize;
  48738. protected _mainTexture: RenderTargetTexture;
  48739. protected _shouldRender: boolean;
  48740. protected _postProcesses: PostProcess[];
  48741. protected _textures: BaseTexture[];
  48742. protected _emissiveTextureAndColor: {
  48743. texture: Nullable<BaseTexture>;
  48744. color: Color4;
  48745. };
  48746. /**
  48747. * The name of the layer
  48748. */
  48749. name: string;
  48750. /**
  48751. * The clear color of the texture used to generate the glow map.
  48752. */
  48753. neutralColor: Color4;
  48754. /**
  48755. * Specifies wether the highlight layer is enabled or not.
  48756. */
  48757. isEnabled: boolean;
  48758. /**
  48759. * Gets the camera attached to the layer.
  48760. */
  48761. readonly camera: Nullable<Camera>;
  48762. /**
  48763. * Gets the rendering group id the layer should render in.
  48764. */
  48765. renderingGroupId: number;
  48766. /**
  48767. * An event triggered when the effect layer has been disposed.
  48768. */
  48769. onDisposeObservable: Observable<EffectLayer>;
  48770. /**
  48771. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48772. */
  48773. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48774. /**
  48775. * An event triggered when the generated texture is being merged in the scene.
  48776. */
  48777. onBeforeComposeObservable: Observable<EffectLayer>;
  48778. /**
  48779. * An event triggered when the generated texture has been merged in the scene.
  48780. */
  48781. onAfterComposeObservable: Observable<EffectLayer>;
  48782. /**
  48783. * An event triggered when the efffect layer changes its size.
  48784. */
  48785. onSizeChangedObservable: Observable<EffectLayer>;
  48786. /** @hidden */
  48787. static _SceneComponentInitialization: (scene: Scene) => void;
  48788. /**
  48789. * Instantiates a new effect Layer and references it in the scene.
  48790. * @param name The name of the layer
  48791. * @param scene The scene to use the layer in
  48792. */
  48793. constructor(
  48794. /** The Friendly of the effect in the scene */
  48795. name: string, scene: Scene);
  48796. /**
  48797. * Get the effect name of the layer.
  48798. * @return The effect name
  48799. */
  48800. abstract getEffectName(): string;
  48801. /**
  48802. * Checks for the readiness of the element composing the layer.
  48803. * @param subMesh the mesh to check for
  48804. * @param useInstances specify wether or not to use instances to render the mesh
  48805. * @return true if ready otherwise, false
  48806. */
  48807. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48808. /**
  48809. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48810. * @returns true if the effect requires stencil during the main canvas render pass.
  48811. */
  48812. abstract needStencil(): boolean;
  48813. /**
  48814. * Create the merge effect. This is the shader use to blit the information back
  48815. * to the main canvas at the end of the scene rendering.
  48816. * @returns The effect containing the shader used to merge the effect on the main canvas
  48817. */
  48818. protected abstract _createMergeEffect(): Effect;
  48819. /**
  48820. * Creates the render target textures and post processes used in the effect layer.
  48821. */
  48822. protected abstract _createTextureAndPostProcesses(): void;
  48823. /**
  48824. * Implementation specific of rendering the generating effect on the main canvas.
  48825. * @param effect The effect used to render through
  48826. */
  48827. protected abstract _internalRender(effect: Effect): void;
  48828. /**
  48829. * Sets the required values for both the emissive texture and and the main color.
  48830. */
  48831. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48832. /**
  48833. * Free any resources and references associated to a mesh.
  48834. * Internal use
  48835. * @param mesh The mesh to free.
  48836. */
  48837. abstract _disposeMesh(mesh: Mesh): void;
  48838. /**
  48839. * Serializes this layer (Glow or Highlight for example)
  48840. * @returns a serialized layer object
  48841. */
  48842. abstract serialize?(): any;
  48843. /**
  48844. * Initializes the effect layer with the required options.
  48845. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48846. */
  48847. protected _init(options: Partial<IEffectLayerOptions>): void;
  48848. /**
  48849. * Generates the index buffer of the full screen quad blending to the main canvas.
  48850. */
  48851. private _generateIndexBuffer;
  48852. /**
  48853. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48854. */
  48855. private _generateVertexBuffer;
  48856. /**
  48857. * Sets the main texture desired size which is the closest power of two
  48858. * of the engine canvas size.
  48859. */
  48860. private _setMainTextureSize;
  48861. /**
  48862. * Creates the main texture for the effect layer.
  48863. */
  48864. protected _createMainTexture(): void;
  48865. /**
  48866. * Adds specific effects defines.
  48867. * @param defines The defines to add specifics to.
  48868. */
  48869. protected _addCustomEffectDefines(defines: string[]): void;
  48870. /**
  48871. * Checks for the readiness of the element composing the layer.
  48872. * @param subMesh the mesh to check for
  48873. * @param useInstances specify wether or not to use instances to render the mesh
  48874. * @param emissiveTexture the associated emissive texture used to generate the glow
  48875. * @return true if ready otherwise, false
  48876. */
  48877. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48878. /**
  48879. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48880. */
  48881. render(): void;
  48882. /**
  48883. * Determine if a given mesh will be used in the current effect.
  48884. * @param mesh mesh to test
  48885. * @returns true if the mesh will be used
  48886. */
  48887. hasMesh(mesh: AbstractMesh): boolean;
  48888. /**
  48889. * Returns true if the layer contains information to display, otherwise false.
  48890. * @returns true if the glow layer should be rendered
  48891. */
  48892. shouldRender(): boolean;
  48893. /**
  48894. * Returns true if the mesh should render, otherwise false.
  48895. * @param mesh The mesh to render
  48896. * @returns true if it should render otherwise false
  48897. */
  48898. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48899. /**
  48900. * Returns true if the mesh can be rendered, otherwise false.
  48901. * @param mesh The mesh to render
  48902. * @param material The material used on the mesh
  48903. * @returns true if it can be rendered otherwise false
  48904. */
  48905. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48906. /**
  48907. * Returns true if the mesh should render, otherwise false.
  48908. * @param mesh The mesh to render
  48909. * @returns true if it should render otherwise false
  48910. */
  48911. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48912. /**
  48913. * Renders the submesh passed in parameter to the generation map.
  48914. */
  48915. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48916. /**
  48917. * Rebuild the required buffers.
  48918. * @hidden Internal use only.
  48919. */
  48920. _rebuild(): void;
  48921. /**
  48922. * Dispose only the render target textures and post process.
  48923. */
  48924. private _disposeTextureAndPostProcesses;
  48925. /**
  48926. * Dispose the highlight layer and free resources.
  48927. */
  48928. dispose(): void;
  48929. /**
  48930. * Gets the class name of the effect layer
  48931. * @returns the string with the class name of the effect layer
  48932. */
  48933. getClassName(): string;
  48934. /**
  48935. * Creates an effect layer from parsed effect layer data
  48936. * @param parsedEffectLayer defines effect layer data
  48937. * @param scene defines the current scene
  48938. * @param rootUrl defines the root URL containing the effect layer information
  48939. * @returns a parsed effect Layer
  48940. */
  48941. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48942. }
  48943. }
  48944. declare module BABYLON {
  48945. interface AbstractScene {
  48946. /**
  48947. * The list of effect layers (highlights/glow) added to the scene
  48948. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48949. * @see http://doc.babylonjs.com/how_to/glow_layer
  48950. */
  48951. effectLayers: Array<EffectLayer>;
  48952. /**
  48953. * Removes the given effect layer from this scene.
  48954. * @param toRemove defines the effect layer to remove
  48955. * @returns the index of the removed effect layer
  48956. */
  48957. removeEffectLayer(toRemove: EffectLayer): number;
  48958. /**
  48959. * Adds the given effect layer to this scene
  48960. * @param newEffectLayer defines the effect layer to add
  48961. */
  48962. addEffectLayer(newEffectLayer: EffectLayer): void;
  48963. }
  48964. /**
  48965. * Defines the layer scene component responsible to manage any effect layers
  48966. * in a given scene.
  48967. */
  48968. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48969. /**
  48970. * The component name helpfull to identify the component in the list of scene components.
  48971. */
  48972. readonly name: string;
  48973. /**
  48974. * The scene the component belongs to.
  48975. */
  48976. scene: Scene;
  48977. private _engine;
  48978. private _renderEffects;
  48979. private _needStencil;
  48980. private _previousStencilState;
  48981. /**
  48982. * Creates a new instance of the component for the given scene
  48983. * @param scene Defines the scene to register the component in
  48984. */
  48985. constructor(scene: Scene);
  48986. /**
  48987. * Registers the component in a given scene
  48988. */
  48989. register(): void;
  48990. /**
  48991. * Rebuilds the elements related to this component in case of
  48992. * context lost for instance.
  48993. */
  48994. rebuild(): void;
  48995. /**
  48996. * Serializes the component data to the specified json object
  48997. * @param serializationObject The object to serialize to
  48998. */
  48999. serialize(serializationObject: any): void;
  49000. /**
  49001. * Adds all the elements from the container to the scene
  49002. * @param container the container holding the elements
  49003. */
  49004. addFromContainer(container: AbstractScene): void;
  49005. /**
  49006. * Removes all the elements in the container from the scene
  49007. * @param container contains the elements to remove
  49008. * @param dispose if the removed element should be disposed (default: false)
  49009. */
  49010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49011. /**
  49012. * Disposes the component and the associated ressources.
  49013. */
  49014. dispose(): void;
  49015. private _isReadyForMesh;
  49016. private _renderMainTexture;
  49017. private _setStencil;
  49018. private _setStencilBack;
  49019. private _draw;
  49020. private _drawCamera;
  49021. private _drawRenderingGroup;
  49022. }
  49023. }
  49024. declare module BABYLON {
  49025. /** @hidden */
  49026. export var glowMapMergePixelShader: {
  49027. name: string;
  49028. shader: string;
  49029. };
  49030. }
  49031. declare module BABYLON {
  49032. /** @hidden */
  49033. export var glowMapMergeVertexShader: {
  49034. name: string;
  49035. shader: string;
  49036. };
  49037. }
  49038. declare module BABYLON {
  49039. interface AbstractScene {
  49040. /**
  49041. * Return a the first highlight layer of the scene with a given name.
  49042. * @param name The name of the highlight layer to look for.
  49043. * @return The highlight layer if found otherwise null.
  49044. */
  49045. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49046. }
  49047. /**
  49048. * Glow layer options. This helps customizing the behaviour
  49049. * of the glow layer.
  49050. */
  49051. export interface IGlowLayerOptions {
  49052. /**
  49053. * Multiplication factor apply to the canvas size to compute the render target size
  49054. * used to generated the glowing objects (the smaller the faster).
  49055. */
  49056. mainTextureRatio: number;
  49057. /**
  49058. * Enforces a fixed size texture to ensure resize independant blur.
  49059. */
  49060. mainTextureFixedSize?: number;
  49061. /**
  49062. * How big is the kernel of the blur texture.
  49063. */
  49064. blurKernelSize: number;
  49065. /**
  49066. * The camera attached to the layer.
  49067. */
  49068. camera: Nullable<Camera>;
  49069. /**
  49070. * Enable MSAA by chosing the number of samples.
  49071. */
  49072. mainTextureSamples?: number;
  49073. /**
  49074. * The rendering group to draw the layer in.
  49075. */
  49076. renderingGroupId: number;
  49077. }
  49078. /**
  49079. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49080. *
  49081. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49082. * glowy meshes to your scene.
  49083. *
  49084. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49085. */
  49086. export class GlowLayer extends EffectLayer {
  49087. /**
  49088. * Effect Name of the layer.
  49089. */
  49090. static readonly EffectName: string;
  49091. /**
  49092. * The default blur kernel size used for the glow.
  49093. */
  49094. static DefaultBlurKernelSize: number;
  49095. /**
  49096. * The default texture size ratio used for the glow.
  49097. */
  49098. static DefaultTextureRatio: number;
  49099. /**
  49100. * Sets the kernel size of the blur.
  49101. */
  49102. /**
  49103. * Gets the kernel size of the blur.
  49104. */
  49105. blurKernelSize: number;
  49106. /**
  49107. * Sets the glow intensity.
  49108. */
  49109. /**
  49110. * Gets the glow intensity.
  49111. */
  49112. intensity: number;
  49113. private _options;
  49114. private _intensity;
  49115. private _horizontalBlurPostprocess1;
  49116. private _verticalBlurPostprocess1;
  49117. private _horizontalBlurPostprocess2;
  49118. private _verticalBlurPostprocess2;
  49119. private _blurTexture1;
  49120. private _blurTexture2;
  49121. private _postProcesses1;
  49122. private _postProcesses2;
  49123. private _includedOnlyMeshes;
  49124. private _excludedMeshes;
  49125. /**
  49126. * Callback used to let the user override the color selection on a per mesh basis
  49127. */
  49128. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49129. /**
  49130. * Callback used to let the user override the texture selection on a per mesh basis
  49131. */
  49132. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49133. /**
  49134. * Instantiates a new glow Layer and references it to the scene.
  49135. * @param name The name of the layer
  49136. * @param scene The scene to use the layer in
  49137. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49138. */
  49139. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49140. /**
  49141. * Get the effect name of the layer.
  49142. * @return The effect name
  49143. */
  49144. getEffectName(): string;
  49145. /**
  49146. * Create the merge effect. This is the shader use to blit the information back
  49147. * to the main canvas at the end of the scene rendering.
  49148. */
  49149. protected _createMergeEffect(): Effect;
  49150. /**
  49151. * Creates the render target textures and post processes used in the glow layer.
  49152. */
  49153. protected _createTextureAndPostProcesses(): void;
  49154. /**
  49155. * Checks for the readiness of the element composing the layer.
  49156. * @param subMesh the mesh to check for
  49157. * @param useInstances specify wether or not to use instances to render the mesh
  49158. * @param emissiveTexture the associated emissive texture used to generate the glow
  49159. * @return true if ready otherwise, false
  49160. */
  49161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49162. /**
  49163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49164. */
  49165. needStencil(): boolean;
  49166. /**
  49167. * Returns true if the mesh can be rendered, otherwise false.
  49168. * @param mesh The mesh to render
  49169. * @param material The material used on the mesh
  49170. * @returns true if it can be rendered otherwise false
  49171. */
  49172. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49173. /**
  49174. * Implementation specific of rendering the generating effect on the main canvas.
  49175. * @param effect The effect used to render through
  49176. */
  49177. protected _internalRender(effect: Effect): void;
  49178. /**
  49179. * Sets the required values for both the emissive texture and and the main color.
  49180. */
  49181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49182. /**
  49183. * Returns true if the mesh should render, otherwise false.
  49184. * @param mesh The mesh to render
  49185. * @returns true if it should render otherwise false
  49186. */
  49187. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49188. /**
  49189. * Adds specific effects defines.
  49190. * @param defines The defines to add specifics to.
  49191. */
  49192. protected _addCustomEffectDefines(defines: string[]): void;
  49193. /**
  49194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49195. * @param mesh The mesh to exclude from the glow layer
  49196. */
  49197. addExcludedMesh(mesh: Mesh): void;
  49198. /**
  49199. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49200. * @param mesh The mesh to remove
  49201. */
  49202. removeExcludedMesh(mesh: Mesh): void;
  49203. /**
  49204. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49205. * @param mesh The mesh to include in the glow layer
  49206. */
  49207. addIncludedOnlyMesh(mesh: Mesh): void;
  49208. /**
  49209. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49210. * @param mesh The mesh to remove
  49211. */
  49212. removeIncludedOnlyMesh(mesh: Mesh): void;
  49213. /**
  49214. * Determine if a given mesh will be used in the glow layer
  49215. * @param mesh The mesh to test
  49216. * @returns true if the mesh will be highlighted by the current glow layer
  49217. */
  49218. hasMesh(mesh: AbstractMesh): boolean;
  49219. /**
  49220. * Free any resources and references associated to a mesh.
  49221. * Internal use
  49222. * @param mesh The mesh to free.
  49223. * @hidden
  49224. */
  49225. _disposeMesh(mesh: Mesh): void;
  49226. /**
  49227. * Gets the class name of the effect layer
  49228. * @returns the string with the class name of the effect layer
  49229. */
  49230. getClassName(): string;
  49231. /**
  49232. * Serializes this glow layer
  49233. * @returns a serialized glow layer object
  49234. */
  49235. serialize(): any;
  49236. /**
  49237. * Creates a Glow Layer from parsed glow layer data
  49238. * @param parsedGlowLayer defines glow layer data
  49239. * @param scene defines the current scene
  49240. * @param rootUrl defines the root URL containing the glow layer information
  49241. * @returns a parsed Glow Layer
  49242. */
  49243. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49244. }
  49245. }
  49246. declare module BABYLON {
  49247. /** @hidden */
  49248. export var glowBlurPostProcessPixelShader: {
  49249. name: string;
  49250. shader: string;
  49251. };
  49252. }
  49253. declare module BABYLON {
  49254. interface AbstractScene {
  49255. /**
  49256. * Return a the first highlight layer of the scene with a given name.
  49257. * @param name The name of the highlight layer to look for.
  49258. * @return The highlight layer if found otherwise null.
  49259. */
  49260. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49261. }
  49262. /**
  49263. * Highlight layer options. This helps customizing the behaviour
  49264. * of the highlight layer.
  49265. */
  49266. export interface IHighlightLayerOptions {
  49267. /**
  49268. * Multiplication factor apply to the canvas size to compute the render target size
  49269. * used to generated the glowing objects (the smaller the faster).
  49270. */
  49271. mainTextureRatio: number;
  49272. /**
  49273. * Enforces a fixed size texture to ensure resize independant blur.
  49274. */
  49275. mainTextureFixedSize?: number;
  49276. /**
  49277. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49278. * of the picture to blur (the smaller the faster).
  49279. */
  49280. blurTextureSizeRatio: number;
  49281. /**
  49282. * How big in texel of the blur texture is the vertical blur.
  49283. */
  49284. blurVerticalSize: number;
  49285. /**
  49286. * How big in texel of the blur texture is the horizontal blur.
  49287. */
  49288. blurHorizontalSize: number;
  49289. /**
  49290. * Alpha blending mode used to apply the blur. Default is combine.
  49291. */
  49292. alphaBlendingMode: number;
  49293. /**
  49294. * The camera attached to the layer.
  49295. */
  49296. camera: Nullable<Camera>;
  49297. /**
  49298. * Should we display highlight as a solid stroke?
  49299. */
  49300. isStroke?: boolean;
  49301. /**
  49302. * The rendering group to draw the layer in.
  49303. */
  49304. renderingGroupId: number;
  49305. }
  49306. /**
  49307. * The highlight layer Helps adding a glow effect around a mesh.
  49308. *
  49309. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49310. * glowy meshes to your scene.
  49311. *
  49312. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49313. */
  49314. export class HighlightLayer extends EffectLayer {
  49315. name: string;
  49316. /**
  49317. * Effect Name of the highlight layer.
  49318. */
  49319. static readonly EffectName: string;
  49320. /**
  49321. * The neutral color used during the preparation of the glow effect.
  49322. * This is black by default as the blend operation is a blend operation.
  49323. */
  49324. static NeutralColor: Color4;
  49325. /**
  49326. * Stencil value used for glowing meshes.
  49327. */
  49328. static GlowingMeshStencilReference: number;
  49329. /**
  49330. * Stencil value used for the other meshes in the scene.
  49331. */
  49332. static NormalMeshStencilReference: number;
  49333. /**
  49334. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49335. */
  49336. innerGlow: boolean;
  49337. /**
  49338. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49339. */
  49340. outerGlow: boolean;
  49341. /**
  49342. * Specifies the horizontal size of the blur.
  49343. */
  49344. /**
  49345. * Gets the horizontal size of the blur.
  49346. */
  49347. blurHorizontalSize: number;
  49348. /**
  49349. * Specifies the vertical size of the blur.
  49350. */
  49351. /**
  49352. * Gets the vertical size of the blur.
  49353. */
  49354. blurVerticalSize: number;
  49355. /**
  49356. * An event triggered when the highlight layer is being blurred.
  49357. */
  49358. onBeforeBlurObservable: Observable<HighlightLayer>;
  49359. /**
  49360. * An event triggered when the highlight layer has been blurred.
  49361. */
  49362. onAfterBlurObservable: Observable<HighlightLayer>;
  49363. private _instanceGlowingMeshStencilReference;
  49364. private _options;
  49365. private _downSamplePostprocess;
  49366. private _horizontalBlurPostprocess;
  49367. private _verticalBlurPostprocess;
  49368. private _blurTexture;
  49369. private _meshes;
  49370. private _excludedMeshes;
  49371. /**
  49372. * Instantiates a new highlight Layer and references it to the scene..
  49373. * @param name The name of the layer
  49374. * @param scene The scene to use the layer in
  49375. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49376. */
  49377. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49378. /**
  49379. * Get the effect name of the layer.
  49380. * @return The effect name
  49381. */
  49382. getEffectName(): string;
  49383. /**
  49384. * Create the merge effect. This is the shader use to blit the information back
  49385. * to the main canvas at the end of the scene rendering.
  49386. */
  49387. protected _createMergeEffect(): Effect;
  49388. /**
  49389. * Creates the render target textures and post processes used in the highlight layer.
  49390. */
  49391. protected _createTextureAndPostProcesses(): void;
  49392. /**
  49393. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49394. */
  49395. needStencil(): boolean;
  49396. /**
  49397. * Checks for the readiness of the element composing the layer.
  49398. * @param subMesh the mesh to check for
  49399. * @param useInstances specify wether or not to use instances to render the mesh
  49400. * @param emissiveTexture the associated emissive texture used to generate the glow
  49401. * @return true if ready otherwise, false
  49402. */
  49403. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49404. /**
  49405. * Implementation specific of rendering the generating effect on the main canvas.
  49406. * @param effect The effect used to render through
  49407. */
  49408. protected _internalRender(effect: Effect): void;
  49409. /**
  49410. * Returns true if the layer contains information to display, otherwise false.
  49411. */
  49412. shouldRender(): boolean;
  49413. /**
  49414. * Returns true if the mesh should render, otherwise false.
  49415. * @param mesh The mesh to render
  49416. * @returns true if it should render otherwise false
  49417. */
  49418. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49419. /**
  49420. * Sets the required values for both the emissive texture and and the main color.
  49421. */
  49422. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49423. /**
  49424. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49425. * @param mesh The mesh to exclude from the highlight layer
  49426. */
  49427. addExcludedMesh(mesh: Mesh): void;
  49428. /**
  49429. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49430. * @param mesh The mesh to highlight
  49431. */
  49432. removeExcludedMesh(mesh: Mesh): void;
  49433. /**
  49434. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49435. * @param mesh mesh to test
  49436. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49437. */
  49438. hasMesh(mesh: AbstractMesh): boolean;
  49439. /**
  49440. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49441. * @param mesh The mesh to highlight
  49442. * @param color The color of the highlight
  49443. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49444. */
  49445. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49446. /**
  49447. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49448. * @param mesh The mesh to highlight
  49449. */
  49450. removeMesh(mesh: Mesh): void;
  49451. /**
  49452. * Force the stencil to the normal expected value for none glowing parts
  49453. */
  49454. private _defaultStencilReference;
  49455. /**
  49456. * Free any resources and references associated to a mesh.
  49457. * Internal use
  49458. * @param mesh The mesh to free.
  49459. * @hidden
  49460. */
  49461. _disposeMesh(mesh: Mesh): void;
  49462. /**
  49463. * Dispose the highlight layer and free resources.
  49464. */
  49465. dispose(): void;
  49466. /**
  49467. * Gets the class name of the effect layer
  49468. * @returns the string with the class name of the effect layer
  49469. */
  49470. getClassName(): string;
  49471. /**
  49472. * Serializes this Highlight layer
  49473. * @returns a serialized Highlight layer object
  49474. */
  49475. serialize(): any;
  49476. /**
  49477. * Creates a Highlight layer from parsed Highlight layer data
  49478. * @param parsedHightlightLayer defines the Highlight layer data
  49479. * @param scene defines the current scene
  49480. * @param rootUrl defines the root URL containing the Highlight layer information
  49481. * @returns a parsed Highlight layer
  49482. */
  49483. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. interface AbstractScene {
  49488. /**
  49489. * The list of layers (background and foreground) of the scene
  49490. */
  49491. layers: Array<Layer>;
  49492. }
  49493. /**
  49494. * Defines the layer scene component responsible to manage any layers
  49495. * in a given scene.
  49496. */
  49497. export class LayerSceneComponent implements ISceneComponent {
  49498. /**
  49499. * The component name helpfull to identify the component in the list of scene components.
  49500. */
  49501. readonly name: string;
  49502. /**
  49503. * The scene the component belongs to.
  49504. */
  49505. scene: Scene;
  49506. private _engine;
  49507. /**
  49508. * Creates a new instance of the component for the given scene
  49509. * @param scene Defines the scene to register the component in
  49510. */
  49511. constructor(scene: Scene);
  49512. /**
  49513. * Registers the component in a given scene
  49514. */
  49515. register(): void;
  49516. /**
  49517. * Rebuilds the elements related to this component in case of
  49518. * context lost for instance.
  49519. */
  49520. rebuild(): void;
  49521. /**
  49522. * Disposes the component and the associated ressources.
  49523. */
  49524. dispose(): void;
  49525. private _draw;
  49526. private _drawCameraPredicate;
  49527. private _drawCameraBackground;
  49528. private _drawCameraForeground;
  49529. private _drawRenderTargetPredicate;
  49530. private _drawRenderTargetBackground;
  49531. private _drawRenderTargetForeground;
  49532. /**
  49533. * Adds all the elements from the container to the scene
  49534. * @param container the container holding the elements
  49535. */
  49536. addFromContainer(container: AbstractScene): void;
  49537. /**
  49538. * Removes all the elements in the container from the scene
  49539. * @param container contains the elements to remove
  49540. * @param dispose if the removed element should be disposed (default: false)
  49541. */
  49542. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49543. }
  49544. }
  49545. declare module BABYLON {
  49546. /** @hidden */
  49547. export var layerPixelShader: {
  49548. name: string;
  49549. shader: string;
  49550. };
  49551. }
  49552. declare module BABYLON {
  49553. /** @hidden */
  49554. export var layerVertexShader: {
  49555. name: string;
  49556. shader: string;
  49557. };
  49558. }
  49559. declare module BABYLON {
  49560. /**
  49561. * This represents a full screen 2d layer.
  49562. * This can be useful to display a picture in the background of your scene for instance.
  49563. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49564. */
  49565. export class Layer {
  49566. /**
  49567. * Define the name of the layer.
  49568. */
  49569. name: string;
  49570. /**
  49571. * Define the texture the layer should display.
  49572. */
  49573. texture: Nullable<Texture>;
  49574. /**
  49575. * Is the layer in background or foreground.
  49576. */
  49577. isBackground: boolean;
  49578. /**
  49579. * Define the color of the layer (instead of texture).
  49580. */
  49581. color: Color4;
  49582. /**
  49583. * Define the scale of the layer in order to zoom in out of the texture.
  49584. */
  49585. scale: Vector2;
  49586. /**
  49587. * Define an offset for the layer in order to shift the texture.
  49588. */
  49589. offset: Vector2;
  49590. /**
  49591. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49592. */
  49593. alphaBlendingMode: number;
  49594. /**
  49595. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49596. * Alpha test will not mix with the background color in case of transparency.
  49597. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49598. */
  49599. alphaTest: boolean;
  49600. /**
  49601. * Define a mask to restrict the layer to only some of the scene cameras.
  49602. */
  49603. layerMask: number;
  49604. /**
  49605. * Define the list of render target the layer is visible into.
  49606. */
  49607. renderTargetTextures: RenderTargetTexture[];
  49608. /**
  49609. * Define if the layer is only used in renderTarget or if it also
  49610. * renders in the main frame buffer of the canvas.
  49611. */
  49612. renderOnlyInRenderTargetTextures: boolean;
  49613. private _scene;
  49614. private _vertexBuffers;
  49615. private _indexBuffer;
  49616. private _effect;
  49617. private _alphaTestEffect;
  49618. /**
  49619. * An event triggered when the layer is disposed.
  49620. */
  49621. onDisposeObservable: Observable<Layer>;
  49622. private _onDisposeObserver;
  49623. /**
  49624. * Back compatibility with callback before the onDisposeObservable existed.
  49625. * The set callback will be triggered when the layer has been disposed.
  49626. */
  49627. onDispose: () => void;
  49628. /**
  49629. * An event triggered before rendering the scene
  49630. */
  49631. onBeforeRenderObservable: Observable<Layer>;
  49632. private _onBeforeRenderObserver;
  49633. /**
  49634. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49635. * The set callback will be triggered just before rendering the layer.
  49636. */
  49637. onBeforeRender: () => void;
  49638. /**
  49639. * An event triggered after rendering the scene
  49640. */
  49641. onAfterRenderObservable: Observable<Layer>;
  49642. private _onAfterRenderObserver;
  49643. /**
  49644. * Back compatibility with callback before the onAfterRenderObservable existed.
  49645. * The set callback will be triggered just after rendering the layer.
  49646. */
  49647. onAfterRender: () => void;
  49648. /**
  49649. * Instantiates a new layer.
  49650. * This represents a full screen 2d layer.
  49651. * This can be useful to display a picture in the background of your scene for instance.
  49652. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49653. * @param name Define the name of the layer in the scene
  49654. * @param imgUrl Define the url of the texture to display in the layer
  49655. * @param scene Define the scene the layer belongs to
  49656. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49657. * @param color Defines a color for the layer
  49658. */
  49659. constructor(
  49660. /**
  49661. * Define the name of the layer.
  49662. */
  49663. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49664. private _createIndexBuffer;
  49665. /** @hidden */
  49666. _rebuild(): void;
  49667. /**
  49668. * Renders the layer in the scene.
  49669. */
  49670. render(): void;
  49671. /**
  49672. * Disposes and releases the associated ressources.
  49673. */
  49674. dispose(): void;
  49675. }
  49676. }
  49677. declare module BABYLON {
  49678. /** @hidden */
  49679. export var lensFlarePixelShader: {
  49680. name: string;
  49681. shader: string;
  49682. };
  49683. }
  49684. declare module BABYLON {
  49685. /** @hidden */
  49686. export var lensFlareVertexShader: {
  49687. name: string;
  49688. shader: string;
  49689. };
  49690. }
  49691. declare module BABYLON {
  49692. /**
  49693. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49694. * It is usually composed of several `lensFlare`.
  49695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49696. */
  49697. export class LensFlareSystem {
  49698. /**
  49699. * Define the name of the lens flare system
  49700. */
  49701. name: string;
  49702. /**
  49703. * List of lens flares used in this system.
  49704. */
  49705. lensFlares: LensFlare[];
  49706. /**
  49707. * Define a limit from the border the lens flare can be visible.
  49708. */
  49709. borderLimit: number;
  49710. /**
  49711. * Define a viewport border we do not want to see the lens flare in.
  49712. */
  49713. viewportBorder: number;
  49714. /**
  49715. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49716. */
  49717. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49718. /**
  49719. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49720. */
  49721. layerMask: number;
  49722. /**
  49723. * Define the id of the lens flare system in the scene.
  49724. * (equal to name by default)
  49725. */
  49726. id: string;
  49727. private _scene;
  49728. private _emitter;
  49729. private _vertexBuffers;
  49730. private _indexBuffer;
  49731. private _effect;
  49732. private _positionX;
  49733. private _positionY;
  49734. private _isEnabled;
  49735. /** @hidden */
  49736. static _SceneComponentInitialization: (scene: Scene) => void;
  49737. /**
  49738. * Instantiates a lens flare system.
  49739. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49740. * It is usually composed of several `lensFlare`.
  49741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49742. * @param name Define the name of the lens flare system in the scene
  49743. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49744. * @param scene Define the scene the lens flare system belongs to
  49745. */
  49746. constructor(
  49747. /**
  49748. * Define the name of the lens flare system
  49749. */
  49750. name: string, emitter: any, scene: Scene);
  49751. /**
  49752. * Define if the lens flare system is enabled.
  49753. */
  49754. isEnabled: boolean;
  49755. /**
  49756. * Get the scene the effects belongs to.
  49757. * @returns the scene holding the lens flare system
  49758. */
  49759. getScene(): Scene;
  49760. /**
  49761. * Get the emitter of the lens flare system.
  49762. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49763. * @returns the emitter of the lens flare system
  49764. */
  49765. getEmitter(): any;
  49766. /**
  49767. * Set the emitter of the lens flare system.
  49768. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49769. * @param newEmitter Define the new emitter of the system
  49770. */
  49771. setEmitter(newEmitter: any): void;
  49772. /**
  49773. * Get the lens flare system emitter position.
  49774. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49775. * @returns the position
  49776. */
  49777. getEmitterPosition(): Vector3;
  49778. /**
  49779. * @hidden
  49780. */
  49781. computeEffectivePosition(globalViewport: Viewport): boolean;
  49782. /** @hidden */
  49783. _isVisible(): boolean;
  49784. /**
  49785. * @hidden
  49786. */
  49787. render(): boolean;
  49788. /**
  49789. * Dispose and release the lens flare with its associated resources.
  49790. */
  49791. dispose(): void;
  49792. /**
  49793. * Parse a lens flare system from a JSON repressentation
  49794. * @param parsedLensFlareSystem Define the JSON to parse
  49795. * @param scene Define the scene the parsed system should be instantiated in
  49796. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49797. * @returns the parsed system
  49798. */
  49799. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49800. /**
  49801. * Serialize the current Lens Flare System into a JSON representation.
  49802. * @returns the serialized JSON
  49803. */
  49804. serialize(): any;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * This represents one of the lens effect in a `lensFlareSystem`.
  49810. * It controls one of the indiviual texture used in the effect.
  49811. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49812. */
  49813. export class LensFlare {
  49814. /**
  49815. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49816. */
  49817. size: number;
  49818. /**
  49819. * 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.
  49820. */
  49821. position: number;
  49822. /**
  49823. * Define the lens color.
  49824. */
  49825. color: Color3;
  49826. /**
  49827. * Define the lens texture.
  49828. */
  49829. texture: Nullable<Texture>;
  49830. /**
  49831. * Define the alpha mode to render this particular lens.
  49832. */
  49833. alphaMode: number;
  49834. private _system;
  49835. /**
  49836. * Creates a new Lens Flare.
  49837. * This represents one of the lens effect in a `lensFlareSystem`.
  49838. * It controls one of the indiviual texture used in the effect.
  49839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49840. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49841. * @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.
  49842. * @param color Define the lens color
  49843. * @param imgUrl Define the lens texture url
  49844. * @param system Define the `lensFlareSystem` this flare is part of
  49845. * @returns The newly created Lens Flare
  49846. */
  49847. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49848. /**
  49849. * Instantiates a new Lens Flare.
  49850. * This represents one of the lens effect in a `lensFlareSystem`.
  49851. * It controls one of the indiviual texture used in the effect.
  49852. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49853. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49854. * @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.
  49855. * @param color Define the lens color
  49856. * @param imgUrl Define the lens texture url
  49857. * @param system Define the `lensFlareSystem` this flare is part of
  49858. */
  49859. constructor(
  49860. /**
  49861. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49862. */
  49863. size: number,
  49864. /**
  49865. * 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.
  49866. */
  49867. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49868. /**
  49869. * Dispose and release the lens flare with its associated resources.
  49870. */
  49871. dispose(): void;
  49872. }
  49873. }
  49874. declare module BABYLON {
  49875. interface AbstractScene {
  49876. /**
  49877. * The list of lens flare system added to the scene
  49878. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49879. */
  49880. lensFlareSystems: Array<LensFlareSystem>;
  49881. /**
  49882. * Removes the given lens flare system from this scene.
  49883. * @param toRemove The lens flare system to remove
  49884. * @returns The index of the removed lens flare system
  49885. */
  49886. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49887. /**
  49888. * Adds the given lens flare system to this scene
  49889. * @param newLensFlareSystem The lens flare system to add
  49890. */
  49891. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49892. /**
  49893. * Gets a lens flare system using its name
  49894. * @param name defines the name to look for
  49895. * @returns the lens flare system or null if not found
  49896. */
  49897. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49898. /**
  49899. * Gets a lens flare system using its id
  49900. * @param id defines the id to look for
  49901. * @returns the lens flare system or null if not found
  49902. */
  49903. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49904. }
  49905. /**
  49906. * Defines the lens flare scene component responsible to manage any lens flares
  49907. * in a given scene.
  49908. */
  49909. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49910. /**
  49911. * The component name helpfull to identify the component in the list of scene components.
  49912. */
  49913. readonly name: string;
  49914. /**
  49915. * The scene the component belongs to.
  49916. */
  49917. scene: Scene;
  49918. /**
  49919. * Creates a new instance of the component for the given scene
  49920. * @param scene Defines the scene to register the component in
  49921. */
  49922. constructor(scene: Scene);
  49923. /**
  49924. * Registers the component in a given scene
  49925. */
  49926. register(): void;
  49927. /**
  49928. * Rebuilds the elements related to this component in case of
  49929. * context lost for instance.
  49930. */
  49931. rebuild(): void;
  49932. /**
  49933. * Adds all the elements from the container to the scene
  49934. * @param container the container holding the elements
  49935. */
  49936. addFromContainer(container: AbstractScene): void;
  49937. /**
  49938. * Removes all the elements in the container from the scene
  49939. * @param container contains the elements to remove
  49940. * @param dispose if the removed element should be disposed (default: false)
  49941. */
  49942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49943. /**
  49944. * Serializes the component data to the specified json object
  49945. * @param serializationObject The object to serialize to
  49946. */
  49947. serialize(serializationObject: any): void;
  49948. /**
  49949. * Disposes the component and the associated ressources.
  49950. */
  49951. dispose(): void;
  49952. private _draw;
  49953. }
  49954. }
  49955. declare module BABYLON {
  49956. /**
  49957. * Defines the shadow generator component responsible to manage any shadow generators
  49958. * in a given scene.
  49959. */
  49960. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49961. /**
  49962. * The component name helpfull to identify the component in the list of scene components.
  49963. */
  49964. readonly name: string;
  49965. /**
  49966. * The scene the component belongs to.
  49967. */
  49968. scene: Scene;
  49969. /**
  49970. * Creates a new instance of the component for the given scene
  49971. * @param scene Defines the scene to register the component in
  49972. */
  49973. constructor(scene: Scene);
  49974. /**
  49975. * Registers the component in a given scene
  49976. */
  49977. register(): void;
  49978. /**
  49979. * Rebuilds the elements related to this component in case of
  49980. * context lost for instance.
  49981. */
  49982. rebuild(): void;
  49983. /**
  49984. * Serializes the component data to the specified json object
  49985. * @param serializationObject The object to serialize to
  49986. */
  49987. serialize(serializationObject: any): void;
  49988. /**
  49989. * Adds all the elements from the container to the scene
  49990. * @param container the container holding the elements
  49991. */
  49992. addFromContainer(container: AbstractScene): void;
  49993. /**
  49994. * Removes all the elements in the container from the scene
  49995. * @param container contains the elements to remove
  49996. * @param dispose if the removed element should be disposed (default: false)
  49997. */
  49998. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49999. /**
  50000. * Rebuilds the elements related to this component in case of
  50001. * context lost for instance.
  50002. */
  50003. dispose(): void;
  50004. private _gatherRenderTargets;
  50005. }
  50006. }
  50007. declare module BABYLON {
  50008. /**
  50009. * A point light is a light defined by an unique point in world space.
  50010. * The light is emitted in every direction from this point.
  50011. * A good example of a point light is a standard light bulb.
  50012. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50013. */
  50014. export class PointLight extends ShadowLight {
  50015. private _shadowAngle;
  50016. /**
  50017. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50018. * This specifies what angle the shadow will use to be created.
  50019. *
  50020. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50021. */
  50022. /**
  50023. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50024. * This specifies what angle the shadow will use to be created.
  50025. *
  50026. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50027. */
  50028. shadowAngle: number;
  50029. /**
  50030. * Gets the direction if it has been set.
  50031. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50032. */
  50033. /**
  50034. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50035. */
  50036. direction: Vector3;
  50037. /**
  50038. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50039. * A PointLight emits the light in every direction.
  50040. * It can cast shadows.
  50041. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50042. * ```javascript
  50043. * var pointLight = new PointLight("pl", camera.position, scene);
  50044. * ```
  50045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50046. * @param name The light friendly name
  50047. * @param position The position of the point light in the scene
  50048. * @param scene The scene the lights belongs to
  50049. */
  50050. constructor(name: string, position: Vector3, scene: Scene);
  50051. /**
  50052. * Returns the string "PointLight"
  50053. * @returns the class name
  50054. */
  50055. getClassName(): string;
  50056. /**
  50057. * Returns the integer 0.
  50058. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50059. */
  50060. getTypeID(): number;
  50061. /**
  50062. * Specifies wether or not the shadowmap should be a cube texture.
  50063. * @returns true if the shadowmap needs to be a cube texture.
  50064. */
  50065. needCube(): boolean;
  50066. /**
  50067. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50068. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50069. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50070. */
  50071. getShadowDirection(faceIndex?: number): Vector3;
  50072. /**
  50073. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50074. * - fov = PI / 2
  50075. * - aspect ratio : 1.0
  50076. * - z-near and far equal to the active camera minZ and maxZ.
  50077. * Returns the PointLight.
  50078. */
  50079. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50080. protected _buildUniformLayout(): void;
  50081. /**
  50082. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50083. * @param effect The effect to update
  50084. * @param lightIndex The index of the light in the effect to update
  50085. * @returns The point light
  50086. */
  50087. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50088. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50089. /**
  50090. * Prepares the list of defines specific to the light type.
  50091. * @param defines the list of defines
  50092. * @param lightIndex defines the index of the light for the effect
  50093. */
  50094. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50095. }
  50096. }
  50097. declare module BABYLON {
  50098. /**
  50099. * Header information of HDR texture files.
  50100. */
  50101. export interface HDRInfo {
  50102. /**
  50103. * The height of the texture in pixels.
  50104. */
  50105. height: number;
  50106. /**
  50107. * The width of the texture in pixels.
  50108. */
  50109. width: number;
  50110. /**
  50111. * The index of the beginning of the data in the binary file.
  50112. */
  50113. dataPosition: number;
  50114. }
  50115. /**
  50116. * This groups tools to convert HDR texture to native colors array.
  50117. */
  50118. export class HDRTools {
  50119. private static Ldexp;
  50120. private static Rgbe2float;
  50121. private static readStringLine;
  50122. /**
  50123. * Reads header information from an RGBE texture stored in a native array.
  50124. * More information on this format are available here:
  50125. * https://en.wikipedia.org/wiki/RGBE_image_format
  50126. *
  50127. * @param uint8array The binary file stored in native array.
  50128. * @return The header information.
  50129. */
  50130. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50131. /**
  50132. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50133. * This RGBE texture needs to store the information as a panorama.
  50134. *
  50135. * More information on this format are available here:
  50136. * https://en.wikipedia.org/wiki/RGBE_image_format
  50137. *
  50138. * @param buffer The binary file stored in an array buffer.
  50139. * @param size The expected size of the extracted cubemap.
  50140. * @return The Cube Map information.
  50141. */
  50142. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50143. /**
  50144. * Returns the pixels data extracted from an RGBE texture.
  50145. * This pixels will be stored left to right up to down in the R G B order in one array.
  50146. *
  50147. * More information on this format are available here:
  50148. * https://en.wikipedia.org/wiki/RGBE_image_format
  50149. *
  50150. * @param uint8array The binary file stored in an array buffer.
  50151. * @param hdrInfo The header information of the file.
  50152. * @return The pixels data in RGB right to left up to down order.
  50153. */
  50154. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50155. private static RGBE_ReadPixels_RLE;
  50156. }
  50157. }
  50158. declare module BABYLON {
  50159. /**
  50160. * This represents a texture coming from an HDR input.
  50161. *
  50162. * The only supported format is currently panorama picture stored in RGBE format.
  50163. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50164. */
  50165. export class HDRCubeTexture extends BaseTexture {
  50166. private static _facesMapping;
  50167. private _generateHarmonics;
  50168. private _noMipmap;
  50169. private _textureMatrix;
  50170. private _size;
  50171. private _onLoad;
  50172. private _onError;
  50173. /**
  50174. * The texture URL.
  50175. */
  50176. url: string;
  50177. /**
  50178. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50179. */
  50180. coordinatesMode: number;
  50181. protected _isBlocking: boolean;
  50182. /**
  50183. * Sets wether or not the texture is blocking during loading.
  50184. */
  50185. /**
  50186. * Gets wether or not the texture is blocking during loading.
  50187. */
  50188. isBlocking: boolean;
  50189. protected _rotationY: number;
  50190. /**
  50191. * Sets texture matrix rotation angle around Y axis in radians.
  50192. */
  50193. /**
  50194. * Gets texture matrix rotation angle around Y axis radians.
  50195. */
  50196. rotationY: number;
  50197. /**
  50198. * Gets or sets the center of the bounding box associated with the cube texture
  50199. * It must define where the camera used to render the texture was set
  50200. */
  50201. boundingBoxPosition: Vector3;
  50202. private _boundingBoxSize;
  50203. /**
  50204. * Gets or sets the size of the bounding box associated with the cube texture
  50205. * When defined, the cubemap will switch to local mode
  50206. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50207. * @example https://www.babylonjs-playground.com/#RNASML
  50208. */
  50209. boundingBoxSize: Vector3;
  50210. /**
  50211. * Instantiates an HDRTexture from the following parameters.
  50212. *
  50213. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50214. * @param scene The scene the texture will be used in
  50215. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50216. * @param noMipmap Forces to not generate the mipmap if true
  50217. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50218. * @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)
  50219. * @param reserved Reserved flag for internal use.
  50220. */
  50221. 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>);
  50222. /**
  50223. * Get the current class name of the texture useful for serialization or dynamic coding.
  50224. * @returns "HDRCubeTexture"
  50225. */
  50226. getClassName(): string;
  50227. /**
  50228. * Occurs when the file is raw .hdr file.
  50229. */
  50230. private loadTexture;
  50231. clone(): HDRCubeTexture;
  50232. delayLoad(): void;
  50233. /**
  50234. * Get the texture reflection matrix used to rotate/transform the reflection.
  50235. * @returns the reflection matrix
  50236. */
  50237. getReflectionTextureMatrix(): Matrix;
  50238. /**
  50239. * Set the texture reflection matrix used to rotate/transform the reflection.
  50240. * @param value Define the reflection matrix to set
  50241. */
  50242. setReflectionTextureMatrix(value: Matrix): void;
  50243. /**
  50244. * Parses a JSON representation of an HDR Texture in order to create the texture
  50245. * @param parsedTexture Define the JSON representation
  50246. * @param scene Define the scene the texture should be created in
  50247. * @param rootUrl Define the root url in case we need to load relative dependencies
  50248. * @returns the newly created texture after parsing
  50249. */
  50250. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50251. serialize(): any;
  50252. }
  50253. }
  50254. declare module BABYLON {
  50255. /**
  50256. * Class used to control physics engine
  50257. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50258. */
  50259. export class PhysicsEngine implements IPhysicsEngine {
  50260. private _physicsPlugin;
  50261. /**
  50262. * Global value used to control the smallest number supported by the simulation
  50263. */
  50264. static Epsilon: number;
  50265. private _impostors;
  50266. private _joints;
  50267. /**
  50268. * Gets the gravity vector used by the simulation
  50269. */
  50270. gravity: Vector3;
  50271. /**
  50272. * Factory used to create the default physics plugin.
  50273. * @returns The default physics plugin
  50274. */
  50275. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50276. /**
  50277. * Creates a new Physics Engine
  50278. * @param gravity defines the gravity vector used by the simulation
  50279. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50280. */
  50281. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50282. /**
  50283. * Sets the gravity vector used by the simulation
  50284. * @param gravity defines the gravity vector to use
  50285. */
  50286. setGravity(gravity: Vector3): void;
  50287. /**
  50288. * Set the time step of the physics engine.
  50289. * Default is 1/60.
  50290. * To slow it down, enter 1/600 for example.
  50291. * To speed it up, 1/30
  50292. * @param newTimeStep defines the new timestep to apply to this world.
  50293. */
  50294. setTimeStep(newTimeStep?: number): void;
  50295. /**
  50296. * Get the time step of the physics engine.
  50297. * @returns the current time step
  50298. */
  50299. getTimeStep(): number;
  50300. /**
  50301. * Release all resources
  50302. */
  50303. dispose(): void;
  50304. /**
  50305. * Gets the name of the current physics plugin
  50306. * @returns the name of the plugin
  50307. */
  50308. getPhysicsPluginName(): string;
  50309. /**
  50310. * Adding a new impostor for the impostor tracking.
  50311. * This will be done by the impostor itself.
  50312. * @param impostor the impostor to add
  50313. */
  50314. addImpostor(impostor: PhysicsImpostor): void;
  50315. /**
  50316. * Remove an impostor from the engine.
  50317. * This impostor and its mesh will not longer be updated by the physics engine.
  50318. * @param impostor the impostor to remove
  50319. */
  50320. removeImpostor(impostor: PhysicsImpostor): void;
  50321. /**
  50322. * Add a joint to the physics engine
  50323. * @param mainImpostor defines the main impostor to which the joint is added.
  50324. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50325. * @param joint defines the joint that will connect both impostors.
  50326. */
  50327. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50328. /**
  50329. * Removes a joint from the simulation
  50330. * @param mainImpostor defines the impostor used with the joint
  50331. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50332. * @param joint defines the joint to remove
  50333. */
  50334. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50335. /**
  50336. * Called by the scene. No need to call it.
  50337. * @param delta defines the timespam between frames
  50338. */
  50339. _step(delta: number): void;
  50340. /**
  50341. * Gets the current plugin used to run the simulation
  50342. * @returns current plugin
  50343. */
  50344. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50345. /**
  50346. * Gets the list of physic impostors
  50347. * @returns an array of PhysicsImpostor
  50348. */
  50349. getImpostors(): Array<PhysicsImpostor>;
  50350. /**
  50351. * Gets the impostor for a physics enabled object
  50352. * @param object defines the object impersonated by the impostor
  50353. * @returns the PhysicsImpostor or null if not found
  50354. */
  50355. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50356. /**
  50357. * Gets the impostor for a physics body object
  50358. * @param body defines physics body used by the impostor
  50359. * @returns the PhysicsImpostor or null if not found
  50360. */
  50361. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50362. /**
  50363. * Does a raycast in the physics world
  50364. * @param from when should the ray start?
  50365. * @param to when should the ray end?
  50366. * @returns PhysicsRaycastResult
  50367. */
  50368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50369. }
  50370. }
  50371. declare module BABYLON {
  50372. /** @hidden */
  50373. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50374. private _useDeltaForWorldStep;
  50375. world: any;
  50376. name: string;
  50377. private _physicsMaterials;
  50378. private _fixedTimeStep;
  50379. private _cannonRaycastResult;
  50380. private _raycastResult;
  50381. private _physicsBodysToRemoveAfterStep;
  50382. BJSCANNON: any;
  50383. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50384. setGravity(gravity: Vector3): void;
  50385. setTimeStep(timeStep: number): void;
  50386. getTimeStep(): number;
  50387. executeStep(delta: number): void;
  50388. private _removeMarkedPhysicsBodiesFromWorld;
  50389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50392. private _processChildMeshes;
  50393. removePhysicsBody(impostor: PhysicsImpostor): void;
  50394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50396. private _addMaterial;
  50397. private _checkWithEpsilon;
  50398. private _createShape;
  50399. private _createHeightmap;
  50400. private _minus90X;
  50401. private _plus90X;
  50402. private _tmpPosition;
  50403. private _tmpDeltaPosition;
  50404. private _tmpUnityRotation;
  50405. private _updatePhysicsBodyTransformation;
  50406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50408. isSupported(): boolean;
  50409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50411. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50414. getBodyMass(impostor: PhysicsImpostor): number;
  50415. getBodyFriction(impostor: PhysicsImpostor): number;
  50416. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50417. getBodyRestitution(impostor: PhysicsImpostor): number;
  50418. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50419. sleepBody(impostor: PhysicsImpostor): void;
  50420. wakeUpBody(impostor: PhysicsImpostor): void;
  50421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50422. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50425. getRadius(impostor: PhysicsImpostor): number;
  50426. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50427. dispose(): void;
  50428. private _extendNamespace;
  50429. /**
  50430. * Does a raycast in the physics world
  50431. * @param from when should the ray start?
  50432. * @param to when should the ray end?
  50433. * @returns PhysicsRaycastResult
  50434. */
  50435. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50436. }
  50437. }
  50438. declare module BABYLON {
  50439. /** @hidden */
  50440. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50441. world: any;
  50442. name: string;
  50443. BJSOIMO: any;
  50444. private _raycastResult;
  50445. constructor(iterations?: number, oimoInjection?: any);
  50446. setGravity(gravity: Vector3): void;
  50447. setTimeStep(timeStep: number): void;
  50448. getTimeStep(): number;
  50449. private _tmpImpostorsArray;
  50450. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50451. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50452. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50453. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50454. private _tmpPositionVector;
  50455. removePhysicsBody(impostor: PhysicsImpostor): void;
  50456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50457. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50458. isSupported(): boolean;
  50459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50460. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50461. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50462. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50463. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50464. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50465. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50466. getBodyMass(impostor: PhysicsImpostor): number;
  50467. getBodyFriction(impostor: PhysicsImpostor): number;
  50468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50469. getBodyRestitution(impostor: PhysicsImpostor): number;
  50470. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50471. sleepBody(impostor: PhysicsImpostor): void;
  50472. wakeUpBody(impostor: PhysicsImpostor): void;
  50473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50474. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50476. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50477. getRadius(impostor: PhysicsImpostor): number;
  50478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50479. dispose(): void;
  50480. /**
  50481. * Does a raycast in the physics world
  50482. * @param from when should the ray start?
  50483. * @param to when should the ray end?
  50484. * @returns PhysicsRaycastResult
  50485. */
  50486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50487. }
  50488. }
  50489. declare module BABYLON {
  50490. /**
  50491. * Class containing static functions to help procedurally build meshes
  50492. */
  50493. export class RibbonBuilder {
  50494. /**
  50495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50499. * * 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
  50500. * * 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
  50501. * * 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
  50502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50503. * * 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
  50504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50505. * * 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
  50506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50507. * * 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
  50508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50510. * @param name defines the name of the mesh
  50511. * @param options defines the options used to create the mesh
  50512. * @param scene defines the hosting scene
  50513. * @returns the ribbon mesh
  50514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50516. */
  50517. static CreateRibbon(name: string, options: {
  50518. pathArray: Vector3[][];
  50519. closeArray?: boolean;
  50520. closePath?: boolean;
  50521. offset?: number;
  50522. updatable?: boolean;
  50523. sideOrientation?: number;
  50524. frontUVs?: Vector4;
  50525. backUVs?: Vector4;
  50526. instance?: Mesh;
  50527. invertUV?: boolean;
  50528. uvs?: Vector2[];
  50529. colors?: Color4[];
  50530. }, scene?: Nullable<Scene>): Mesh;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * Class containing static functions to help procedurally build meshes
  50536. */
  50537. export class ShapeBuilder {
  50538. /**
  50539. * 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.
  50540. * * 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.
  50541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50542. * * 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.
  50543. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50544. * * 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
  50545. * * 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
  50546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50548. * * 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
  50549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50551. * @param name defines the name of the mesh
  50552. * @param options defines the options used to create the mesh
  50553. * @param scene defines the hosting scene
  50554. * @returns the extruded shape mesh
  50555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50557. */
  50558. static ExtrudeShape(name: string, options: {
  50559. shape: Vector3[];
  50560. path: Vector3[];
  50561. scale?: number;
  50562. rotation?: number;
  50563. cap?: number;
  50564. updatable?: boolean;
  50565. sideOrientation?: number;
  50566. frontUVs?: Vector4;
  50567. backUVs?: Vector4;
  50568. instance?: Mesh;
  50569. invertUV?: boolean;
  50570. }, scene?: Nullable<Scene>): Mesh;
  50571. /**
  50572. * Creates an custom extruded shape mesh.
  50573. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50574. * * 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.
  50575. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50576. * * 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
  50577. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50578. * * 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
  50579. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50580. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50581. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50582. * * 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
  50583. * * 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
  50584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50586. * * 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
  50587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50589. * @param name defines the name of the mesh
  50590. * @param options defines the options used to create the mesh
  50591. * @param scene defines the hosting scene
  50592. * @returns the custom extruded shape mesh
  50593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50596. */
  50597. static ExtrudeShapeCustom(name: string, options: {
  50598. shape: Vector3[];
  50599. path: Vector3[];
  50600. scaleFunction?: any;
  50601. rotationFunction?: any;
  50602. ribbonCloseArray?: boolean;
  50603. ribbonClosePath?: boolean;
  50604. cap?: number;
  50605. updatable?: boolean;
  50606. sideOrientation?: number;
  50607. frontUVs?: Vector4;
  50608. backUVs?: Vector4;
  50609. instance?: Mesh;
  50610. invertUV?: boolean;
  50611. }, scene?: Nullable<Scene>): Mesh;
  50612. private static _ExtrudeShapeGeneric;
  50613. }
  50614. }
  50615. declare module BABYLON {
  50616. /**
  50617. * AmmoJS Physics plugin
  50618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50619. * @see https://github.com/kripken/ammo.js/
  50620. */
  50621. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50622. private _useDeltaForWorldStep;
  50623. /**
  50624. * Reference to the Ammo library
  50625. */
  50626. bjsAMMO: any;
  50627. /**
  50628. * Created ammoJS world which physics bodies are added to
  50629. */
  50630. world: any;
  50631. /**
  50632. * Name of the plugin
  50633. */
  50634. name: string;
  50635. private _timeStep;
  50636. private _fixedTimeStep;
  50637. private _maxSteps;
  50638. private _tmpQuaternion;
  50639. private _tmpAmmoTransform;
  50640. private _tmpAmmoQuaternion;
  50641. private _tmpAmmoConcreteContactResultCallback;
  50642. private _collisionConfiguration;
  50643. private _dispatcher;
  50644. private _overlappingPairCache;
  50645. private _solver;
  50646. private _softBodySolver;
  50647. private _tmpAmmoVectorA;
  50648. private _tmpAmmoVectorB;
  50649. private _tmpAmmoVectorC;
  50650. private _tmpAmmoVectorD;
  50651. private _tmpContactCallbackResult;
  50652. private _tmpAmmoVectorRCA;
  50653. private _tmpAmmoVectorRCB;
  50654. private _raycastResult;
  50655. private static readonly DISABLE_COLLISION_FLAG;
  50656. private static readonly KINEMATIC_FLAG;
  50657. private static readonly DISABLE_DEACTIVATION_FLAG;
  50658. /**
  50659. * Initializes the ammoJS plugin
  50660. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50661. * @param ammoInjection can be used to inject your own ammo reference
  50662. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50663. */
  50664. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50665. /**
  50666. * Sets the gravity of the physics world (m/(s^2))
  50667. * @param gravity Gravity to set
  50668. */
  50669. setGravity(gravity: Vector3): void;
  50670. /**
  50671. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50672. * @param timeStep timestep to use in seconds
  50673. */
  50674. setTimeStep(timeStep: number): void;
  50675. /**
  50676. * 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)
  50677. * @param fixedTimeStep fixedTimeStep to use in seconds
  50678. */
  50679. setFixedTimeStep(fixedTimeStep: number): void;
  50680. /**
  50681. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50682. * @param maxSteps the maximum number of steps by the physics engine per frame
  50683. */
  50684. setMaxSteps(maxSteps: number): void;
  50685. /**
  50686. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50687. * @returns the current timestep in seconds
  50688. */
  50689. getTimeStep(): number;
  50690. private _isImpostorInContact;
  50691. private _isImpostorPairInContact;
  50692. private _stepSimulation;
  50693. /**
  50694. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50695. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50696. * After the step the babylon meshes are set to the position of the physics imposters
  50697. * @param delta amount of time to step forward
  50698. * @param impostors array of imposters to update before/after the step
  50699. */
  50700. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50701. /**
  50702. * Update babylon mesh to match physics world object
  50703. * @param impostor imposter to match
  50704. */
  50705. private _afterSoftStep;
  50706. /**
  50707. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50708. * @param impostor imposter to match
  50709. */
  50710. private _ropeStep;
  50711. /**
  50712. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50713. * @param impostor imposter to match
  50714. */
  50715. private _softbodyOrClothStep;
  50716. private _tmpVector;
  50717. private _tmpMatrix;
  50718. /**
  50719. * Applies an impulse on the imposter
  50720. * @param impostor imposter to apply impulse to
  50721. * @param force amount of force to be applied to the imposter
  50722. * @param contactPoint the location to apply the impulse on the imposter
  50723. */
  50724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50725. /**
  50726. * Applies a force on the imposter
  50727. * @param impostor imposter to apply force
  50728. * @param force amount of force to be applied to the imposter
  50729. * @param contactPoint the location to apply the force on the imposter
  50730. */
  50731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50732. /**
  50733. * Creates a physics body using the plugin
  50734. * @param impostor the imposter to create the physics body on
  50735. */
  50736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50737. /**
  50738. * Removes the physics body from the imposter and disposes of the body's memory
  50739. * @param impostor imposter to remove the physics body from
  50740. */
  50741. removePhysicsBody(impostor: PhysicsImpostor): void;
  50742. /**
  50743. * Generates a joint
  50744. * @param impostorJoint the imposter joint to create the joint with
  50745. */
  50746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50747. /**
  50748. * Removes a joint
  50749. * @param impostorJoint the imposter joint to remove the joint from
  50750. */
  50751. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50752. private _addMeshVerts;
  50753. /**
  50754. * Initialise the soft body vertices to match its object's (mesh) vertices
  50755. * Softbody vertices (nodes) are in world space and to match this
  50756. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50757. * @param impostor to create the softbody for
  50758. */
  50759. private _softVertexData;
  50760. /**
  50761. * Create an impostor's soft body
  50762. * @param impostor to create the softbody for
  50763. */
  50764. private _createSoftbody;
  50765. /**
  50766. * Create cloth for an impostor
  50767. * @param impostor to create the softbody for
  50768. */
  50769. private _createCloth;
  50770. /**
  50771. * Create rope for an impostor
  50772. * @param impostor to create the softbody for
  50773. */
  50774. private _createRope;
  50775. private _addHullVerts;
  50776. private _createShape;
  50777. /**
  50778. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50779. * @param impostor imposter containing the physics body and babylon object
  50780. */
  50781. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50782. /**
  50783. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50784. * @param impostor imposter containing the physics body and babylon object
  50785. * @param newPosition new position
  50786. * @param newRotation new rotation
  50787. */
  50788. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50789. /**
  50790. * If this plugin is supported
  50791. * @returns true if its supported
  50792. */
  50793. isSupported(): boolean;
  50794. /**
  50795. * Sets the linear velocity of the physics body
  50796. * @param impostor imposter to set the velocity on
  50797. * @param velocity velocity to set
  50798. */
  50799. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50800. /**
  50801. * Sets the angular velocity of the physics body
  50802. * @param impostor imposter to set the velocity on
  50803. * @param velocity velocity to set
  50804. */
  50805. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50806. /**
  50807. * gets the linear velocity
  50808. * @param impostor imposter to get linear velocity from
  50809. * @returns linear velocity
  50810. */
  50811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50812. /**
  50813. * gets the angular velocity
  50814. * @param impostor imposter to get angular velocity from
  50815. * @returns angular velocity
  50816. */
  50817. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50818. /**
  50819. * Sets the mass of physics body
  50820. * @param impostor imposter to set the mass on
  50821. * @param mass mass to set
  50822. */
  50823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50824. /**
  50825. * Gets the mass of the physics body
  50826. * @param impostor imposter to get the mass from
  50827. * @returns mass
  50828. */
  50829. getBodyMass(impostor: PhysicsImpostor): number;
  50830. /**
  50831. * Gets friction of the impostor
  50832. * @param impostor impostor to get friction from
  50833. * @returns friction value
  50834. */
  50835. getBodyFriction(impostor: PhysicsImpostor): number;
  50836. /**
  50837. * Sets friction of the impostor
  50838. * @param impostor impostor to set friction on
  50839. * @param friction friction value
  50840. */
  50841. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50842. /**
  50843. * Gets restitution of the impostor
  50844. * @param impostor impostor to get restitution from
  50845. * @returns restitution value
  50846. */
  50847. getBodyRestitution(impostor: PhysicsImpostor): number;
  50848. /**
  50849. * Sets resitution of the impostor
  50850. * @param impostor impostor to set resitution on
  50851. * @param restitution resitution value
  50852. */
  50853. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50854. /**
  50855. * Gets pressure inside the impostor
  50856. * @param impostor impostor to get pressure from
  50857. * @returns pressure value
  50858. */
  50859. getBodyPressure(impostor: PhysicsImpostor): number;
  50860. /**
  50861. * Sets pressure inside a soft body impostor
  50862. * Cloth and rope must remain 0 pressure
  50863. * @param impostor impostor to set pressure on
  50864. * @param pressure pressure value
  50865. */
  50866. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50867. /**
  50868. * Gets stiffness of the impostor
  50869. * @param impostor impostor to get stiffness from
  50870. * @returns pressure value
  50871. */
  50872. getBodyStiffness(impostor: PhysicsImpostor): number;
  50873. /**
  50874. * Sets stiffness of the impostor
  50875. * @param impostor impostor to set stiffness on
  50876. * @param stiffness stiffness value from 0 to 1
  50877. */
  50878. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50879. /**
  50880. * Gets velocityIterations of the impostor
  50881. * @param impostor impostor to get velocity iterations from
  50882. * @returns velocityIterations value
  50883. */
  50884. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50885. /**
  50886. * Sets velocityIterations of the impostor
  50887. * @param impostor impostor to set velocity iterations on
  50888. * @param velocityIterations velocityIterations value
  50889. */
  50890. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50891. /**
  50892. * Gets positionIterations of the impostor
  50893. * @param impostor impostor to get position iterations from
  50894. * @returns positionIterations value
  50895. */
  50896. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50897. /**
  50898. * Sets positionIterations of the impostor
  50899. * @param impostor impostor to set position on
  50900. * @param positionIterations positionIterations value
  50901. */
  50902. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50903. /**
  50904. * Append an anchor to a cloth object
  50905. * @param impostor is the cloth impostor to add anchor to
  50906. * @param otherImpostor is the rigid impostor to anchor to
  50907. * @param width ratio across width from 0 to 1
  50908. * @param height ratio up height from 0 to 1
  50909. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50910. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50911. */
  50912. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50913. /**
  50914. * Append an hook to a rope object
  50915. * @param impostor is the rope impostor to add hook to
  50916. * @param otherImpostor is the rigid impostor to hook to
  50917. * @param length ratio along the rope from 0 to 1
  50918. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50919. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50920. */
  50921. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50922. /**
  50923. * Sleeps the physics body and stops it from being active
  50924. * @param impostor impostor to sleep
  50925. */
  50926. sleepBody(impostor: PhysicsImpostor): void;
  50927. /**
  50928. * Activates the physics body
  50929. * @param impostor impostor to activate
  50930. */
  50931. wakeUpBody(impostor: PhysicsImpostor): void;
  50932. /**
  50933. * Updates the distance parameters of the joint
  50934. * @param joint joint to update
  50935. * @param maxDistance maximum distance of the joint
  50936. * @param minDistance minimum distance of the joint
  50937. */
  50938. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50939. /**
  50940. * Sets a motor on the joint
  50941. * @param joint joint to set motor on
  50942. * @param speed speed of the motor
  50943. * @param maxForce maximum force of the motor
  50944. * @param motorIndex index of the motor
  50945. */
  50946. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50947. /**
  50948. * Sets the motors limit
  50949. * @param joint joint to set limit on
  50950. * @param upperLimit upper limit
  50951. * @param lowerLimit lower limit
  50952. */
  50953. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50954. /**
  50955. * Syncs the position and rotation of a mesh with the impostor
  50956. * @param mesh mesh to sync
  50957. * @param impostor impostor to update the mesh with
  50958. */
  50959. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50960. /**
  50961. * Gets the radius of the impostor
  50962. * @param impostor impostor to get radius from
  50963. * @returns the radius
  50964. */
  50965. getRadius(impostor: PhysicsImpostor): number;
  50966. /**
  50967. * Gets the box size of the impostor
  50968. * @param impostor impostor to get box size from
  50969. * @param result the resulting box size
  50970. */
  50971. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50972. /**
  50973. * Disposes of the impostor
  50974. */
  50975. dispose(): void;
  50976. /**
  50977. * Does a raycast in the physics world
  50978. * @param from when should the ray start?
  50979. * @param to when should the ray end?
  50980. * @returns PhysicsRaycastResult
  50981. */
  50982. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50983. }
  50984. }
  50985. declare module BABYLON {
  50986. interface AbstractScene {
  50987. /**
  50988. * The list of reflection probes added to the scene
  50989. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50990. */
  50991. reflectionProbes: Array<ReflectionProbe>;
  50992. /**
  50993. * Removes the given reflection probe from this scene.
  50994. * @param toRemove The reflection probe to remove
  50995. * @returns The index of the removed reflection probe
  50996. */
  50997. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50998. /**
  50999. * Adds the given reflection probe to this scene.
  51000. * @param newReflectionProbe The reflection probe to add
  51001. */
  51002. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51003. }
  51004. /**
  51005. * Class used to generate realtime reflection / refraction cube textures
  51006. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51007. */
  51008. export class ReflectionProbe {
  51009. /** defines the name of the probe */
  51010. name: string;
  51011. private _scene;
  51012. private _renderTargetTexture;
  51013. private _projectionMatrix;
  51014. private _viewMatrix;
  51015. private _target;
  51016. private _add;
  51017. private _attachedMesh;
  51018. private _invertYAxis;
  51019. /** Gets or sets probe position (center of the cube map) */
  51020. position: Vector3;
  51021. /**
  51022. * Creates a new reflection probe
  51023. * @param name defines the name of the probe
  51024. * @param size defines the texture resolution (for each face)
  51025. * @param scene defines the hosting scene
  51026. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51027. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51028. */
  51029. constructor(
  51030. /** defines the name of the probe */
  51031. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51032. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51033. samples: number;
  51034. /** Gets or sets the refresh rate to use (on every frame by default) */
  51035. refreshRate: number;
  51036. /**
  51037. * Gets the hosting scene
  51038. * @returns a Scene
  51039. */
  51040. getScene(): Scene;
  51041. /** Gets the internal CubeTexture used to render to */
  51042. readonly cubeTexture: RenderTargetTexture;
  51043. /** Gets the list of meshes to render */
  51044. readonly renderList: Nullable<AbstractMesh[]>;
  51045. /**
  51046. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51047. * @param mesh defines the mesh to attach to
  51048. */
  51049. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51050. /**
  51051. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51052. * @param renderingGroupId The rendering group id corresponding to its index
  51053. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51054. */
  51055. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51056. /**
  51057. * Clean all associated resources
  51058. */
  51059. dispose(): void;
  51060. /**
  51061. * Converts the reflection probe information to a readable string for debug purpose.
  51062. * @param fullDetails Supports for multiple levels of logging within scene loading
  51063. * @returns the human readable reflection probe info
  51064. */
  51065. toString(fullDetails?: boolean): string;
  51066. /**
  51067. * Get the class name of the relfection probe.
  51068. * @returns "ReflectionProbe"
  51069. */
  51070. getClassName(): string;
  51071. /**
  51072. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51073. * @returns The JSON representation of the texture
  51074. */
  51075. serialize(): any;
  51076. /**
  51077. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51078. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51079. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51080. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51081. * @returns The parsed reflection probe if successful
  51082. */
  51083. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51084. }
  51085. }
  51086. declare module BABYLON {
  51087. /** @hidden */
  51088. export var _BabylonLoaderRegistered: boolean;
  51089. }
  51090. declare module BABYLON {
  51091. /**
  51092. * The Physically based simple base material of BJS.
  51093. *
  51094. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51095. * It is used as the base class for both the specGloss and metalRough conventions.
  51096. */
  51097. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51098. /**
  51099. * Number of Simultaneous lights allowed on the material.
  51100. */
  51101. maxSimultaneousLights: number;
  51102. /**
  51103. * If sets to true, disables all the lights affecting the material.
  51104. */
  51105. disableLighting: boolean;
  51106. /**
  51107. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51108. */
  51109. environmentTexture: BaseTexture;
  51110. /**
  51111. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51112. */
  51113. invertNormalMapX: boolean;
  51114. /**
  51115. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51116. */
  51117. invertNormalMapY: boolean;
  51118. /**
  51119. * Normal map used in the model.
  51120. */
  51121. normalTexture: BaseTexture;
  51122. /**
  51123. * Emissivie color used to self-illuminate the model.
  51124. */
  51125. emissiveColor: Color3;
  51126. /**
  51127. * Emissivie texture used to self-illuminate the model.
  51128. */
  51129. emissiveTexture: BaseTexture;
  51130. /**
  51131. * Occlusion Channel Strenght.
  51132. */
  51133. occlusionStrength: number;
  51134. /**
  51135. * Occlusion Texture of the material (adding extra occlusion effects).
  51136. */
  51137. occlusionTexture: BaseTexture;
  51138. /**
  51139. * Defines the alpha limits in alpha test mode.
  51140. */
  51141. alphaCutOff: number;
  51142. /**
  51143. * Gets the current double sided mode.
  51144. */
  51145. /**
  51146. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51147. */
  51148. doubleSided: boolean;
  51149. /**
  51150. * Stores the pre-calculated light information of a mesh in a texture.
  51151. */
  51152. lightmapTexture: BaseTexture;
  51153. /**
  51154. * If true, the light map contains occlusion information instead of lighting info.
  51155. */
  51156. useLightmapAsShadowmap: boolean;
  51157. /**
  51158. * Instantiates a new PBRMaterial instance.
  51159. *
  51160. * @param name The material name
  51161. * @param scene The scene the material will be use in.
  51162. */
  51163. constructor(name: string, scene: Scene);
  51164. getClassName(): string;
  51165. }
  51166. }
  51167. declare module BABYLON {
  51168. /**
  51169. * The PBR material of BJS following the metal roughness convention.
  51170. *
  51171. * This fits to the PBR convention in the GLTF definition:
  51172. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51173. */
  51174. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51175. /**
  51176. * The base color has two different interpretations depending on the value of metalness.
  51177. * When the material is a metal, the base color is the specific measured reflectance value
  51178. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51179. * of the material.
  51180. */
  51181. baseColor: Color3;
  51182. /**
  51183. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51184. * well as opacity information in the alpha channel.
  51185. */
  51186. baseTexture: BaseTexture;
  51187. /**
  51188. * Specifies the metallic scalar value of the material.
  51189. * Can also be used to scale the metalness values of the metallic texture.
  51190. */
  51191. metallic: number;
  51192. /**
  51193. * Specifies the roughness scalar value of the material.
  51194. * Can also be used to scale the roughness values of the metallic texture.
  51195. */
  51196. roughness: number;
  51197. /**
  51198. * Texture containing both the metallic value in the B channel and the
  51199. * roughness value in the G channel to keep better precision.
  51200. */
  51201. metallicRoughnessTexture: BaseTexture;
  51202. /**
  51203. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51204. *
  51205. * @param name The material name
  51206. * @param scene The scene the material will be use in.
  51207. */
  51208. constructor(name: string, scene: Scene);
  51209. /**
  51210. * Return the currrent class name of the material.
  51211. */
  51212. getClassName(): string;
  51213. /**
  51214. * Makes a duplicate of the current material.
  51215. * @param name - name to use for the new material.
  51216. */
  51217. clone(name: string): PBRMetallicRoughnessMaterial;
  51218. /**
  51219. * Serialize the material to a parsable JSON object.
  51220. */
  51221. serialize(): any;
  51222. /**
  51223. * Parses a JSON object correponding to the serialize function.
  51224. */
  51225. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51226. }
  51227. }
  51228. declare module BABYLON {
  51229. /**
  51230. * The PBR material of BJS following the specular glossiness convention.
  51231. *
  51232. * This fits to the PBR convention in the GLTF definition:
  51233. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51234. */
  51235. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51236. /**
  51237. * Specifies the diffuse color of the material.
  51238. */
  51239. diffuseColor: Color3;
  51240. /**
  51241. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51242. * channel.
  51243. */
  51244. diffuseTexture: BaseTexture;
  51245. /**
  51246. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51247. */
  51248. specularColor: Color3;
  51249. /**
  51250. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51251. */
  51252. glossiness: number;
  51253. /**
  51254. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51255. */
  51256. specularGlossinessTexture: BaseTexture;
  51257. /**
  51258. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51259. *
  51260. * @param name The material name
  51261. * @param scene The scene the material will be use in.
  51262. */
  51263. constructor(name: string, scene: Scene);
  51264. /**
  51265. * Return the currrent class name of the material.
  51266. */
  51267. getClassName(): string;
  51268. /**
  51269. * Makes a duplicate of the current material.
  51270. * @param name - name to use for the new material.
  51271. */
  51272. clone(name: string): PBRSpecularGlossinessMaterial;
  51273. /**
  51274. * Serialize the material to a parsable JSON object.
  51275. */
  51276. serialize(): any;
  51277. /**
  51278. * Parses a JSON object correponding to the serialize function.
  51279. */
  51280. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51281. }
  51282. }
  51283. declare module BABYLON {
  51284. /**
  51285. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51286. * It can help converting any input color in a desired output one. This can then be used to create effects
  51287. * from sepia, black and white to sixties or futuristic rendering...
  51288. *
  51289. * The only supported format is currently 3dl.
  51290. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51291. */
  51292. export class ColorGradingTexture extends BaseTexture {
  51293. /**
  51294. * The current texture matrix. (will always be identity in color grading texture)
  51295. */
  51296. private _textureMatrix;
  51297. /**
  51298. * The texture URL.
  51299. */
  51300. url: string;
  51301. /**
  51302. * Empty line regex stored for GC.
  51303. */
  51304. private static _noneEmptyLineRegex;
  51305. private _engine;
  51306. /**
  51307. * Instantiates a ColorGradingTexture from the following parameters.
  51308. *
  51309. * @param url The location of the color gradind data (currently only supporting 3dl)
  51310. * @param scene The scene the texture will be used in
  51311. */
  51312. constructor(url: string, scene: Scene);
  51313. /**
  51314. * Returns the texture matrix used in most of the material.
  51315. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51316. */
  51317. getTextureMatrix(): Matrix;
  51318. /**
  51319. * Occurs when the file being loaded is a .3dl LUT file.
  51320. */
  51321. private load3dlTexture;
  51322. /**
  51323. * Starts the loading process of the texture.
  51324. */
  51325. private loadTexture;
  51326. /**
  51327. * Clones the color gradind texture.
  51328. */
  51329. clone(): ColorGradingTexture;
  51330. /**
  51331. * Called during delayed load for textures.
  51332. */
  51333. delayLoad(): void;
  51334. /**
  51335. * Parses a color grading texture serialized by Babylon.
  51336. * @param parsedTexture The texture information being parsedTexture
  51337. * @param scene The scene to load the texture in
  51338. * @param rootUrl The root url of the data assets to load
  51339. * @return A color gradind texture
  51340. */
  51341. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51342. /**
  51343. * Serializes the LUT texture to json format.
  51344. */
  51345. serialize(): any;
  51346. }
  51347. }
  51348. declare module BABYLON {
  51349. /**
  51350. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51351. */
  51352. export class EquiRectangularCubeTexture extends BaseTexture {
  51353. /** The six faces of the cube. */
  51354. private static _FacesMapping;
  51355. private _noMipmap;
  51356. private _onLoad;
  51357. private _onError;
  51358. /** The size of the cubemap. */
  51359. private _size;
  51360. /** The buffer of the image. */
  51361. private _buffer;
  51362. /** The width of the input image. */
  51363. private _width;
  51364. /** The height of the input image. */
  51365. private _height;
  51366. /** The URL to the image. */
  51367. url: string;
  51368. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51369. coordinatesMode: number;
  51370. /**
  51371. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51372. * @param url The location of the image
  51373. * @param scene The scene the texture will be used in
  51374. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51375. * @param noMipmap Forces to not generate the mipmap if true
  51376. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51377. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51378. * @param onLoad — defines a callback called when texture is loaded
  51379. * @param onError — defines a callback called if there is an error
  51380. */
  51381. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51382. /**
  51383. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51384. */
  51385. private loadImage;
  51386. /**
  51387. * Convert the image buffer into a cubemap and create a CubeTexture.
  51388. */
  51389. private loadTexture;
  51390. /**
  51391. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51392. * @param buffer The ArrayBuffer that should be converted.
  51393. * @returns The buffer as Float32Array.
  51394. */
  51395. private getFloat32ArrayFromArrayBuffer;
  51396. /**
  51397. * Get the current class name of the texture useful for serialization or dynamic coding.
  51398. * @returns "EquiRectangularCubeTexture"
  51399. */
  51400. getClassName(): string;
  51401. /**
  51402. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51403. * @returns A clone of the current EquiRectangularCubeTexture.
  51404. */
  51405. clone(): EquiRectangularCubeTexture;
  51406. }
  51407. }
  51408. declare module BABYLON {
  51409. /**
  51410. * Based on jsTGALoader - Javascript loader for TGA file
  51411. * By Vincent Thibault
  51412. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51413. */
  51414. export class TGATools {
  51415. private static _TYPE_INDEXED;
  51416. private static _TYPE_RGB;
  51417. private static _TYPE_GREY;
  51418. private static _TYPE_RLE_INDEXED;
  51419. private static _TYPE_RLE_RGB;
  51420. private static _TYPE_RLE_GREY;
  51421. private static _ORIGIN_MASK;
  51422. private static _ORIGIN_SHIFT;
  51423. private static _ORIGIN_BL;
  51424. private static _ORIGIN_BR;
  51425. private static _ORIGIN_UL;
  51426. private static _ORIGIN_UR;
  51427. /**
  51428. * Gets the header of a TGA file
  51429. * @param data defines the TGA data
  51430. * @returns the header
  51431. */
  51432. static GetTGAHeader(data: Uint8Array): any;
  51433. /**
  51434. * Uploads TGA content to a Babylon Texture
  51435. * @hidden
  51436. */
  51437. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51438. /** @hidden */
  51439. 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;
  51440. /** @hidden */
  51441. 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;
  51442. /** @hidden */
  51443. 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;
  51444. /** @hidden */
  51445. 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;
  51446. /** @hidden */
  51447. 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;
  51448. /** @hidden */
  51449. 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;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * Implementation of the TGA Texture Loader.
  51455. * @hidden
  51456. */
  51457. export class _TGATextureLoader implements IInternalTextureLoader {
  51458. /**
  51459. * Defines wether the loader supports cascade loading the different faces.
  51460. */
  51461. readonly supportCascades: boolean;
  51462. /**
  51463. * This returns if the loader support the current file information.
  51464. * @param extension defines the file extension of the file being loaded
  51465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51466. * @param fallback defines the fallback internal texture if any
  51467. * @param isBase64 defines whether the texture is encoded as a base64
  51468. * @param isBuffer defines whether the texture data are stored as a buffer
  51469. * @returns true if the loader can load the specified file
  51470. */
  51471. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51472. /**
  51473. * Transform the url before loading if required.
  51474. * @param rootUrl the url of the texture
  51475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51476. * @returns the transformed texture
  51477. */
  51478. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51479. /**
  51480. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51481. * @param rootUrl the url of the texture
  51482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51483. * @returns the fallback texture
  51484. */
  51485. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51486. /**
  51487. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51488. * @param data contains the texture data
  51489. * @param texture defines the BabylonJS internal texture
  51490. * @param createPolynomials will be true if polynomials have been requested
  51491. * @param onLoad defines the callback to trigger once the texture is ready
  51492. * @param onError defines the callback to trigger in case of error
  51493. */
  51494. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51495. /**
  51496. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51497. * @param data contains the texture data
  51498. * @param texture defines the BabylonJS internal texture
  51499. * @param callback defines the method to call once ready to upload
  51500. */
  51501. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51502. }
  51503. }
  51504. declare module BABYLON {
  51505. /**
  51506. * Info about the .basis files
  51507. */
  51508. class BasisFileInfo {
  51509. /**
  51510. * If the file has alpha
  51511. */
  51512. hasAlpha: boolean;
  51513. /**
  51514. * Info about each image of the basis file
  51515. */
  51516. images: Array<{
  51517. levels: Array<{
  51518. width: number;
  51519. height: number;
  51520. transcodedPixels: ArrayBufferView;
  51521. }>;
  51522. }>;
  51523. }
  51524. /**
  51525. * Result of transcoding a basis file
  51526. */
  51527. class TranscodeResult {
  51528. /**
  51529. * Info about the .basis file
  51530. */
  51531. fileInfo: BasisFileInfo;
  51532. /**
  51533. * Format to use when loading the file
  51534. */
  51535. format: number;
  51536. }
  51537. /**
  51538. * Configuration options for the Basis transcoder
  51539. */
  51540. export class BasisTranscodeConfiguration {
  51541. /**
  51542. * Supported compression formats used to determine the supported output format of the transcoder
  51543. */
  51544. supportedCompressionFormats?: {
  51545. /**
  51546. * etc1 compression format
  51547. */
  51548. etc1?: boolean;
  51549. /**
  51550. * s3tc compression format
  51551. */
  51552. s3tc?: boolean;
  51553. /**
  51554. * pvrtc compression format
  51555. */
  51556. pvrtc?: boolean;
  51557. /**
  51558. * etc2 compression format
  51559. */
  51560. etc2?: boolean;
  51561. };
  51562. /**
  51563. * If mipmap levels should be loaded for transcoded images (Default: true)
  51564. */
  51565. loadMipmapLevels?: boolean;
  51566. /**
  51567. * Index of a single image to load (Default: all images)
  51568. */
  51569. loadSingleImage?: number;
  51570. }
  51571. /**
  51572. * Used to load .Basis files
  51573. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51574. */
  51575. export class BasisTools {
  51576. private static _IgnoreSupportedFormats;
  51577. /**
  51578. * URL to use when loading the basis transcoder
  51579. */
  51580. static JSModuleURL: string;
  51581. /**
  51582. * URL to use when loading the wasm module for the transcoder
  51583. */
  51584. static WasmModuleURL: string;
  51585. /**
  51586. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51587. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51588. * @returns internal format corresponding to the Basis format
  51589. */
  51590. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51591. private static _WorkerPromise;
  51592. private static _Worker;
  51593. private static _actionId;
  51594. private static _CreateWorkerAsync;
  51595. /**
  51596. * Transcodes a loaded image file to compressed pixel data
  51597. * @param imageData image data to transcode
  51598. * @param config configuration options for the transcoding
  51599. * @returns a promise resulting in the transcoded image
  51600. */
  51601. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51602. /**
  51603. * Loads a texture from the transcode result
  51604. * @param texture texture load to
  51605. * @param transcodeResult the result of transcoding the basis file to load from
  51606. */
  51607. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51608. }
  51609. }
  51610. declare module BABYLON {
  51611. /**
  51612. * Loader for .basis file format
  51613. */
  51614. export class _BasisTextureLoader implements IInternalTextureLoader {
  51615. /**
  51616. * Defines whether the loader supports cascade loading the different faces.
  51617. */
  51618. readonly supportCascades: boolean;
  51619. /**
  51620. * This returns if the loader support the current file information.
  51621. * @param extension defines the file extension of the file being loaded
  51622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51623. * @param fallback defines the fallback internal texture if any
  51624. * @param isBase64 defines whether the texture is encoded as a base64
  51625. * @param isBuffer defines whether the texture data are stored as a buffer
  51626. * @returns true if the loader can load the specified file
  51627. */
  51628. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51629. /**
  51630. * Transform the url before loading if required.
  51631. * @param rootUrl the url of the texture
  51632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51633. * @returns the transformed texture
  51634. */
  51635. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51636. /**
  51637. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51638. * @param rootUrl the url of the texture
  51639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51640. * @returns the fallback texture
  51641. */
  51642. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51643. /**
  51644. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51645. * @param data contains the texture data
  51646. * @param texture defines the BabylonJS internal texture
  51647. * @param createPolynomials will be true if polynomials have been requested
  51648. * @param onLoad defines the callback to trigger once the texture is ready
  51649. * @param onError defines the callback to trigger in case of error
  51650. */
  51651. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51652. /**
  51653. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51654. * @param data contains the texture data
  51655. * @param texture defines the BabylonJS internal texture
  51656. * @param callback defines the method to call once ready to upload
  51657. */
  51658. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /**
  51663. * 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.
  51664. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51666. */
  51667. export class CustomProceduralTexture extends ProceduralTexture {
  51668. private _animate;
  51669. private _time;
  51670. private _config;
  51671. private _texturePath;
  51672. /**
  51673. * Instantiates a new Custom Procedural Texture.
  51674. * 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.
  51675. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51676. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51677. * @param name Define the name of the texture
  51678. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51679. * @param size Define the size of the texture to create
  51680. * @param scene Define the scene the texture belongs to
  51681. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51682. * @param generateMipMaps Define if the texture should creates mip maps or not
  51683. */
  51684. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51685. private _loadJson;
  51686. /**
  51687. * Is the texture ready to be used ? (rendered at least once)
  51688. * @returns true if ready, otherwise, false.
  51689. */
  51690. isReady(): boolean;
  51691. /**
  51692. * Render the texture to its associated render target.
  51693. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51694. */
  51695. render(useCameraPostProcess?: boolean): void;
  51696. /**
  51697. * Update the list of dependant textures samplers in the shader.
  51698. */
  51699. updateTextures(): void;
  51700. /**
  51701. * Update the uniform values of the procedural texture in the shader.
  51702. */
  51703. updateShaderUniforms(): void;
  51704. /**
  51705. * Define if the texture animates or not.
  51706. */
  51707. animate: boolean;
  51708. }
  51709. }
  51710. declare module BABYLON {
  51711. /** @hidden */
  51712. export var noisePixelShader: {
  51713. name: string;
  51714. shader: string;
  51715. };
  51716. }
  51717. declare module BABYLON {
  51718. /**
  51719. * Class used to generate noise procedural textures
  51720. */
  51721. export class NoiseProceduralTexture extends ProceduralTexture {
  51722. private _time;
  51723. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51724. brightness: number;
  51725. /** Defines the number of octaves to process */
  51726. octaves: number;
  51727. /** Defines the level of persistence (0.8 by default) */
  51728. persistence: number;
  51729. /** Gets or sets animation speed factor (default is 1) */
  51730. animationSpeedFactor: number;
  51731. /**
  51732. * Creates a new NoiseProceduralTexture
  51733. * @param name defines the name fo the texture
  51734. * @param size defines the size of the texture (default is 256)
  51735. * @param scene defines the hosting scene
  51736. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51737. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51738. */
  51739. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51740. private _updateShaderUniforms;
  51741. protected _getDefines(): string;
  51742. /** Generate the current state of the procedural texture */
  51743. render(useCameraPostProcess?: boolean): void;
  51744. /**
  51745. * Serializes this noise procedural texture
  51746. * @returns a serialized noise procedural texture object
  51747. */
  51748. serialize(): any;
  51749. /**
  51750. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51751. * @param parsedTexture defines parsed texture data
  51752. * @param scene defines the current scene
  51753. * @param rootUrl defines the root URL containing noise procedural texture information
  51754. * @returns a parsed NoiseProceduralTexture
  51755. */
  51756. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * Raw cube texture where the raw buffers are passed in
  51762. */
  51763. export class RawCubeTexture extends CubeTexture {
  51764. /**
  51765. * Creates a cube texture where the raw buffers are passed in.
  51766. * @param scene defines the scene the texture is attached to
  51767. * @param data defines the array of data to use to create each face
  51768. * @param size defines the size of the textures
  51769. * @param format defines the format of the data
  51770. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51771. * @param generateMipMaps defines if the engine should generate the mip levels
  51772. * @param invertY defines if data must be stored with Y axis inverted
  51773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51774. * @param compression defines the compression used (null by default)
  51775. */
  51776. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51777. /**
  51778. * Updates the raw cube texture.
  51779. * @param data defines the data to store
  51780. * @param format defines the data format
  51781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51782. * @param invertY defines if data must be stored with Y axis inverted
  51783. * @param compression defines the compression used (null by default)
  51784. * @param level defines which level of the texture to update
  51785. */
  51786. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51787. /**
  51788. * Updates a raw cube texture with RGBD encoded data.
  51789. * @param data defines the array of data [mipmap][face] to use to create each face
  51790. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51791. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51792. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51793. * @returns a promsie that resolves when the operation is complete
  51794. */
  51795. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51796. /**
  51797. * Clones the raw cube texture.
  51798. * @return a new cube texture
  51799. */
  51800. clone(): CubeTexture;
  51801. /** @hidden */
  51802. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51803. }
  51804. }
  51805. declare module BABYLON {
  51806. /**
  51807. * Class used to store 3D textures containing user data
  51808. */
  51809. export class RawTexture3D extends Texture {
  51810. /** Gets or sets the texture format to use */
  51811. format: number;
  51812. private _engine;
  51813. /**
  51814. * Create a new RawTexture3D
  51815. * @param data defines the data of the texture
  51816. * @param width defines the width of the texture
  51817. * @param height defines the height of the texture
  51818. * @param depth defines the depth of the texture
  51819. * @param format defines the texture format to use
  51820. * @param scene defines the hosting scene
  51821. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51822. * @param invertY defines if texture must be stored with Y axis inverted
  51823. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51824. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51825. */
  51826. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51827. /** Gets or sets the texture format to use */
  51828. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51829. /**
  51830. * Update the texture with new data
  51831. * @param data defines the data to store in the texture
  51832. */
  51833. update(data: ArrayBufferView): void;
  51834. }
  51835. }
  51836. declare module BABYLON {
  51837. /**
  51838. * Creates a refraction texture used by refraction channel of the standard material.
  51839. * It is like a mirror but to see through a material.
  51840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51841. */
  51842. export class RefractionTexture extends RenderTargetTexture {
  51843. /**
  51844. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51845. * 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.
  51846. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51847. */
  51848. refractionPlane: Plane;
  51849. /**
  51850. * Define how deep under the surface we should see.
  51851. */
  51852. depth: number;
  51853. /**
  51854. * Creates a refraction texture used by refraction channel of the standard material.
  51855. * It is like a mirror but to see through a material.
  51856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51857. * @param name Define the texture name
  51858. * @param size Define the size of the underlying texture
  51859. * @param scene Define the scene the refraction belongs to
  51860. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51861. */
  51862. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51863. /**
  51864. * Clone the refraction texture.
  51865. * @returns the cloned texture
  51866. */
  51867. clone(): RefractionTexture;
  51868. /**
  51869. * Serialize the texture to a JSON representation you could use in Parse later on
  51870. * @returns the serialized JSON representation
  51871. */
  51872. serialize(): any;
  51873. }
  51874. }
  51875. declare module BABYLON {
  51876. /**
  51877. * Defines the options related to the creation of an HtmlElementTexture
  51878. */
  51879. export interface IHtmlElementTextureOptions {
  51880. /**
  51881. * Defines wether mip maps should be created or not.
  51882. */
  51883. generateMipMaps?: boolean;
  51884. /**
  51885. * Defines the sampling mode of the texture.
  51886. */
  51887. samplingMode?: number;
  51888. /**
  51889. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51890. */
  51891. engine: Nullable<Engine>;
  51892. /**
  51893. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51894. */
  51895. scene: Nullable<Scene>;
  51896. }
  51897. /**
  51898. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51899. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51900. * is automatically managed.
  51901. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51902. * in your application.
  51903. *
  51904. * As the update is not automatic, you need to call them manually.
  51905. */
  51906. export class HtmlElementTexture extends BaseTexture {
  51907. /**
  51908. * The texture URL.
  51909. */
  51910. element: HTMLVideoElement | HTMLCanvasElement;
  51911. private static readonly DefaultOptions;
  51912. private _textureMatrix;
  51913. private _engine;
  51914. private _isVideo;
  51915. private _generateMipMaps;
  51916. private _samplingMode;
  51917. /**
  51918. * Instantiates a HtmlElementTexture from the following parameters.
  51919. *
  51920. * @param name Defines the name of the texture
  51921. * @param element Defines the video or canvas the texture is filled with
  51922. * @param options Defines the other none mandatory texture creation options
  51923. */
  51924. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51925. private _createInternalTexture;
  51926. /**
  51927. * Returns the texture matrix used in most of the material.
  51928. */
  51929. getTextureMatrix(): Matrix;
  51930. /**
  51931. * Updates the content of the texture.
  51932. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51933. */
  51934. update(invertY?: Nullable<boolean>): void;
  51935. }
  51936. }
  51937. declare module BABYLON {
  51938. /**
  51939. * Enum used to define the target of a block
  51940. */
  51941. export enum NodeMaterialBlockTargets {
  51942. /** Vertex shader */
  51943. Vertex = 1,
  51944. /** Fragment shader */
  51945. Fragment = 2,
  51946. /** Neutral */
  51947. Neutral = 4,
  51948. /** Vertex and Fragment */
  51949. VertexAndFragment = 3
  51950. }
  51951. }
  51952. declare module BABYLON {
  51953. /**
  51954. * Defines the kind of connection point for node based material
  51955. */
  51956. export enum NodeMaterialBlockConnectionPointTypes {
  51957. /** Float */
  51958. Float = 1,
  51959. /** Int */
  51960. Int = 2,
  51961. /** Vector2 */
  51962. Vector2 = 4,
  51963. /** Vector3 */
  51964. Vector3 = 8,
  51965. /** Vector4 */
  51966. Vector4 = 16,
  51967. /** Color3 */
  51968. Color3 = 32,
  51969. /** Color4 */
  51970. Color4 = 64,
  51971. /** Matrix */
  51972. Matrix = 128,
  51973. /** Detect type based on connection */
  51974. AutoDetect = 1024,
  51975. /** Output type that will be defined by input type */
  51976. BasedOnInput = 2048
  51977. }
  51978. }
  51979. declare module BABYLON {
  51980. /**
  51981. * Root class for all node material optimizers
  51982. */
  51983. export class NodeMaterialOptimizer {
  51984. /**
  51985. * Function used to optimize a NodeMaterial graph
  51986. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51987. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51988. */
  51989. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51990. }
  51991. }
  51992. declare module BABYLON {
  51993. /**
  51994. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51995. */
  51996. export class TransformBlock extends NodeMaterialBlock {
  51997. /**
  51998. * Defines the value to use to complement W value to transform it to a Vector4
  51999. */
  52000. complementW: number;
  52001. /**
  52002. * Defines the value to use to complement z value to transform it to a Vector4
  52003. */
  52004. complementZ: number;
  52005. /**
  52006. * Creates a new TransformBlock
  52007. * @param name defines the block name
  52008. */
  52009. constructor(name: string);
  52010. /**
  52011. * Gets the current class name
  52012. * @returns the class name
  52013. */
  52014. getClassName(): string;
  52015. /**
  52016. * Gets the vector input
  52017. */
  52018. readonly vector: NodeMaterialConnectionPoint;
  52019. /**
  52020. * Gets the output component
  52021. */
  52022. readonly output: NodeMaterialConnectionPoint;
  52023. /**
  52024. * Gets the matrix transform input
  52025. */
  52026. readonly transform: NodeMaterialConnectionPoint;
  52027. protected _buildBlock(state: NodeMaterialBuildState): this;
  52028. serialize(): any;
  52029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52030. protected _dumpPropertiesCode(): string;
  52031. }
  52032. }
  52033. declare module BABYLON {
  52034. /**
  52035. * Block used to output the vertex position
  52036. */
  52037. export class VertexOutputBlock extends NodeMaterialBlock {
  52038. /**
  52039. * Creates a new VertexOutputBlock
  52040. * @param name defines the block name
  52041. */
  52042. constructor(name: string);
  52043. /**
  52044. * Gets the current class name
  52045. * @returns the class name
  52046. */
  52047. getClassName(): string;
  52048. /**
  52049. * Gets the vector input component
  52050. */
  52051. readonly vector: NodeMaterialConnectionPoint;
  52052. protected _buildBlock(state: NodeMaterialBuildState): this;
  52053. }
  52054. }
  52055. declare module BABYLON {
  52056. /**
  52057. * Block used to output the final color
  52058. */
  52059. export class FragmentOutputBlock extends NodeMaterialBlock {
  52060. /**
  52061. * Create a new FragmentOutputBlock
  52062. * @param name defines the block name
  52063. */
  52064. constructor(name: string);
  52065. /**
  52066. * Gets the current class name
  52067. * @returns the class name
  52068. */
  52069. getClassName(): string;
  52070. /**
  52071. * Gets the rgba input component
  52072. */
  52073. readonly rgba: NodeMaterialConnectionPoint;
  52074. /**
  52075. * Gets the rgb input component
  52076. */
  52077. readonly rgb: NodeMaterialConnectionPoint;
  52078. /**
  52079. * Gets the a input component
  52080. */
  52081. readonly a: NodeMaterialConnectionPoint;
  52082. protected _buildBlock(state: NodeMaterialBuildState): this;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * Enum used to define system values e.g. values automatically provided by the system
  52088. */
  52089. export enum NodeMaterialSystemValues {
  52090. /** World */
  52091. World = 1,
  52092. /** View */
  52093. View = 2,
  52094. /** Projection */
  52095. Projection = 3,
  52096. /** ViewProjection */
  52097. ViewProjection = 4,
  52098. /** WorldView */
  52099. WorldView = 5,
  52100. /** WorldViewProjection */
  52101. WorldViewProjection = 6,
  52102. /** CameraPosition */
  52103. CameraPosition = 7,
  52104. /** Fog Color */
  52105. FogColor = 8
  52106. }
  52107. }
  52108. declare module BABYLON {
  52109. /**
  52110. * Block used to read a reflection texture from a sampler
  52111. */
  52112. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52113. private _define3DName;
  52114. private _defineCubicName;
  52115. private _defineExplicitName;
  52116. private _defineProjectionName;
  52117. private _defineLocalCubicName;
  52118. private _defineSphericalName;
  52119. private _definePlanarName;
  52120. private _defineEquirectangularName;
  52121. private _defineMirroredEquirectangularFixedName;
  52122. private _defineEquirectangularFixedName;
  52123. private _defineSkyboxName;
  52124. private _cubeSamplerName;
  52125. private _2DSamplerName;
  52126. private _positionUVWName;
  52127. private _directionWName;
  52128. private _reflectionCoordsName;
  52129. private _reflection2DCoordsName;
  52130. private _reflectionColorName;
  52131. private _reflectionMatrixName;
  52132. /**
  52133. * Gets or sets the texture associated with the node
  52134. */
  52135. texture: Nullable<BaseTexture>;
  52136. /**
  52137. * Create a new TextureBlock
  52138. * @param name defines the block name
  52139. */
  52140. constructor(name: string);
  52141. /**
  52142. * Gets the current class name
  52143. * @returns the class name
  52144. */
  52145. getClassName(): string;
  52146. /**
  52147. * Gets the world position input component
  52148. */
  52149. readonly position: NodeMaterialConnectionPoint;
  52150. /**
  52151. * Gets the world position input component
  52152. */
  52153. readonly worldPosition: NodeMaterialConnectionPoint;
  52154. /**
  52155. * Gets the world normal input component
  52156. */
  52157. readonly worldNormal: NodeMaterialConnectionPoint;
  52158. /**
  52159. * Gets the world input component
  52160. */
  52161. readonly world: NodeMaterialConnectionPoint;
  52162. /**
  52163. * Gets the camera (or eye) position component
  52164. */
  52165. readonly cameraPosition: NodeMaterialConnectionPoint;
  52166. /**
  52167. * Gets the view input component
  52168. */
  52169. readonly view: NodeMaterialConnectionPoint;
  52170. /**
  52171. * Gets the rgb output component
  52172. */
  52173. readonly rgb: NodeMaterialConnectionPoint;
  52174. /**
  52175. * Gets the r output component
  52176. */
  52177. readonly r: NodeMaterialConnectionPoint;
  52178. /**
  52179. * Gets the g output component
  52180. */
  52181. readonly g: NodeMaterialConnectionPoint;
  52182. /**
  52183. * Gets the b output component
  52184. */
  52185. readonly b: NodeMaterialConnectionPoint;
  52186. autoConfigure(material: NodeMaterial): void;
  52187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52188. isReady(): boolean;
  52189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52190. private _injectVertexCode;
  52191. private _writeOutput;
  52192. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52193. serialize(): any;
  52194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /**
  52199. * Interface used to configure the node material editor
  52200. */
  52201. export interface INodeMaterialEditorOptions {
  52202. /** Define the URl to load node editor script */
  52203. editorURL?: string;
  52204. }
  52205. /** @hidden */
  52206. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52207. /** BONES */
  52208. NUM_BONE_INFLUENCERS: number;
  52209. BonesPerMesh: number;
  52210. BONETEXTURE: boolean;
  52211. /** MORPH TARGETS */
  52212. MORPHTARGETS: boolean;
  52213. MORPHTARGETS_NORMAL: boolean;
  52214. MORPHTARGETS_TANGENT: boolean;
  52215. MORPHTARGETS_UV: boolean;
  52216. NUM_MORPH_INFLUENCERS: number;
  52217. /** IMAGE PROCESSING */
  52218. IMAGEPROCESSING: boolean;
  52219. VIGNETTE: boolean;
  52220. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52221. VIGNETTEBLENDMODEOPAQUE: boolean;
  52222. TONEMAPPING: boolean;
  52223. TONEMAPPING_ACES: boolean;
  52224. CONTRAST: boolean;
  52225. EXPOSURE: boolean;
  52226. COLORCURVES: boolean;
  52227. COLORGRADING: boolean;
  52228. COLORGRADING3D: boolean;
  52229. SAMPLER3DGREENDEPTH: boolean;
  52230. SAMPLER3DBGRMAP: boolean;
  52231. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52232. constructor();
  52233. setValue(name: string, value: boolean): void;
  52234. }
  52235. /**
  52236. * Class used to configure NodeMaterial
  52237. */
  52238. export interface INodeMaterialOptions {
  52239. /**
  52240. * Defines if blocks should emit comments
  52241. */
  52242. emitComments: boolean;
  52243. }
  52244. /**
  52245. * Class used to create a node based material built by assembling shader blocks
  52246. */
  52247. export class NodeMaterial extends PushMaterial {
  52248. private static _BuildIdGenerator;
  52249. private _options;
  52250. private _vertexCompilationState;
  52251. private _fragmentCompilationState;
  52252. private _sharedData;
  52253. private _buildId;
  52254. private _buildWasSuccessful;
  52255. private _cachedWorldViewMatrix;
  52256. private _cachedWorldViewProjectionMatrix;
  52257. private _optimizers;
  52258. private _animationFrame;
  52259. /** Define the URl to load node editor script */
  52260. static EditorURL: string;
  52261. private BJSNODEMATERIALEDITOR;
  52262. /** Get the inspector from bundle or global */
  52263. private _getGlobalNodeMaterialEditor;
  52264. /**
  52265. * 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)
  52266. */
  52267. ignoreAlpha: boolean;
  52268. /**
  52269. * Defines the maximum number of lights that can be used in the material
  52270. */
  52271. maxSimultaneousLights: number;
  52272. /**
  52273. * Observable raised when the material is built
  52274. */
  52275. onBuildObservable: Observable<NodeMaterial>;
  52276. /**
  52277. * Gets or sets the root nodes of the material vertex shader
  52278. */
  52279. _vertexOutputNodes: NodeMaterialBlock[];
  52280. /**
  52281. * Gets or sets the root nodes of the material fragment (pixel) shader
  52282. */
  52283. _fragmentOutputNodes: NodeMaterialBlock[];
  52284. /** Gets or sets options to control the node material overall behavior */
  52285. options: INodeMaterialOptions;
  52286. /**
  52287. * Default configuration related to image processing available in the standard Material.
  52288. */
  52289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52290. /**
  52291. * Gets the image processing configuration used either in this material.
  52292. */
  52293. /**
  52294. * Sets the Default image processing configuration used either in the this material.
  52295. *
  52296. * If sets to null, the scene one is in use.
  52297. */
  52298. imageProcessingConfiguration: ImageProcessingConfiguration;
  52299. /**
  52300. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52301. */
  52302. attachedBlocks: NodeMaterialBlock[];
  52303. /**
  52304. * Create a new node based material
  52305. * @param name defines the material name
  52306. * @param scene defines the hosting scene
  52307. * @param options defines creation option
  52308. */
  52309. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52310. /**
  52311. * Gets the current class name of the material e.g. "NodeMaterial"
  52312. * @returns the class name
  52313. */
  52314. getClassName(): string;
  52315. /**
  52316. * Keep track of the image processing observer to allow dispose and replace.
  52317. */
  52318. private _imageProcessingObserver;
  52319. /**
  52320. * Attaches a new image processing configuration to the Standard Material.
  52321. * @param configuration
  52322. */
  52323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52324. /**
  52325. * Get a block by its name
  52326. * @param name defines the name of the block to retrieve
  52327. * @returns the required block or null if not found
  52328. */
  52329. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52330. /**
  52331. * Get a block by its name
  52332. * @param predicate defines the predicate used to find the good candidate
  52333. * @returns the required block or null if not found
  52334. */
  52335. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52336. /**
  52337. * Get an input block by its name
  52338. * @param predicate defines the predicate used to find the good candidate
  52339. * @returns the required input block or null if not found
  52340. */
  52341. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52342. /**
  52343. * Gets the list of input blocks attached to this material
  52344. * @returns an array of InputBlocks
  52345. */
  52346. getInputBlocks(): InputBlock[];
  52347. /**
  52348. * Adds a new optimizer to the list of optimizers
  52349. * @param optimizer defines the optimizers to add
  52350. * @returns the current material
  52351. */
  52352. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52353. /**
  52354. * Remove an optimizer from the list of optimizers
  52355. * @param optimizer defines the optimizers to remove
  52356. * @returns the current material
  52357. */
  52358. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52359. /**
  52360. * Add a new block to the list of output nodes
  52361. * @param node defines the node to add
  52362. * @returns the current material
  52363. */
  52364. addOutputNode(node: NodeMaterialBlock): this;
  52365. /**
  52366. * Remove a block from the list of root nodes
  52367. * @param node defines the node to remove
  52368. * @returns the current material
  52369. */
  52370. removeOutputNode(node: NodeMaterialBlock): this;
  52371. private _addVertexOutputNode;
  52372. private _removeVertexOutputNode;
  52373. private _addFragmentOutputNode;
  52374. private _removeFragmentOutputNode;
  52375. /**
  52376. * Specifies if the material will require alpha blending
  52377. * @returns a boolean specifying if alpha blending is needed
  52378. */
  52379. needAlphaBlending(): boolean;
  52380. /**
  52381. * Specifies if this material should be rendered in alpha test mode
  52382. * @returns a boolean specifying if an alpha test is needed.
  52383. */
  52384. needAlphaTesting(): boolean;
  52385. private _initializeBlock;
  52386. private _resetDualBlocks;
  52387. /**
  52388. * Build the material and generates the inner effect
  52389. * @param verbose defines if the build should log activity
  52390. */
  52391. build(verbose?: boolean): void;
  52392. /**
  52393. * Runs an otpimization phase to try to improve the shader code
  52394. */
  52395. optimize(): void;
  52396. private _prepareDefinesForAttributes;
  52397. /**
  52398. * Get if the submesh is ready to be used and all its information available.
  52399. * Child classes can use it to update shaders
  52400. * @param mesh defines the mesh to check
  52401. * @param subMesh defines which submesh to check
  52402. * @param useInstances specifies that instances should be used
  52403. * @returns a boolean indicating that the submesh is ready or not
  52404. */
  52405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52406. /**
  52407. * Get a string representing the shaders built by the current node graph
  52408. */
  52409. readonly compiledShaders: string;
  52410. /**
  52411. * Binds the world matrix to the material
  52412. * @param world defines the world transformation matrix
  52413. */
  52414. bindOnlyWorldMatrix(world: Matrix): void;
  52415. /**
  52416. * Binds the submesh to this material by preparing the effect and shader to draw
  52417. * @param world defines the world transformation matrix
  52418. * @param mesh defines the mesh containing the submesh
  52419. * @param subMesh defines the submesh to bind the material to
  52420. */
  52421. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52422. /**
  52423. * Gets the active textures from the material
  52424. * @returns an array of textures
  52425. */
  52426. getActiveTextures(): BaseTexture[];
  52427. /**
  52428. * Gets the list of texture blocks
  52429. * @returns an array of texture blocks
  52430. */
  52431. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52432. /**
  52433. * Specifies if the material uses a texture
  52434. * @param texture defines the texture to check against the material
  52435. * @returns a boolean specifying if the material uses the texture
  52436. */
  52437. hasTexture(texture: BaseTexture): boolean;
  52438. /**
  52439. * Disposes the material
  52440. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52441. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52442. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52443. */
  52444. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52445. /** Creates the node editor window. */
  52446. private _createNodeEditor;
  52447. /**
  52448. * Launch the node material editor
  52449. * @param config Define the configuration of the editor
  52450. * @return a promise fulfilled when the node editor is visible
  52451. */
  52452. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52453. /**
  52454. * Clear the current material
  52455. */
  52456. clear(): void;
  52457. /**
  52458. * Clear the current material and set it to a default state
  52459. */
  52460. setToDefault(): void;
  52461. /**
  52462. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52463. * @param url defines the url to load from
  52464. * @returns a promise that will fullfil when the material is fully loaded
  52465. */
  52466. loadAsync(url: string): Promise<unknown>;
  52467. private _gatherBlocks;
  52468. /**
  52469. * Generate a string containing the code declaration required to create an equivalent of this material
  52470. * @returns a string
  52471. */
  52472. generateCode(): string;
  52473. /**
  52474. * Serializes this material in a JSON representation
  52475. * @returns the serialized material object
  52476. */
  52477. serialize(): any;
  52478. private _restoreConnections;
  52479. /**
  52480. * Clear the current graph and load a new one from a serialization object
  52481. * @param source defines the JSON representation of the material
  52482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52483. */
  52484. loadFromSerialization(source: any, rootUrl?: string): void;
  52485. /**
  52486. * Creates a node material from parsed material data
  52487. * @param source defines the JSON representation of the material
  52488. * @param scene defines the hosting scene
  52489. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52490. * @returns a new node material
  52491. */
  52492. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52493. /**
  52494. * Creates a new node material set to default basic configuration
  52495. * @param name defines the name of the material
  52496. * @param scene defines the hosting scene
  52497. * @returns a new NodeMaterial
  52498. */
  52499. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Block used to read a texture from a sampler
  52505. */
  52506. export class TextureBlock extends NodeMaterialBlock {
  52507. private _defineName;
  52508. private _samplerName;
  52509. private _transformedUVName;
  52510. private _textureTransformName;
  52511. private _textureInfoName;
  52512. private _mainUVName;
  52513. private _mainUVDefineName;
  52514. /**
  52515. * Gets or sets the texture associated with the node
  52516. */
  52517. texture: Nullable<BaseTexture>;
  52518. /**
  52519. * Create a new TextureBlock
  52520. * @param name defines the block name
  52521. */
  52522. constructor(name: string);
  52523. /**
  52524. * Gets the current class name
  52525. * @returns the class name
  52526. */
  52527. getClassName(): string;
  52528. /**
  52529. * Gets the uv input component
  52530. */
  52531. readonly uv: NodeMaterialConnectionPoint;
  52532. /**
  52533. * Gets the rgba output component
  52534. */
  52535. readonly rgba: NodeMaterialConnectionPoint;
  52536. /**
  52537. * Gets the rgb output component
  52538. */
  52539. readonly rgb: NodeMaterialConnectionPoint;
  52540. /**
  52541. * Gets the r output component
  52542. */
  52543. readonly r: NodeMaterialConnectionPoint;
  52544. /**
  52545. * Gets the g output component
  52546. */
  52547. readonly g: NodeMaterialConnectionPoint;
  52548. /**
  52549. * Gets the b output component
  52550. */
  52551. readonly b: NodeMaterialConnectionPoint;
  52552. /**
  52553. * Gets the a output component
  52554. */
  52555. readonly a: NodeMaterialConnectionPoint;
  52556. readonly target: NodeMaterialBlockTargets;
  52557. autoConfigure(material: NodeMaterial): void;
  52558. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52560. isReady(): boolean;
  52561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52562. private readonly _isMixed;
  52563. private _injectVertexCode;
  52564. private _writeOutput;
  52565. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52566. protected _dumpPropertiesCode(): string;
  52567. serialize(): any;
  52568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52569. }
  52570. }
  52571. declare module BABYLON {
  52572. /**
  52573. * Class used to store shared data between 2 NodeMaterialBuildState
  52574. */
  52575. export class NodeMaterialBuildStateSharedData {
  52576. /**
  52577. * Gets the list of emitted varyings
  52578. */
  52579. temps: string[];
  52580. /**
  52581. * Gets the list of emitted varyings
  52582. */
  52583. varyings: string[];
  52584. /**
  52585. * Gets the varying declaration string
  52586. */
  52587. varyingDeclaration: string;
  52588. /**
  52589. * Input blocks
  52590. */
  52591. inputBlocks: InputBlock[];
  52592. /**
  52593. * Input blocks
  52594. */
  52595. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52596. /**
  52597. * Bindable blocks (Blocks that need to set data to the effect)
  52598. */
  52599. bindableBlocks: NodeMaterialBlock[];
  52600. /**
  52601. * List of blocks that can provide a compilation fallback
  52602. */
  52603. blocksWithFallbacks: NodeMaterialBlock[];
  52604. /**
  52605. * List of blocks that can provide a define update
  52606. */
  52607. blocksWithDefines: NodeMaterialBlock[];
  52608. /**
  52609. * List of blocks that can provide a repeatable content
  52610. */
  52611. repeatableContentBlocks: NodeMaterialBlock[];
  52612. /**
  52613. * List of blocks that can provide a dynamic list of uniforms
  52614. */
  52615. dynamicUniformBlocks: NodeMaterialBlock[];
  52616. /**
  52617. * List of blocks that can block the isReady function for the material
  52618. */
  52619. blockingBlocks: NodeMaterialBlock[];
  52620. /**
  52621. * Gets the list of animated inputs
  52622. */
  52623. animatedInputs: InputBlock[];
  52624. /**
  52625. * Build Id used to avoid multiple recompilations
  52626. */
  52627. buildId: number;
  52628. /** List of emitted variables */
  52629. variableNames: {
  52630. [key: string]: number;
  52631. };
  52632. /** List of emitted defines */
  52633. defineNames: {
  52634. [key: string]: number;
  52635. };
  52636. /** Should emit comments? */
  52637. emitComments: boolean;
  52638. /** Emit build activity */
  52639. verbose: boolean;
  52640. /**
  52641. * Gets the compilation hints emitted at compilation time
  52642. */
  52643. hints: {
  52644. needWorldViewMatrix: boolean;
  52645. needWorldViewProjectionMatrix: boolean;
  52646. needAlphaBlending: boolean;
  52647. needAlphaTesting: boolean;
  52648. };
  52649. /**
  52650. * List of compilation checks
  52651. */
  52652. checks: {
  52653. emitVertex: boolean;
  52654. emitFragment: boolean;
  52655. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52656. };
  52657. /** Creates a new shared data */
  52658. constructor();
  52659. /**
  52660. * Emits console errors and exceptions if there is a failing check
  52661. */
  52662. emitErrors(): void;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Class used to store node based material build state
  52668. */
  52669. export class NodeMaterialBuildState {
  52670. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52671. supportUniformBuffers: boolean;
  52672. /**
  52673. * Gets the list of emitted attributes
  52674. */
  52675. attributes: string[];
  52676. /**
  52677. * Gets the list of emitted uniforms
  52678. */
  52679. uniforms: string[];
  52680. /**
  52681. * Gets the list of emitted uniform buffers
  52682. */
  52683. uniformBuffers: string[];
  52684. /**
  52685. * Gets the list of emitted samplers
  52686. */
  52687. samplers: string[];
  52688. /**
  52689. * Gets the list of emitted functions
  52690. */
  52691. functions: {
  52692. [key: string]: string;
  52693. };
  52694. /**
  52695. * Gets the target of the compilation state
  52696. */
  52697. target: NodeMaterialBlockTargets;
  52698. /**
  52699. * Gets the list of emitted counters
  52700. */
  52701. counters: {
  52702. [key: string]: number;
  52703. };
  52704. /**
  52705. * Shared data between multiple NodeMaterialBuildState instances
  52706. */
  52707. sharedData: NodeMaterialBuildStateSharedData;
  52708. /** @hidden */
  52709. _vertexState: NodeMaterialBuildState;
  52710. /** @hidden */
  52711. _attributeDeclaration: string;
  52712. /** @hidden */
  52713. _uniformDeclaration: string;
  52714. /** @hidden */
  52715. _samplerDeclaration: string;
  52716. /** @hidden */
  52717. _varyingTransfer: string;
  52718. private _repeatableContentAnchorIndex;
  52719. /** @hidden */
  52720. _builtCompilationString: string;
  52721. /**
  52722. * Gets the emitted compilation strings
  52723. */
  52724. compilationString: string;
  52725. /**
  52726. * Finalize the compilation strings
  52727. * @param state defines the current compilation state
  52728. */
  52729. finalize(state: NodeMaterialBuildState): void;
  52730. /** @hidden */
  52731. readonly _repeatableContentAnchor: string;
  52732. /** @hidden */
  52733. _getFreeVariableName(prefix: string): string;
  52734. /** @hidden */
  52735. _getFreeDefineName(prefix: string): string;
  52736. /** @hidden */
  52737. _excludeVariableName(name: string): void;
  52738. /** @hidden */
  52739. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52740. /** @hidden */
  52741. _emitFunction(name: string, code: string, comments: string): void;
  52742. /** @hidden */
  52743. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52744. replaceStrings?: {
  52745. search: RegExp;
  52746. replace: string;
  52747. }[];
  52748. repeatKey?: string;
  52749. }): string;
  52750. /** @hidden */
  52751. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52752. repeatKey?: string;
  52753. removeAttributes?: boolean;
  52754. removeUniforms?: boolean;
  52755. removeVaryings?: boolean;
  52756. removeIfDef?: boolean;
  52757. replaceStrings?: {
  52758. search: RegExp;
  52759. replace: string;
  52760. }[];
  52761. }, storeKey?: string): void;
  52762. /** @hidden */
  52763. _registerTempVariable(name: string): boolean;
  52764. /** @hidden */
  52765. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52766. /** @hidden */
  52767. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52768. }
  52769. }
  52770. declare module BABYLON {
  52771. /**
  52772. * Defines a block that can be used inside a node based material
  52773. */
  52774. export class NodeMaterialBlock {
  52775. private _buildId;
  52776. private _buildTarget;
  52777. private _target;
  52778. private _isFinalMerger;
  52779. private _isInput;
  52780. /** @hidden */
  52781. _codeVariableName: string;
  52782. /** @hidden */
  52783. _inputs: NodeMaterialConnectionPoint[];
  52784. /** @hidden */
  52785. _outputs: NodeMaterialConnectionPoint[];
  52786. /** @hidden */
  52787. _preparationId: number;
  52788. /**
  52789. * Gets or sets the name of the block
  52790. */
  52791. name: string;
  52792. /**
  52793. * Gets or sets the unique id of the node
  52794. */
  52795. uniqueId: number;
  52796. /**
  52797. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52798. */
  52799. readonly isFinalMerger: boolean;
  52800. /**
  52801. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52802. */
  52803. readonly isInput: boolean;
  52804. /**
  52805. * Gets or sets the build Id
  52806. */
  52807. buildId: number;
  52808. /**
  52809. * Gets or sets the target of the block
  52810. */
  52811. target: NodeMaterialBlockTargets;
  52812. /**
  52813. * Gets the list of input points
  52814. */
  52815. readonly inputs: NodeMaterialConnectionPoint[];
  52816. /** Gets the list of output points */
  52817. readonly outputs: NodeMaterialConnectionPoint[];
  52818. /**
  52819. * Find an input by its name
  52820. * @param name defines the name of the input to look for
  52821. * @returns the input or null if not found
  52822. */
  52823. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52824. /**
  52825. * Find an output by its name
  52826. * @param name defines the name of the outputto look for
  52827. * @returns the output or null if not found
  52828. */
  52829. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52830. /**
  52831. * Creates a new NodeMaterialBlock
  52832. * @param name defines the block name
  52833. * @param target defines the target of that block (Vertex by default)
  52834. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52835. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52836. */
  52837. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52838. /**
  52839. * Initialize the block and prepare the context for build
  52840. * @param state defines the state that will be used for the build
  52841. */
  52842. initialize(state: NodeMaterialBuildState): void;
  52843. /**
  52844. * Bind data to effect. Will only be called for blocks with isBindable === true
  52845. * @param effect defines the effect to bind data to
  52846. * @param nodeMaterial defines the hosting NodeMaterial
  52847. * @param mesh defines the mesh that will be rendered
  52848. */
  52849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52850. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52851. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52852. protected _writeFloat(value: number): string;
  52853. /**
  52854. * Gets the current class name e.g. "NodeMaterialBlock"
  52855. * @returns the class name
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Register a new input. Must be called inside a block constructor
  52860. * @param name defines the connection point name
  52861. * @param type defines the connection point type
  52862. * @param isOptional defines a boolean indicating that this input can be omitted
  52863. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52864. * @returns the current block
  52865. */
  52866. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52867. /**
  52868. * Register a new output. Must be called inside a block constructor
  52869. * @param name defines the connection point name
  52870. * @param type defines the connection point type
  52871. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52872. * @returns the current block
  52873. */
  52874. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52875. /**
  52876. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52877. * @param forOutput defines an optional connection point to check compatibility with
  52878. * @returns the first available input or null
  52879. */
  52880. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52881. /**
  52882. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52883. * @param forBlock defines an optional block to check compatibility with
  52884. * @returns the first available input or null
  52885. */
  52886. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52887. /**
  52888. * Gets the sibling of the given output
  52889. * @param current defines the current output
  52890. * @returns the next output in the list or null
  52891. */
  52892. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52893. /**
  52894. * Connect current block with another block
  52895. * @param other defines the block to connect with
  52896. * @param options define the various options to help pick the right connections
  52897. * @returns the current block
  52898. */
  52899. connectTo(other: NodeMaterialBlock, options?: {
  52900. input?: string;
  52901. output?: string;
  52902. outputSwizzle?: string;
  52903. }): this | undefined;
  52904. protected _buildBlock(state: NodeMaterialBuildState): void;
  52905. /**
  52906. * Add uniforms, samplers and uniform buffers at compilation time
  52907. * @param state defines the state to update
  52908. * @param nodeMaterial defines the node material requesting the update
  52909. * @param defines defines the material defines to update
  52910. */
  52911. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52912. /**
  52913. * Add potential fallbacks if shader compilation fails
  52914. * @param mesh defines the mesh to be rendered
  52915. * @param fallbacks defines the current prioritized list of fallbacks
  52916. */
  52917. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52918. /**
  52919. * Update defines for shader compilation
  52920. * @param mesh defines the mesh to be rendered
  52921. * @param nodeMaterial defines the node material requesting the update
  52922. * @param defines defines the material defines to update
  52923. * @param useInstances specifies that instances should be used
  52924. */
  52925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52926. /**
  52927. * Initialize defines for shader compilation
  52928. * @param mesh defines the mesh to be rendered
  52929. * @param nodeMaterial defines the node material requesting the update
  52930. * @param defines defines the material defines to be prepared
  52931. * @param useInstances specifies that instances should be used
  52932. */
  52933. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52934. /**
  52935. * Lets the block try to connect some inputs automatically
  52936. * @param material defines the hosting NodeMaterial
  52937. */
  52938. autoConfigure(material: NodeMaterial): void;
  52939. /**
  52940. * Function called when a block is declared as repeatable content generator
  52941. * @param vertexShaderState defines the current compilation state for the vertex shader
  52942. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52943. * @param mesh defines the mesh to be rendered
  52944. * @param defines defines the material defines to update
  52945. */
  52946. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52947. /**
  52948. * Checks if the block is ready
  52949. * @param mesh defines the mesh to be rendered
  52950. * @param nodeMaterial defines the node material requesting the update
  52951. * @param defines defines the material defines to update
  52952. * @param useInstances specifies that instances should be used
  52953. * @returns true if the block is ready
  52954. */
  52955. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52956. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52957. private _processBuild;
  52958. /**
  52959. * Compile the current node and generate the shader code
  52960. * @param state defines the current compilation state (uniforms, samplers, current string)
  52961. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52962. * @returns true if already built
  52963. */
  52964. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52965. protected _inputRename(name: string): string;
  52966. protected _outputRename(name: string): string;
  52967. protected _dumpPropertiesCode(): string;
  52968. /** @hidden */
  52969. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52970. /**
  52971. * Clone the current block to a new identical block
  52972. * @param scene defines the hosting scene
  52973. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52974. * @returns a copy of the current block
  52975. */
  52976. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52977. /**
  52978. * Serializes this block in a JSON representation
  52979. * @returns the serialized block object
  52980. */
  52981. serialize(): any;
  52982. /** @hidden */
  52983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52984. }
  52985. }
  52986. declare module BABYLON {
  52987. /**
  52988. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52989. */
  52990. export enum NodeMaterialBlockConnectionPointMode {
  52991. /** Value is an uniform */
  52992. Uniform = 0,
  52993. /** Value is a mesh attribute */
  52994. Attribute = 1,
  52995. /** Value is a varying between vertex and fragment shaders */
  52996. Varying = 2,
  52997. /** Mode is undefined */
  52998. Undefined = 3
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * Enum defining the type of animations supported by InputBlock
  53004. */
  53005. export enum AnimatedInputBlockTypes {
  53006. /** No animation */
  53007. None = 0,
  53008. /** Time based animation. Will only work for floats */
  53009. Time = 1
  53010. }
  53011. }
  53012. declare module BABYLON {
  53013. /**
  53014. * Block used to expose an input value
  53015. */
  53016. export class InputBlock extends NodeMaterialBlock {
  53017. private _mode;
  53018. private _associatedVariableName;
  53019. private _storedValue;
  53020. private _valueCallback;
  53021. private _type;
  53022. private _animationType;
  53023. /** @hidden */
  53024. _systemValue: Nullable<NodeMaterialSystemValues>;
  53025. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53026. visibleInInspector: boolean;
  53027. /**
  53028. * Gets or sets the connection point type (default is float)
  53029. */
  53030. readonly type: NodeMaterialBlockConnectionPointTypes;
  53031. /**
  53032. * Creates a new InputBlock
  53033. * @param name defines the block name
  53034. * @param target defines the target of that block (Vertex by default)
  53035. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53036. */
  53037. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53038. /**
  53039. * Gets the output component
  53040. */
  53041. readonly output: NodeMaterialConnectionPoint;
  53042. /**
  53043. * Set the source of this connection point to a vertex attribute
  53044. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53045. * @returns the current connection point
  53046. */
  53047. setAsAttribute(attributeName?: string): InputBlock;
  53048. /**
  53049. * Set the source of this connection point to a system value
  53050. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53051. * @returns the current connection point
  53052. */
  53053. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53054. /**
  53055. * Gets or sets the value of that point.
  53056. * Please note that this value will be ignored if valueCallback is defined
  53057. */
  53058. value: any;
  53059. /**
  53060. * Gets or sets a callback used to get the value of that point.
  53061. * Please note that setting this value will force the connection point to ignore the value property
  53062. */
  53063. valueCallback: () => any;
  53064. /**
  53065. * Gets or sets the associated variable name in the shader
  53066. */
  53067. associatedVariableName: string;
  53068. /** Gets or sets the type of animation applied to the input */
  53069. animationType: AnimatedInputBlockTypes;
  53070. /**
  53071. * Gets a boolean indicating that this connection point not defined yet
  53072. */
  53073. readonly isUndefined: boolean;
  53074. /**
  53075. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53076. * In this case the connection point name must be the name of the uniform to use.
  53077. * Can only be set on inputs
  53078. */
  53079. isUniform: boolean;
  53080. /**
  53081. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53082. * In this case the connection point name must be the name of the attribute to use
  53083. * Can only be set on inputs
  53084. */
  53085. isAttribute: boolean;
  53086. /**
  53087. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53088. * Can only be set on exit points
  53089. */
  53090. isVarying: boolean;
  53091. /**
  53092. * Gets a boolean indicating that the current connection point is a system value
  53093. */
  53094. readonly isSystemValue: boolean;
  53095. /**
  53096. * Gets or sets the current well known value or null if not defined as a system value
  53097. */
  53098. systemValue: Nullable<NodeMaterialSystemValues>;
  53099. /**
  53100. * Gets the current class name
  53101. * @returns the class name
  53102. */
  53103. getClassName(): string;
  53104. /**
  53105. * Animate the input if animationType !== None
  53106. * @param scene defines the rendering scene
  53107. */
  53108. animate(scene: Scene): void;
  53109. private _emitDefine;
  53110. /**
  53111. * Set the input block to its default value (based on its type)
  53112. */
  53113. setDefaultValue(): void;
  53114. protected _dumpPropertiesCode(): string;
  53115. private _emit;
  53116. /** @hidden */
  53117. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53118. /** @hidden */
  53119. _transmit(effect: Effect, scene: Scene): void;
  53120. protected _buildBlock(state: NodeMaterialBuildState): void;
  53121. serialize(): any;
  53122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53123. }
  53124. }
  53125. declare module BABYLON {
  53126. /**
  53127. * Defines a connection point for a block
  53128. */
  53129. export class NodeMaterialConnectionPoint {
  53130. /** @hidden */
  53131. _ownerBlock: NodeMaterialBlock;
  53132. /** @hidden */
  53133. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53134. private _endpoints;
  53135. private _associatedVariableName;
  53136. /** @hidden */
  53137. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53138. /** @hidden */
  53139. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53140. private _type;
  53141. /** @hidden */
  53142. _enforceAssociatedVariableName: boolean;
  53143. /**
  53144. * Gets or sets the additional types supported byt this connection point
  53145. */
  53146. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53147. /**
  53148. * Gets or sets the associated variable name in the shader
  53149. */
  53150. associatedVariableName: string;
  53151. /**
  53152. * Gets or sets the connection point type (default is float)
  53153. */
  53154. type: NodeMaterialBlockConnectionPointTypes;
  53155. /**
  53156. * Gets or sets the connection point name
  53157. */
  53158. name: string;
  53159. /**
  53160. * Gets or sets a boolean indicating that this connection point can be omitted
  53161. */
  53162. isOptional: boolean;
  53163. /**
  53164. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53165. */
  53166. define: string;
  53167. /** Gets or sets the target of that connection point */
  53168. target: NodeMaterialBlockTargets;
  53169. /**
  53170. * Gets a boolean indicating that the current point is connected
  53171. */
  53172. readonly isConnected: boolean;
  53173. /**
  53174. * Gets a boolean indicating that the current point is connected to an input block
  53175. */
  53176. readonly isConnectedToInputBlock: boolean;
  53177. /**
  53178. * Gets a the connected input block (if any)
  53179. */
  53180. readonly connectInputBlock: Nullable<InputBlock>;
  53181. /** Get the other side of the connection (if any) */
  53182. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53183. /** Get the block that owns this connection point */
  53184. readonly ownerBlock: NodeMaterialBlock;
  53185. /** Get the block connected on the other side of this connection (if any) */
  53186. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53187. /** Get the block connected on the endpoints of this connection (if any) */
  53188. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53189. /** Gets the list of connected endpoints */
  53190. readonly endpoints: NodeMaterialConnectionPoint[];
  53191. /** Gets a boolean indicating if that output point is connected to at least one input */
  53192. readonly hasEndpoints: boolean;
  53193. /**
  53194. * Creates a new connection point
  53195. * @param name defines the connection point name
  53196. * @param ownerBlock defines the block hosting this connection point
  53197. */
  53198. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53199. /**
  53200. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53201. * @returns the class name
  53202. */
  53203. getClassName(): string;
  53204. /**
  53205. * Gets an boolean indicating if the current point can be connected to another point
  53206. * @param connectionPoint defines the other connection point
  53207. * @returns true if the connection is possible
  53208. */
  53209. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53210. /**
  53211. * Connect this point to another connection point
  53212. * @param connectionPoint defines the other connection point
  53213. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53214. * @returns the current connection point
  53215. */
  53216. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53217. /**
  53218. * Disconnect this point from one of his endpoint
  53219. * @param endpoint defines the other connection point
  53220. * @returns the current connection point
  53221. */
  53222. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53223. /**
  53224. * Serializes this point in a JSON representation
  53225. * @returns the serialized point object
  53226. */
  53227. serialize(): any;
  53228. }
  53229. }
  53230. declare module BABYLON {
  53231. /**
  53232. * Block used to add support for vertex skinning (bones)
  53233. */
  53234. export class BonesBlock extends NodeMaterialBlock {
  53235. /**
  53236. * Creates a new BonesBlock
  53237. * @param name defines the block name
  53238. */
  53239. constructor(name: string);
  53240. /**
  53241. * Initialize the block and prepare the context for build
  53242. * @param state defines the state that will be used for the build
  53243. */
  53244. initialize(state: NodeMaterialBuildState): void;
  53245. /**
  53246. * Gets the current class name
  53247. * @returns the class name
  53248. */
  53249. getClassName(): string;
  53250. /**
  53251. * Gets the matrix indices input component
  53252. */
  53253. readonly matricesIndices: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the matrix weights input component
  53256. */
  53257. readonly matricesWeights: NodeMaterialConnectionPoint;
  53258. /**
  53259. * Gets the extra matrix indices input component
  53260. */
  53261. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53262. /**
  53263. * Gets the extra matrix weights input component
  53264. */
  53265. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53266. /**
  53267. * Gets the world input component
  53268. */
  53269. readonly world: NodeMaterialConnectionPoint;
  53270. /**
  53271. * Gets the output component
  53272. */
  53273. readonly output: NodeMaterialConnectionPoint;
  53274. autoConfigure(material: NodeMaterial): void;
  53275. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53278. protected _buildBlock(state: NodeMaterialBuildState): this;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Block used to add support for instances
  53284. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53285. */
  53286. export class InstancesBlock extends NodeMaterialBlock {
  53287. /**
  53288. * Creates a new InstancesBlock
  53289. * @param name defines the block name
  53290. */
  53291. constructor(name: string);
  53292. /**
  53293. * Gets the current class name
  53294. * @returns the class name
  53295. */
  53296. getClassName(): string;
  53297. /**
  53298. * Gets the first world row input component
  53299. */
  53300. readonly world0: NodeMaterialConnectionPoint;
  53301. /**
  53302. * Gets the second world row input component
  53303. */
  53304. readonly world1: NodeMaterialConnectionPoint;
  53305. /**
  53306. * Gets the third world row input component
  53307. */
  53308. readonly world2: NodeMaterialConnectionPoint;
  53309. /**
  53310. * Gets the forth world row input component
  53311. */
  53312. readonly world3: NodeMaterialConnectionPoint;
  53313. /**
  53314. * Gets the world input component
  53315. */
  53316. readonly world: NodeMaterialConnectionPoint;
  53317. /**
  53318. * Gets the output component
  53319. */
  53320. readonly output: NodeMaterialConnectionPoint;
  53321. autoConfigure(material: NodeMaterial): void;
  53322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53323. protected _buildBlock(state: NodeMaterialBuildState): this;
  53324. }
  53325. }
  53326. declare module BABYLON {
  53327. /**
  53328. * Block used to add morph targets support to vertex shader
  53329. */
  53330. export class MorphTargetsBlock extends NodeMaterialBlock {
  53331. private _repeatableContentAnchor;
  53332. private _repeatebleContentGenerated;
  53333. /**
  53334. * Create a new MorphTargetsBlock
  53335. * @param name defines the block name
  53336. */
  53337. constructor(name: string);
  53338. /**
  53339. * Gets the current class name
  53340. * @returns the class name
  53341. */
  53342. getClassName(): string;
  53343. /**
  53344. * Gets the position input component
  53345. */
  53346. readonly position: NodeMaterialConnectionPoint;
  53347. /**
  53348. * Gets the normal input component
  53349. */
  53350. readonly normal: NodeMaterialConnectionPoint;
  53351. /**
  53352. * Gets the tangent input component
  53353. */
  53354. readonly tangent: NodeMaterialConnectionPoint;
  53355. /**
  53356. * Gets the tangent input component
  53357. */
  53358. readonly uv: NodeMaterialConnectionPoint;
  53359. /**
  53360. * Gets the position output component
  53361. */
  53362. readonly positionOutput: NodeMaterialConnectionPoint;
  53363. /**
  53364. * Gets the normal output component
  53365. */
  53366. readonly normalOutput: NodeMaterialConnectionPoint;
  53367. /**
  53368. * Gets the tangent output component
  53369. */
  53370. readonly tangentOutput: NodeMaterialConnectionPoint;
  53371. /**
  53372. * Gets the tangent output component
  53373. */
  53374. readonly uvOutput: NodeMaterialConnectionPoint;
  53375. initialize(state: NodeMaterialBuildState): void;
  53376. autoConfigure(material: NodeMaterial): void;
  53377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53379. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53380. protected _buildBlock(state: NodeMaterialBuildState): this;
  53381. }
  53382. }
  53383. declare module BABYLON {
  53384. /**
  53385. * Block used to get data information from a light
  53386. */
  53387. export class LightInformationBlock extends NodeMaterialBlock {
  53388. private _lightDataDefineName;
  53389. private _lightColorDefineName;
  53390. /**
  53391. * Gets or sets the light associated with this block
  53392. */
  53393. light: Nullable<Light>;
  53394. /**
  53395. * Creates a new LightInformationBlock
  53396. * @param name defines the block name
  53397. */
  53398. constructor(name: string);
  53399. /**
  53400. * Gets the current class name
  53401. * @returns the class name
  53402. */
  53403. getClassName(): string;
  53404. /**
  53405. * Gets the world position input component
  53406. */
  53407. readonly worldPosition: NodeMaterialConnectionPoint;
  53408. /**
  53409. * Gets the direction output component
  53410. */
  53411. readonly direction: NodeMaterialConnectionPoint;
  53412. /**
  53413. * Gets the direction output component
  53414. */
  53415. readonly color: NodeMaterialConnectionPoint;
  53416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53417. protected _buildBlock(state: NodeMaterialBuildState): this;
  53418. serialize(): any;
  53419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /**
  53424. * Block used to add an alpha test in the fragment shader
  53425. */
  53426. export class AlphaTestBlock extends NodeMaterialBlock {
  53427. /**
  53428. * Gets or sets the alpha value where alpha testing happens
  53429. */
  53430. alphaCutOff: number;
  53431. /**
  53432. * Create a new AlphaTestBlock
  53433. * @param name defines the block name
  53434. */
  53435. constructor(name: string);
  53436. /**
  53437. * Gets the current class name
  53438. * @returns the class name
  53439. */
  53440. getClassName(): string;
  53441. /**
  53442. * Gets the color input component
  53443. */
  53444. readonly color: NodeMaterialConnectionPoint;
  53445. /**
  53446. * Gets the alpha input component
  53447. */
  53448. readonly alpha: NodeMaterialConnectionPoint;
  53449. protected _buildBlock(state: NodeMaterialBuildState): this;
  53450. protected _dumpPropertiesCode(): string;
  53451. serialize(): any;
  53452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53453. }
  53454. }
  53455. declare module BABYLON {
  53456. /**
  53457. * Block used to add image processing support to fragment shader
  53458. */
  53459. export class ImageProcessingBlock extends NodeMaterialBlock {
  53460. /**
  53461. * Create a new ImageProcessingBlock
  53462. * @param name defines the block name
  53463. */
  53464. constructor(name: string);
  53465. /**
  53466. * Gets the current class name
  53467. * @returns the class name
  53468. */
  53469. getClassName(): string;
  53470. /**
  53471. * Gets the color input component
  53472. */
  53473. readonly color: NodeMaterialConnectionPoint;
  53474. /**
  53475. * Gets the output component
  53476. */
  53477. readonly output: NodeMaterialConnectionPoint;
  53478. /**
  53479. * Initialize the block and prepare the context for build
  53480. * @param state defines the state that will be used for the build
  53481. */
  53482. initialize(state: NodeMaterialBuildState): void;
  53483. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53486. protected _buildBlock(state: NodeMaterialBuildState): this;
  53487. }
  53488. }
  53489. declare module BABYLON {
  53490. /**
  53491. * Block used to add support for scene fog
  53492. */
  53493. export class FogBlock extends NodeMaterialBlock {
  53494. private _fogDistanceName;
  53495. private _fogParameters;
  53496. /**
  53497. * Create a new FogBlock
  53498. * @param name defines the block name
  53499. */
  53500. constructor(name: string);
  53501. /**
  53502. * Gets the current class name
  53503. * @returns the class name
  53504. */
  53505. getClassName(): string;
  53506. /**
  53507. * Gets the world position input component
  53508. */
  53509. readonly worldPosition: NodeMaterialConnectionPoint;
  53510. /**
  53511. * Gets the view input component
  53512. */
  53513. readonly view: NodeMaterialConnectionPoint;
  53514. /**
  53515. * Gets the color input component
  53516. */
  53517. readonly input: NodeMaterialConnectionPoint;
  53518. /**
  53519. * Gets the fog color input component
  53520. */
  53521. readonly fogColor: NodeMaterialConnectionPoint;
  53522. /**
  53523. * Gets the output component
  53524. */
  53525. readonly output: NodeMaterialConnectionPoint;
  53526. autoConfigure(material: NodeMaterial): void;
  53527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53529. protected _buildBlock(state: NodeMaterialBuildState): this;
  53530. }
  53531. }
  53532. declare module BABYLON {
  53533. /**
  53534. * Block used to add light in the fragment shader
  53535. */
  53536. export class LightBlock extends NodeMaterialBlock {
  53537. private _lightId;
  53538. /**
  53539. * Gets or sets the light associated with this block
  53540. */
  53541. light: Nullable<Light>;
  53542. /**
  53543. * Create a new LightBlock
  53544. * @param name defines the block name
  53545. */
  53546. constructor(name: string);
  53547. /**
  53548. * Gets the current class name
  53549. * @returns the class name
  53550. */
  53551. getClassName(): string;
  53552. /**
  53553. * Gets the world position input component
  53554. */
  53555. readonly worldPosition: NodeMaterialConnectionPoint;
  53556. /**
  53557. * Gets the world normal input component
  53558. */
  53559. readonly worldNormal: NodeMaterialConnectionPoint;
  53560. /**
  53561. * Gets the camera (or eye) position component
  53562. */
  53563. readonly cameraPosition: NodeMaterialConnectionPoint;
  53564. /**
  53565. * Gets the diffuse output component
  53566. */
  53567. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53568. /**
  53569. * Gets the specular output component
  53570. */
  53571. readonly specularOutput: NodeMaterialConnectionPoint;
  53572. autoConfigure(material: NodeMaterial): void;
  53573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53574. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53576. private _injectVertexCode;
  53577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53578. serialize(): any;
  53579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53580. }
  53581. }
  53582. declare module BABYLON {
  53583. /**
  53584. * Block used to multiply 2 values
  53585. */
  53586. export class MultiplyBlock extends NodeMaterialBlock {
  53587. /**
  53588. * Creates a new MultiplyBlock
  53589. * @param name defines the block name
  53590. */
  53591. constructor(name: string);
  53592. /**
  53593. * Gets the current class name
  53594. * @returns the class name
  53595. */
  53596. getClassName(): string;
  53597. /**
  53598. * Gets the left operand input component
  53599. */
  53600. readonly left: NodeMaterialConnectionPoint;
  53601. /**
  53602. * Gets the right operand input component
  53603. */
  53604. readonly right: NodeMaterialConnectionPoint;
  53605. /**
  53606. * Gets the output component
  53607. */
  53608. readonly output: NodeMaterialConnectionPoint;
  53609. protected _buildBlock(state: NodeMaterialBuildState): this;
  53610. }
  53611. }
  53612. declare module BABYLON {
  53613. /**
  53614. * Block used to add 2 vectors
  53615. */
  53616. export class AddBlock extends NodeMaterialBlock {
  53617. /**
  53618. * Creates a new AddBlock
  53619. * @param name defines the block name
  53620. */
  53621. constructor(name: string);
  53622. /**
  53623. * Gets the current class name
  53624. * @returns the class name
  53625. */
  53626. getClassName(): string;
  53627. /**
  53628. * Gets the left operand input component
  53629. */
  53630. readonly left: NodeMaterialConnectionPoint;
  53631. /**
  53632. * Gets the right operand input component
  53633. */
  53634. readonly right: NodeMaterialConnectionPoint;
  53635. /**
  53636. * Gets the output component
  53637. */
  53638. readonly output: NodeMaterialConnectionPoint;
  53639. protected _buildBlock(state: NodeMaterialBuildState): this;
  53640. }
  53641. }
  53642. declare module BABYLON {
  53643. /**
  53644. * Block used to scale a vector by a float
  53645. */
  53646. export class ScaleBlock extends NodeMaterialBlock {
  53647. /**
  53648. * Creates a new ScaleBlock
  53649. * @param name defines the block name
  53650. */
  53651. constructor(name: string);
  53652. /**
  53653. * Gets the current class name
  53654. * @returns the class name
  53655. */
  53656. getClassName(): string;
  53657. /**
  53658. * Gets the input component
  53659. */
  53660. readonly input: NodeMaterialConnectionPoint;
  53661. /**
  53662. * Gets the factor input component
  53663. */
  53664. readonly factor: NodeMaterialConnectionPoint;
  53665. /**
  53666. * Gets the output component
  53667. */
  53668. readonly output: NodeMaterialConnectionPoint;
  53669. protected _buildBlock(state: NodeMaterialBuildState): this;
  53670. }
  53671. }
  53672. declare module BABYLON {
  53673. /**
  53674. * Block used to clamp a float
  53675. */
  53676. export class ClampBlock extends NodeMaterialBlock {
  53677. /** Gets or sets the minimum range */
  53678. minimum: number;
  53679. /** Gets or sets the maximum range */
  53680. maximum: number;
  53681. /**
  53682. * Creates a new ClampBlock
  53683. * @param name defines the block name
  53684. */
  53685. constructor(name: string);
  53686. /**
  53687. * Gets the current class name
  53688. * @returns the class name
  53689. */
  53690. getClassName(): string;
  53691. /**
  53692. * Gets the value input component
  53693. */
  53694. readonly value: NodeMaterialConnectionPoint;
  53695. /**
  53696. * Gets the output component
  53697. */
  53698. readonly output: NodeMaterialConnectionPoint;
  53699. protected _buildBlock(state: NodeMaterialBuildState): this;
  53700. protected _dumpPropertiesCode(): string;
  53701. serialize(): any;
  53702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53703. }
  53704. }
  53705. declare module BABYLON {
  53706. /**
  53707. * Block used to apply a cross product between 2 vectors
  53708. */
  53709. export class CrossBlock extends NodeMaterialBlock {
  53710. /**
  53711. * Creates a new CrossBlock
  53712. * @param name defines the block name
  53713. */
  53714. constructor(name: string);
  53715. /**
  53716. * Gets the current class name
  53717. * @returns the class name
  53718. */
  53719. getClassName(): string;
  53720. /**
  53721. * Gets the left operand input component
  53722. */
  53723. readonly left: NodeMaterialConnectionPoint;
  53724. /**
  53725. * Gets the right operand input component
  53726. */
  53727. readonly right: NodeMaterialConnectionPoint;
  53728. /**
  53729. * Gets the output component
  53730. */
  53731. readonly output: NodeMaterialConnectionPoint;
  53732. protected _buildBlock(state: NodeMaterialBuildState): this;
  53733. }
  53734. }
  53735. declare module BABYLON {
  53736. /**
  53737. * Block used to apply a dot product between 2 vectors
  53738. */
  53739. export class DotBlock extends NodeMaterialBlock {
  53740. /**
  53741. * Creates a new DotBlock
  53742. * @param name defines the block name
  53743. */
  53744. constructor(name: string);
  53745. /**
  53746. * Gets the current class name
  53747. * @returns the class name
  53748. */
  53749. getClassName(): string;
  53750. /**
  53751. * Gets the left operand input component
  53752. */
  53753. readonly left: NodeMaterialConnectionPoint;
  53754. /**
  53755. * Gets the right operand input component
  53756. */
  53757. readonly right: NodeMaterialConnectionPoint;
  53758. /**
  53759. * Gets the output component
  53760. */
  53761. readonly output: NodeMaterialConnectionPoint;
  53762. protected _buildBlock(state: NodeMaterialBuildState): this;
  53763. }
  53764. }
  53765. declare module BABYLON {
  53766. /**
  53767. * Block used to remap a float from a range to a new one
  53768. */
  53769. export class RemapBlock extends NodeMaterialBlock {
  53770. /**
  53771. * Gets or sets the source range
  53772. */
  53773. sourceRange: Vector2;
  53774. /**
  53775. * Gets or sets the target range
  53776. */
  53777. targetRange: Vector2;
  53778. /**
  53779. * Creates a new RemapBlock
  53780. * @param name defines the block name
  53781. */
  53782. constructor(name: string);
  53783. /**
  53784. * Gets the current class name
  53785. * @returns the class name
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Gets the input component
  53790. */
  53791. readonly input: NodeMaterialConnectionPoint;
  53792. /**
  53793. * Gets the output component
  53794. */
  53795. readonly output: NodeMaterialConnectionPoint;
  53796. protected _buildBlock(state: NodeMaterialBuildState): this;
  53797. protected _dumpPropertiesCode(): string;
  53798. serialize(): any;
  53799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53800. }
  53801. }
  53802. declare module BABYLON {
  53803. /**
  53804. * Block used to normalize a vector
  53805. */
  53806. export class NormalizeBlock extends NodeMaterialBlock {
  53807. /**
  53808. * Creates a new NormalizeBlock
  53809. * @param name defines the block name
  53810. */
  53811. constructor(name: string);
  53812. /**
  53813. * Gets the current class name
  53814. * @returns the class name
  53815. */
  53816. getClassName(): string;
  53817. /**
  53818. * Gets the input component
  53819. */
  53820. readonly input: NodeMaterialConnectionPoint;
  53821. /**
  53822. * Gets the output component
  53823. */
  53824. readonly output: NodeMaterialConnectionPoint;
  53825. protected _buildBlock(state: NodeMaterialBuildState): this;
  53826. }
  53827. }
  53828. declare module BABYLON {
  53829. /**
  53830. * Operations supported by the Trigonometry block
  53831. */
  53832. export enum TrigonometryBlockOperations {
  53833. /** Cos */
  53834. Cos = 0,
  53835. /** Sin */
  53836. Sin = 1,
  53837. /** Abs */
  53838. Abs = 2,
  53839. /** Exp */
  53840. Exp = 3,
  53841. /** Exp2 */
  53842. Exp2 = 4,
  53843. /** Round */
  53844. Round = 5,
  53845. /** Floor */
  53846. Floor = 6,
  53847. /** Ceiling */
  53848. Ceiling = 7
  53849. }
  53850. /**
  53851. * Block used to apply trigonometry operation to floats
  53852. */
  53853. export class TrigonometryBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Gets or sets the operation applied by the block
  53856. */
  53857. operation: TrigonometryBlockOperations;
  53858. /**
  53859. * Creates a new TrigonometryBlock
  53860. * @param name defines the block name
  53861. */
  53862. constructor(name: string);
  53863. /**
  53864. * Gets the current class name
  53865. * @returns the class name
  53866. */
  53867. getClassName(): string;
  53868. /**
  53869. * Gets the input component
  53870. */
  53871. readonly input: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the output component
  53874. */
  53875. readonly output: NodeMaterialConnectionPoint;
  53876. protected _buildBlock(state: NodeMaterialBuildState): this;
  53877. serialize(): any;
  53878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /**
  53883. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53884. */
  53885. export class ColorMergerBlock extends NodeMaterialBlock {
  53886. /**
  53887. * Create a new ColorMergerBlock
  53888. * @param name defines the block name
  53889. */
  53890. constructor(name: string);
  53891. /**
  53892. * Gets the current class name
  53893. * @returns the class name
  53894. */
  53895. getClassName(): string;
  53896. /**
  53897. * Gets the r component (input)
  53898. */
  53899. readonly r: NodeMaterialConnectionPoint;
  53900. /**
  53901. * Gets the g component (input)
  53902. */
  53903. readonly g: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the b component (input)
  53906. */
  53907. readonly b: NodeMaterialConnectionPoint;
  53908. /**
  53909. * Gets the a component (input)
  53910. */
  53911. readonly a: NodeMaterialConnectionPoint;
  53912. /**
  53913. * Gets the rgba component (output)
  53914. */
  53915. readonly rgba: NodeMaterialConnectionPoint;
  53916. /**
  53917. * Gets the rgb component (output)
  53918. */
  53919. readonly rgb: NodeMaterialConnectionPoint;
  53920. protected _buildBlock(state: NodeMaterialBuildState): this;
  53921. }
  53922. }
  53923. declare module BABYLON {
  53924. /**
  53925. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53926. */
  53927. export class VectorMergerBlock extends NodeMaterialBlock {
  53928. /**
  53929. * Create a new VectorMergerBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the x component (input)
  53940. */
  53941. readonly x: NodeMaterialConnectionPoint;
  53942. /**
  53943. * Gets the y component (input)
  53944. */
  53945. readonly y: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the z component (input)
  53948. */
  53949. readonly z: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the w component (input)
  53952. */
  53953. readonly w: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the xyzw component (output)
  53956. */
  53957. readonly xyzw: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the xyz component (output)
  53960. */
  53961. readonly xyz: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the xy component (output)
  53964. */
  53965. readonly xy: NodeMaterialConnectionPoint;
  53966. protected _buildBlock(state: NodeMaterialBuildState): this;
  53967. }
  53968. }
  53969. declare module BABYLON {
  53970. /**
  53971. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53972. */
  53973. export class ColorSplitterBlock extends NodeMaterialBlock {
  53974. /**
  53975. * Create a new ColorSplitterBlock
  53976. * @param name defines the block name
  53977. */
  53978. constructor(name: string);
  53979. /**
  53980. * Gets the current class name
  53981. * @returns the class name
  53982. */
  53983. getClassName(): string;
  53984. /**
  53985. * Gets the rgba component (input)
  53986. */
  53987. readonly rgba: NodeMaterialConnectionPoint;
  53988. /**
  53989. * Gets the rgb component (input)
  53990. */
  53991. readonly rgbIn: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the rgb component (output)
  53994. */
  53995. readonly rgbOut: NodeMaterialConnectionPoint;
  53996. /**
  53997. * Gets the r component (output)
  53998. */
  53999. readonly r: NodeMaterialConnectionPoint;
  54000. /**
  54001. * Gets the g component (output)
  54002. */
  54003. readonly g: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the b component (output)
  54006. */
  54007. readonly b: NodeMaterialConnectionPoint;
  54008. /**
  54009. * Gets the a component (output)
  54010. */
  54011. readonly a: NodeMaterialConnectionPoint;
  54012. protected _inputRename(name: string): string;
  54013. protected _outputRename(name: string): string;
  54014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54015. }
  54016. }
  54017. declare module BABYLON {
  54018. /**
  54019. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54020. */
  54021. export class VectorSplitterBlock extends NodeMaterialBlock {
  54022. /**
  54023. * Create a new VectorSplitterBlock
  54024. * @param name defines the block name
  54025. */
  54026. constructor(name: string);
  54027. /**
  54028. * Gets the current class name
  54029. * @returns the class name
  54030. */
  54031. getClassName(): string;
  54032. /**
  54033. * Gets the xyzw component (input)
  54034. */
  54035. readonly xyzw: NodeMaterialConnectionPoint;
  54036. /**
  54037. * Gets the xyz component (input)
  54038. */
  54039. readonly xyzIn: NodeMaterialConnectionPoint;
  54040. /**
  54041. * Gets the xy component (input)
  54042. */
  54043. readonly xyIn: NodeMaterialConnectionPoint;
  54044. /**
  54045. * Gets the xyz component (output)
  54046. */
  54047. readonly xyzOut: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the xy component (output)
  54050. */
  54051. readonly xyOut: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the x component (output)
  54054. */
  54055. readonly x: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the y component (output)
  54058. */
  54059. readonly y: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the z component (output)
  54062. */
  54063. readonly z: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the w component (output)
  54066. */
  54067. readonly w: NodeMaterialConnectionPoint;
  54068. protected _inputRename(name: string): string;
  54069. protected _outputRename(name: string): string;
  54070. protected _buildBlock(state: NodeMaterialBuildState): this;
  54071. }
  54072. }
  54073. declare module BABYLON {
  54074. /**
  54075. * Block used to lerp 2 values
  54076. */
  54077. export class LerpBlock extends NodeMaterialBlock {
  54078. /**
  54079. * Creates a new LerpBlock
  54080. * @param name defines the block name
  54081. */
  54082. constructor(name: string);
  54083. /**
  54084. * Gets the current class name
  54085. * @returns the class name
  54086. */
  54087. getClassName(): string;
  54088. /**
  54089. * Gets the left operand input component
  54090. */
  54091. readonly left: NodeMaterialConnectionPoint;
  54092. /**
  54093. * Gets the right operand input component
  54094. */
  54095. readonly right: NodeMaterialConnectionPoint;
  54096. /**
  54097. * Gets the gradient operand input component
  54098. */
  54099. readonly gradient: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the output component
  54102. */
  54103. readonly output: NodeMaterialConnectionPoint;
  54104. protected _buildBlock(state: NodeMaterialBuildState): this;
  54105. }
  54106. }
  54107. declare module BABYLON {
  54108. /**
  54109. * Block used to divide 2 vectors
  54110. */
  54111. export class DivideBlock extends NodeMaterialBlock {
  54112. /**
  54113. * Creates a new DivideBlock
  54114. * @param name defines the block name
  54115. */
  54116. constructor(name: string);
  54117. /**
  54118. * Gets the current class name
  54119. * @returns the class name
  54120. */
  54121. getClassName(): string;
  54122. /**
  54123. * Gets the left operand input component
  54124. */
  54125. readonly left: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the right operand input component
  54128. */
  54129. readonly right: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the output component
  54132. */
  54133. readonly output: NodeMaterialConnectionPoint;
  54134. protected _buildBlock(state: NodeMaterialBuildState): this;
  54135. }
  54136. }
  54137. declare module BABYLON {
  54138. /**
  54139. * Block used to subtract 2 vectors
  54140. */
  54141. export class SubtractBlock extends NodeMaterialBlock {
  54142. /**
  54143. * Creates a new SubtractBlock
  54144. * @param name defines the block name
  54145. */
  54146. constructor(name: string);
  54147. /**
  54148. * Gets the current class name
  54149. * @returns the class name
  54150. */
  54151. getClassName(): string;
  54152. /**
  54153. * Gets the left operand input component
  54154. */
  54155. readonly left: NodeMaterialConnectionPoint;
  54156. /**
  54157. * Gets the right operand input component
  54158. */
  54159. readonly right: NodeMaterialConnectionPoint;
  54160. /**
  54161. * Gets the output component
  54162. */
  54163. readonly output: NodeMaterialConnectionPoint;
  54164. protected _buildBlock(state: NodeMaterialBuildState): this;
  54165. }
  54166. }
  54167. declare module BABYLON {
  54168. /**
  54169. * Block used to step a value
  54170. */
  54171. export class StepBlock extends NodeMaterialBlock {
  54172. /**
  54173. * Creates a new AddBlock
  54174. * @param name defines the block name
  54175. */
  54176. constructor(name: string);
  54177. /**
  54178. * Gets the current class name
  54179. * @returns the class name
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Gets the value operand input component
  54184. */
  54185. readonly value: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the edge operand input component
  54188. */
  54189. readonly edge: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the output component
  54192. */
  54193. readonly output: NodeMaterialConnectionPoint;
  54194. protected _buildBlock(state: NodeMaterialBuildState): this;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * Block used to get the opposite of a value
  54200. */
  54201. export class OppositeBlock extends NodeMaterialBlock {
  54202. /**
  54203. * Creates a new OppositeBlock
  54204. * @param name defines the block name
  54205. */
  54206. constructor(name: string);
  54207. /**
  54208. * Gets the current class name
  54209. * @returns the class name
  54210. */
  54211. getClassName(): string;
  54212. /**
  54213. * Gets the input component
  54214. */
  54215. readonly input: NodeMaterialConnectionPoint;
  54216. /**
  54217. * Gets the output component
  54218. */
  54219. readonly output: NodeMaterialConnectionPoint;
  54220. protected _buildBlock(state: NodeMaterialBuildState): this;
  54221. }
  54222. }
  54223. declare module BABYLON {
  54224. /**
  54225. * Block used to get the view direction
  54226. */
  54227. export class ViewDirectionBlock extends NodeMaterialBlock {
  54228. /**
  54229. * Creates a new ViewDirectionBlock
  54230. * @param name defines the block name
  54231. */
  54232. constructor(name: string);
  54233. /**
  54234. * Gets the current class name
  54235. * @returns the class name
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Gets the world position component
  54240. */
  54241. readonly worldPosition: NodeMaterialConnectionPoint;
  54242. /**
  54243. * Gets the camera position component
  54244. */
  54245. readonly cameraPosition: NodeMaterialConnectionPoint;
  54246. /**
  54247. * Gets the output component
  54248. */
  54249. readonly output: NodeMaterialConnectionPoint;
  54250. autoConfigure(material: NodeMaterial): void;
  54251. protected _buildBlock(state: NodeMaterialBuildState): this;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * Block used to compute fresnel value
  54257. */
  54258. export class FresnelBlock extends NodeMaterialBlock {
  54259. /**
  54260. * Create a new FresnelBlock
  54261. * @param name defines the block name
  54262. */
  54263. constructor(name: string);
  54264. /**
  54265. * Gets the current class name
  54266. * @returns the class name
  54267. */
  54268. getClassName(): string;
  54269. /**
  54270. * Gets the world normal input component
  54271. */
  54272. readonly worldNormal: NodeMaterialConnectionPoint;
  54273. /**
  54274. * Gets the view direction input component
  54275. */
  54276. readonly viewDirection: NodeMaterialConnectionPoint;
  54277. /**
  54278. * Gets the bias input component
  54279. */
  54280. readonly bias: NodeMaterialConnectionPoint;
  54281. /**
  54282. * Gets the camera (or eye) position component
  54283. */
  54284. readonly power: NodeMaterialConnectionPoint;
  54285. /**
  54286. * Gets the fresnel output component
  54287. */
  54288. readonly fresnel: NodeMaterialConnectionPoint;
  54289. autoConfigure(material: NodeMaterial): void;
  54290. protected _buildBlock(state: NodeMaterialBuildState): this;
  54291. }
  54292. }
  54293. declare module BABYLON {
  54294. /**
  54295. * Block used to get the max of 2 values
  54296. */
  54297. export class MaxBlock extends NodeMaterialBlock {
  54298. /**
  54299. * Creates a new MaxBlock
  54300. * @param name defines the block name
  54301. */
  54302. constructor(name: string);
  54303. /**
  54304. * Gets the current class name
  54305. * @returns the class name
  54306. */
  54307. getClassName(): string;
  54308. /**
  54309. * Gets the left operand input component
  54310. */
  54311. readonly left: NodeMaterialConnectionPoint;
  54312. /**
  54313. * Gets the right operand input component
  54314. */
  54315. readonly right: NodeMaterialConnectionPoint;
  54316. /**
  54317. * Gets the output component
  54318. */
  54319. readonly output: NodeMaterialConnectionPoint;
  54320. protected _buildBlock(state: NodeMaterialBuildState): this;
  54321. }
  54322. }
  54323. declare module BABYLON {
  54324. /**
  54325. * Block used to get the min of 2 values
  54326. */
  54327. export class MinBlock extends NodeMaterialBlock {
  54328. /**
  54329. * Creates a new MinBlock
  54330. * @param name defines the block name
  54331. */
  54332. constructor(name: string);
  54333. /**
  54334. * Gets the current class name
  54335. * @returns the class name
  54336. */
  54337. getClassName(): string;
  54338. /**
  54339. * Gets the left operand input component
  54340. */
  54341. readonly left: NodeMaterialConnectionPoint;
  54342. /**
  54343. * Gets the right operand input component
  54344. */
  54345. readonly right: NodeMaterialConnectionPoint;
  54346. /**
  54347. * Gets the output component
  54348. */
  54349. readonly output: NodeMaterialConnectionPoint;
  54350. protected _buildBlock(state: NodeMaterialBuildState): this;
  54351. }
  54352. }
  54353. declare module BABYLON {
  54354. /**
  54355. * Effect Render Options
  54356. */
  54357. export interface IEffectRendererOptions {
  54358. /**
  54359. * Defines the vertices positions.
  54360. */
  54361. positions?: number[];
  54362. /**
  54363. * Defines the indices.
  54364. */
  54365. indices?: number[];
  54366. }
  54367. /**
  54368. * Helper class to render one or more effects
  54369. */
  54370. export class EffectRenderer {
  54371. private engine;
  54372. private static _DefaultOptions;
  54373. private _vertexBuffers;
  54374. private _indexBuffer;
  54375. private _ringBufferIndex;
  54376. private _ringScreenBuffer;
  54377. private _fullscreenViewport;
  54378. private _getNextFrameBuffer;
  54379. /**
  54380. * Creates an effect renderer
  54381. * @param engine the engine to use for rendering
  54382. * @param options defines the options of the effect renderer
  54383. */
  54384. constructor(engine: Engine, options?: IEffectRendererOptions);
  54385. /**
  54386. * Sets the current viewport in normalized coordinates 0-1
  54387. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54388. */
  54389. setViewport(viewport?: Viewport): void;
  54390. /**
  54391. * Binds the embedded attributes buffer to the effect.
  54392. * @param effect Defines the effect to bind the attributes for
  54393. */
  54394. bindBuffers(effect: Effect): void;
  54395. /**
  54396. * Sets the current effect wrapper to use during draw.
  54397. * The effect needs to be ready before calling this api.
  54398. * This also sets the default full screen position attribute.
  54399. * @param effectWrapper Defines the effect to draw with
  54400. */
  54401. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54402. /**
  54403. * Draws a full screen quad.
  54404. */
  54405. draw(): void;
  54406. /**
  54407. * renders one or more effects to a specified texture
  54408. * @param effectWrappers list of effects to renderer
  54409. * @param outputTexture texture to draw to, if null it will render to the screen
  54410. */
  54411. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54412. /**
  54413. * Disposes of the effect renderer
  54414. */
  54415. dispose(): void;
  54416. }
  54417. /**
  54418. * Options to create an EffectWrapper
  54419. */
  54420. interface EffectWrapperCreationOptions {
  54421. /**
  54422. * Engine to use to create the effect
  54423. */
  54424. engine: Engine;
  54425. /**
  54426. * Fragment shader for the effect
  54427. */
  54428. fragmentShader: string;
  54429. /**
  54430. * Vertex shader for the effect
  54431. */
  54432. vertexShader?: string;
  54433. /**
  54434. * Attributes to use in the shader
  54435. */
  54436. attributeNames?: Array<string>;
  54437. /**
  54438. * Uniforms to use in the shader
  54439. */
  54440. uniformNames?: Array<string>;
  54441. /**
  54442. * Texture sampler names to use in the shader
  54443. */
  54444. samplerNames?: Array<string>;
  54445. /**
  54446. * The friendly name of the effect displayed in Spector.
  54447. */
  54448. name?: string;
  54449. }
  54450. /**
  54451. * Wraps an effect to be used for rendering
  54452. */
  54453. export class EffectWrapper {
  54454. /**
  54455. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54456. */
  54457. onApplyObservable: Observable<{}>;
  54458. /**
  54459. * The underlying effect
  54460. */
  54461. effect: Effect;
  54462. /**
  54463. * Creates an effect to be renderer
  54464. * @param creationOptions options to create the effect
  54465. */
  54466. constructor(creationOptions: EffectWrapperCreationOptions);
  54467. /**
  54468. * Disposes of the effect wrapper
  54469. */
  54470. dispose(): void;
  54471. }
  54472. }
  54473. declare module BABYLON {
  54474. /**
  54475. * Helper class to push actions to a pool of workers.
  54476. */
  54477. export class WorkerPool implements IDisposable {
  54478. private _workerInfos;
  54479. private _pendingActions;
  54480. /**
  54481. * Constructor
  54482. * @param workers Array of workers to use for actions
  54483. */
  54484. constructor(workers: Array<Worker>);
  54485. /**
  54486. * Terminates all workers and clears any pending actions.
  54487. */
  54488. dispose(): void;
  54489. /**
  54490. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54491. * pended until a worker has completed its action.
  54492. * @param action The action to perform. Call onComplete when the action is complete.
  54493. */
  54494. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54495. private _execute;
  54496. }
  54497. }
  54498. declare module BABYLON {
  54499. /**
  54500. * Configuration for Draco compression
  54501. */
  54502. export interface IDracoCompressionConfiguration {
  54503. /**
  54504. * Configuration for the decoder.
  54505. */
  54506. decoder: {
  54507. /**
  54508. * The url to the WebAssembly module.
  54509. */
  54510. wasmUrl?: string;
  54511. /**
  54512. * The url to the WebAssembly binary.
  54513. */
  54514. wasmBinaryUrl?: string;
  54515. /**
  54516. * The url to the fallback JavaScript module.
  54517. */
  54518. fallbackUrl?: string;
  54519. };
  54520. }
  54521. /**
  54522. * Draco compression (https://google.github.io/draco/)
  54523. *
  54524. * This class wraps the Draco module.
  54525. *
  54526. * **Encoder**
  54527. *
  54528. * The encoder is not currently implemented.
  54529. *
  54530. * **Decoder**
  54531. *
  54532. * 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.
  54533. *
  54534. * To update the configuration, use the following code:
  54535. * ```javascript
  54536. * DracoCompression.Configuration = {
  54537. * decoder: {
  54538. * wasmUrl: "<url to the WebAssembly library>",
  54539. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54540. * fallbackUrl: "<url to the fallback JavaScript library>",
  54541. * }
  54542. * };
  54543. * ```
  54544. *
  54545. * 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.
  54546. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54547. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54548. *
  54549. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54550. * ```javascript
  54551. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54552. * ```
  54553. *
  54554. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54555. */
  54556. export class DracoCompression implements IDisposable {
  54557. private _workerPoolPromise?;
  54558. private _decoderModulePromise?;
  54559. /**
  54560. * The configuration. Defaults to the following urls:
  54561. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54562. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54563. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54564. */
  54565. static Configuration: IDracoCompressionConfiguration;
  54566. /**
  54567. * Returns true if the decoder configuration is available.
  54568. */
  54569. static readonly DecoderAvailable: boolean;
  54570. /**
  54571. * Default number of workers to create when creating the draco compression object.
  54572. */
  54573. static DefaultNumWorkers: number;
  54574. private static GetDefaultNumWorkers;
  54575. private static _Default;
  54576. /**
  54577. * Default instance for the draco compression object.
  54578. */
  54579. static readonly Default: DracoCompression;
  54580. /**
  54581. * Constructor
  54582. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54583. */
  54584. constructor(numWorkers?: number);
  54585. /**
  54586. * Stop all async operations and release resources.
  54587. */
  54588. dispose(): void;
  54589. /**
  54590. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54591. * @returns a promise that resolves when ready
  54592. */
  54593. whenReadyAsync(): Promise<void>;
  54594. /**
  54595. * Decode Draco compressed mesh data to vertex data.
  54596. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54597. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54598. * @returns A promise that resolves with the decoded vertex data
  54599. */
  54600. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54601. [kind: string]: number;
  54602. }): Promise<VertexData>;
  54603. }
  54604. }
  54605. declare module BABYLON {
  54606. /**
  54607. * Class for building Constructive Solid Geometry
  54608. */
  54609. export class CSG {
  54610. private polygons;
  54611. /**
  54612. * The world matrix
  54613. */
  54614. matrix: Matrix;
  54615. /**
  54616. * Stores the position
  54617. */
  54618. position: Vector3;
  54619. /**
  54620. * Stores the rotation
  54621. */
  54622. rotation: Vector3;
  54623. /**
  54624. * Stores the rotation quaternion
  54625. */
  54626. rotationQuaternion: Nullable<Quaternion>;
  54627. /**
  54628. * Stores the scaling vector
  54629. */
  54630. scaling: Vector3;
  54631. /**
  54632. * Convert the Mesh to CSG
  54633. * @param mesh The Mesh to convert to CSG
  54634. * @returns A new CSG from the Mesh
  54635. */
  54636. static FromMesh(mesh: Mesh): CSG;
  54637. /**
  54638. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54639. * @param polygons Polygons used to construct a CSG solid
  54640. */
  54641. private static FromPolygons;
  54642. /**
  54643. * Clones, or makes a deep copy, of the CSG
  54644. * @returns A new CSG
  54645. */
  54646. clone(): CSG;
  54647. /**
  54648. * Unions this CSG with another CSG
  54649. * @param csg The CSG to union against this CSG
  54650. * @returns The unioned CSG
  54651. */
  54652. union(csg: CSG): CSG;
  54653. /**
  54654. * Unions this CSG with another CSG in place
  54655. * @param csg The CSG to union against this CSG
  54656. */
  54657. unionInPlace(csg: CSG): void;
  54658. /**
  54659. * Subtracts this CSG with another CSG
  54660. * @param csg The CSG to subtract against this CSG
  54661. * @returns A new CSG
  54662. */
  54663. subtract(csg: CSG): CSG;
  54664. /**
  54665. * Subtracts this CSG with another CSG in place
  54666. * @param csg The CSG to subtact against this CSG
  54667. */
  54668. subtractInPlace(csg: CSG): void;
  54669. /**
  54670. * Intersect this CSG with another CSG
  54671. * @param csg The CSG to intersect against this CSG
  54672. * @returns A new CSG
  54673. */
  54674. intersect(csg: CSG): CSG;
  54675. /**
  54676. * Intersects this CSG with another CSG in place
  54677. * @param csg The CSG to intersect against this CSG
  54678. */
  54679. intersectInPlace(csg: CSG): void;
  54680. /**
  54681. * Return a new CSG solid with solid and empty space switched. This solid is
  54682. * not modified.
  54683. * @returns A new CSG solid with solid and empty space switched
  54684. */
  54685. inverse(): CSG;
  54686. /**
  54687. * Inverses the CSG in place
  54688. */
  54689. inverseInPlace(): void;
  54690. /**
  54691. * This is used to keep meshes transformations so they can be restored
  54692. * when we build back a Babylon Mesh
  54693. * NB : All CSG operations are performed in world coordinates
  54694. * @param csg The CSG to copy the transform attributes from
  54695. * @returns This CSG
  54696. */
  54697. copyTransformAttributes(csg: CSG): CSG;
  54698. /**
  54699. * Build Raw mesh from CSG
  54700. * Coordinates here are in world space
  54701. * @param name The name of the mesh geometry
  54702. * @param scene The Scene
  54703. * @param keepSubMeshes Specifies if the submeshes should be kept
  54704. * @returns A new Mesh
  54705. */
  54706. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54707. /**
  54708. * Build Mesh from CSG taking material and transforms into account
  54709. * @param name The name of the Mesh
  54710. * @param material The material of the Mesh
  54711. * @param scene The Scene
  54712. * @param keepSubMeshes Specifies if submeshes should be kept
  54713. * @returns The new Mesh
  54714. */
  54715. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54716. }
  54717. }
  54718. declare module BABYLON {
  54719. /**
  54720. * Class used to create a trail following a mesh
  54721. */
  54722. export class TrailMesh extends Mesh {
  54723. private _generator;
  54724. private _autoStart;
  54725. private _running;
  54726. private _diameter;
  54727. private _length;
  54728. private _sectionPolygonPointsCount;
  54729. private _sectionVectors;
  54730. private _sectionNormalVectors;
  54731. private _beforeRenderObserver;
  54732. /**
  54733. * @constructor
  54734. * @param name The value used by scene.getMeshByName() to do a lookup.
  54735. * @param generator The mesh to generate a trail.
  54736. * @param scene The scene to add this mesh to.
  54737. * @param diameter Diameter of trailing mesh. Default is 1.
  54738. * @param length Length of trailing mesh. Default is 60.
  54739. * @param autoStart Automatically start trailing mesh. Default true.
  54740. */
  54741. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54742. /**
  54743. * "TrailMesh"
  54744. * @returns "TrailMesh"
  54745. */
  54746. getClassName(): string;
  54747. private _createMesh;
  54748. /**
  54749. * Start trailing mesh.
  54750. */
  54751. start(): void;
  54752. /**
  54753. * Stop trailing mesh.
  54754. */
  54755. stop(): void;
  54756. /**
  54757. * Update trailing mesh geometry.
  54758. */
  54759. update(): void;
  54760. /**
  54761. * Returns a new TrailMesh object.
  54762. * @param name is a string, the name given to the new mesh
  54763. * @param newGenerator use new generator object for cloned trail mesh
  54764. * @returns a new mesh
  54765. */
  54766. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54767. /**
  54768. * Serializes this trail mesh
  54769. * @param serializationObject object to write serialization to
  54770. */
  54771. serialize(serializationObject: any): void;
  54772. /**
  54773. * Parses a serialized trail mesh
  54774. * @param parsedMesh the serialized mesh
  54775. * @param scene the scene to create the trail mesh in
  54776. * @returns the created trail mesh
  54777. */
  54778. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54779. }
  54780. }
  54781. declare module BABYLON {
  54782. /**
  54783. * Class containing static functions to help procedurally build meshes
  54784. */
  54785. export class TiledBoxBuilder {
  54786. /**
  54787. * Creates a box mesh
  54788. * 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)
  54789. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54791. * * 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
  54792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54793. * @param name defines the name of the mesh
  54794. * @param options defines the options used to create the mesh
  54795. * @param scene defines the hosting scene
  54796. * @returns the box mesh
  54797. */
  54798. static CreateTiledBox(name: string, options: {
  54799. pattern?: number;
  54800. width?: number;
  54801. height?: number;
  54802. depth?: number;
  54803. tileSize?: number;
  54804. tileWidth?: number;
  54805. tileHeight?: number;
  54806. alignHorizontal?: number;
  54807. alignVertical?: number;
  54808. faceUV?: Vector4[];
  54809. faceColors?: Color4[];
  54810. sideOrientation?: number;
  54811. updatable?: boolean;
  54812. }, scene?: Nullable<Scene>): Mesh;
  54813. }
  54814. }
  54815. declare module BABYLON {
  54816. /**
  54817. * Class containing static functions to help procedurally build meshes
  54818. */
  54819. export class TorusKnotBuilder {
  54820. /**
  54821. * Creates a torus knot mesh
  54822. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54823. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54824. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54825. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54827. * * 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
  54828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54829. * @param name defines the name of the mesh
  54830. * @param options defines the options used to create the mesh
  54831. * @param scene defines the hosting scene
  54832. * @returns the torus knot mesh
  54833. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54834. */
  54835. static CreateTorusKnot(name: string, options: {
  54836. radius?: number;
  54837. tube?: number;
  54838. radialSegments?: number;
  54839. tubularSegments?: number;
  54840. p?: number;
  54841. q?: number;
  54842. updatable?: boolean;
  54843. sideOrientation?: number;
  54844. frontUVs?: Vector4;
  54845. backUVs?: Vector4;
  54846. }, scene: any): Mesh;
  54847. }
  54848. }
  54849. declare module BABYLON {
  54850. /**
  54851. * Polygon
  54852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54853. */
  54854. export class Polygon {
  54855. /**
  54856. * Creates a rectangle
  54857. * @param xmin bottom X coord
  54858. * @param ymin bottom Y coord
  54859. * @param xmax top X coord
  54860. * @param ymax top Y coord
  54861. * @returns points that make the resulting rectation
  54862. */
  54863. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54864. /**
  54865. * Creates a circle
  54866. * @param radius radius of circle
  54867. * @param cx scale in x
  54868. * @param cy scale in y
  54869. * @param numberOfSides number of sides that make up the circle
  54870. * @returns points that make the resulting circle
  54871. */
  54872. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54873. /**
  54874. * Creates a polygon from input string
  54875. * @param input Input polygon data
  54876. * @returns the parsed points
  54877. */
  54878. static Parse(input: string): Vector2[];
  54879. /**
  54880. * Starts building a polygon from x and y coordinates
  54881. * @param x x coordinate
  54882. * @param y y coordinate
  54883. * @returns the started path2
  54884. */
  54885. static StartingAt(x: number, y: number): Path2;
  54886. }
  54887. /**
  54888. * Builds a polygon
  54889. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54890. */
  54891. export class PolygonMeshBuilder {
  54892. private _points;
  54893. private _outlinepoints;
  54894. private _holes;
  54895. private _name;
  54896. private _scene;
  54897. private _epoints;
  54898. private _eholes;
  54899. private _addToepoint;
  54900. /**
  54901. * Babylon reference to the earcut plugin.
  54902. */
  54903. bjsEarcut: any;
  54904. /**
  54905. * Creates a PolygonMeshBuilder
  54906. * @param name name of the builder
  54907. * @param contours Path of the polygon
  54908. * @param scene scene to add to when creating the mesh
  54909. * @param earcutInjection can be used to inject your own earcut reference
  54910. */
  54911. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54912. /**
  54913. * Adds a whole within the polygon
  54914. * @param hole Array of points defining the hole
  54915. * @returns this
  54916. */
  54917. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54918. /**
  54919. * Creates the polygon
  54920. * @param updatable If the mesh should be updatable
  54921. * @param depth The depth of the mesh created
  54922. * @returns the created mesh
  54923. */
  54924. build(updatable?: boolean, depth?: number): Mesh;
  54925. /**
  54926. * Creates the polygon
  54927. * @param depth The depth of the mesh created
  54928. * @returns the created VertexData
  54929. */
  54930. buildVertexData(depth?: number): VertexData;
  54931. /**
  54932. * Adds a side to the polygon
  54933. * @param positions points that make the polygon
  54934. * @param normals normals of the polygon
  54935. * @param uvs uvs of the polygon
  54936. * @param indices indices of the polygon
  54937. * @param bounds bounds of the polygon
  54938. * @param points points of the polygon
  54939. * @param depth depth of the polygon
  54940. * @param flip flip of the polygon
  54941. */
  54942. private addSide;
  54943. }
  54944. }
  54945. declare module BABYLON {
  54946. /**
  54947. * Class containing static functions to help procedurally build meshes
  54948. */
  54949. export class PolygonBuilder {
  54950. /**
  54951. * Creates a polygon mesh
  54952. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54953. * * 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
  54954. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54956. * * 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)
  54957. * * Remember you can only change the shape positions, not their number when updating a polygon
  54958. * @param name defines the name of the mesh
  54959. * @param options defines the options used to create the mesh
  54960. * @param scene defines the hosting scene
  54961. * @param earcutInjection can be used to inject your own earcut reference
  54962. * @returns the polygon mesh
  54963. */
  54964. static CreatePolygon(name: string, options: {
  54965. shape: Vector3[];
  54966. holes?: Vector3[][];
  54967. depth?: number;
  54968. faceUV?: Vector4[];
  54969. faceColors?: Color4[];
  54970. updatable?: boolean;
  54971. sideOrientation?: number;
  54972. frontUVs?: Vector4;
  54973. backUVs?: Vector4;
  54974. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54975. /**
  54976. * Creates an extruded polygon mesh, with depth in the Y direction.
  54977. * * 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)
  54978. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54979. * @param name defines the name of the mesh
  54980. * @param options defines the options used to create the mesh
  54981. * @param scene defines the hosting scene
  54982. * @param earcutInjection can be used to inject your own earcut reference
  54983. * @returns the polygon mesh
  54984. */
  54985. static ExtrudePolygon(name: string, options: {
  54986. shape: Vector3[];
  54987. holes?: Vector3[][];
  54988. depth?: number;
  54989. faceUV?: Vector4[];
  54990. faceColors?: Color4[];
  54991. updatable?: boolean;
  54992. sideOrientation?: number;
  54993. frontUVs?: Vector4;
  54994. backUVs?: Vector4;
  54995. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54996. }
  54997. }
  54998. declare module BABYLON {
  54999. /**
  55000. * Class containing static functions to help procedurally build meshes
  55001. */
  55002. export class LatheBuilder {
  55003. /**
  55004. * Creates lathe mesh.
  55005. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55006. * * 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
  55007. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55008. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55009. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55010. * * 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
  55011. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55012. * * 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
  55013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55014. * * 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
  55015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the lathe mesh
  55021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55022. */
  55023. static CreateLathe(name: string, options: {
  55024. shape: Vector3[];
  55025. radius?: number;
  55026. tessellation?: number;
  55027. clip?: number;
  55028. arc?: number;
  55029. closed?: boolean;
  55030. updatable?: boolean;
  55031. sideOrientation?: number;
  55032. frontUVs?: Vector4;
  55033. backUVs?: Vector4;
  55034. cap?: number;
  55035. invertUV?: boolean;
  55036. }, scene?: Nullable<Scene>): Mesh;
  55037. }
  55038. }
  55039. declare module BABYLON {
  55040. /**
  55041. * Class containing static functions to help procedurally build meshes
  55042. */
  55043. export class TiledPlaneBuilder {
  55044. /**
  55045. * Creates a tiled plane mesh
  55046. * * The parameter `pattern` will, depending on value, do nothing or
  55047. * * * flip (reflect about central vertical) alternate tiles across and up
  55048. * * * flip every tile on alternate rows
  55049. * * * rotate (180 degs) alternate tiles across and up
  55050. * * * rotate every tile on alternate rows
  55051. * * * flip and rotate alternate tiles across and up
  55052. * * * flip and rotate every tile on alternate rows
  55053. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55054. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55055. * * 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
  55056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55057. * * 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)
  55058. * * 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)
  55059. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55060. * @param name defines the name of the mesh
  55061. * @param options defines the options used to create the mesh
  55062. * @param scene defines the hosting scene
  55063. * @returns the box mesh
  55064. */
  55065. static CreateTiledPlane(name: string, options: {
  55066. pattern?: number;
  55067. tileSize?: number;
  55068. tileWidth?: number;
  55069. tileHeight?: number;
  55070. size?: number;
  55071. width?: number;
  55072. height?: number;
  55073. alignHorizontal?: number;
  55074. alignVertical?: number;
  55075. sideOrientation?: number;
  55076. frontUVs?: Vector4;
  55077. backUVs?: Vector4;
  55078. updatable?: boolean;
  55079. }, scene?: Nullable<Scene>): Mesh;
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * Class containing static functions to help procedurally build meshes
  55085. */
  55086. export class TubeBuilder {
  55087. /**
  55088. * Creates a tube mesh.
  55089. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55090. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55091. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55092. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55093. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55094. * * 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)
  55095. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55096. * * 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
  55097. * * 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
  55098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55099. * * 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
  55100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55102. * @param name defines the name of the mesh
  55103. * @param options defines the options used to create the mesh
  55104. * @param scene defines the hosting scene
  55105. * @returns the tube mesh
  55106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55107. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55108. */
  55109. static CreateTube(name: string, options: {
  55110. path: Vector3[];
  55111. radius?: number;
  55112. tessellation?: number;
  55113. radiusFunction?: {
  55114. (i: number, distance: number): number;
  55115. };
  55116. cap?: number;
  55117. arc?: number;
  55118. updatable?: boolean;
  55119. sideOrientation?: number;
  55120. frontUVs?: Vector4;
  55121. backUVs?: Vector4;
  55122. instance?: Mesh;
  55123. invertUV?: boolean;
  55124. }, scene?: Nullable<Scene>): Mesh;
  55125. }
  55126. }
  55127. declare module BABYLON {
  55128. /**
  55129. * Class containing static functions to help procedurally build meshes
  55130. */
  55131. export class IcoSphereBuilder {
  55132. /**
  55133. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55134. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55135. * * 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`)
  55136. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55137. * * 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
  55138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55139. * * 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
  55140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55141. * @param name defines the name of the mesh
  55142. * @param options defines the options used to create the mesh
  55143. * @param scene defines the hosting scene
  55144. * @returns the icosahedron mesh
  55145. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55146. */
  55147. static CreateIcoSphere(name: string, options: {
  55148. radius?: number;
  55149. radiusX?: number;
  55150. radiusY?: number;
  55151. radiusZ?: number;
  55152. flat?: boolean;
  55153. subdivisions?: number;
  55154. sideOrientation?: number;
  55155. frontUVs?: Vector4;
  55156. backUVs?: Vector4;
  55157. updatable?: boolean;
  55158. }, scene?: Nullable<Scene>): Mesh;
  55159. }
  55160. }
  55161. declare module BABYLON {
  55162. /**
  55163. * Class containing static functions to help procedurally build meshes
  55164. */
  55165. export class DecalBuilder {
  55166. /**
  55167. * Creates a decal mesh.
  55168. * 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
  55169. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55170. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55171. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55172. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55173. * @param name defines the name of the mesh
  55174. * @param sourceMesh defines the mesh where the decal must be applied
  55175. * @param options defines the options used to create the mesh
  55176. * @param scene defines the hosting scene
  55177. * @returns the decal mesh
  55178. * @see https://doc.babylonjs.com/how_to/decals
  55179. */
  55180. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55181. position?: Vector3;
  55182. normal?: Vector3;
  55183. size?: Vector3;
  55184. angle?: number;
  55185. }): Mesh;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /**
  55190. * Class containing static functions to help procedurally build meshes
  55191. */
  55192. export class MeshBuilder {
  55193. /**
  55194. * Creates a box mesh
  55195. * * The parameter `size` sets the size (float) of each box side (default 1)
  55196. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55197. * * 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)
  55198. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55200. * * 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
  55201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55202. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55203. * @param name defines the name of the mesh
  55204. * @param options defines the options used to create the mesh
  55205. * @param scene defines the hosting scene
  55206. * @returns the box mesh
  55207. */
  55208. static CreateBox(name: string, options: {
  55209. size?: number;
  55210. width?: number;
  55211. height?: number;
  55212. depth?: number;
  55213. faceUV?: Vector4[];
  55214. faceColors?: Color4[];
  55215. sideOrientation?: number;
  55216. frontUVs?: Vector4;
  55217. backUVs?: Vector4;
  55218. updatable?: boolean;
  55219. }, scene?: Nullable<Scene>): Mesh;
  55220. /**
  55221. * Creates a tiled box mesh
  55222. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55224. * @param name defines the name of the mesh
  55225. * @param options defines the options used to create the mesh
  55226. * @param scene defines the hosting scene
  55227. * @returns the tiled box mesh
  55228. */
  55229. static CreateTiledBox(name: string, options: {
  55230. pattern?: number;
  55231. size?: number;
  55232. width?: number;
  55233. height?: number;
  55234. depth: number;
  55235. tileSize?: number;
  55236. tileWidth?: number;
  55237. tileHeight?: number;
  55238. faceUV?: Vector4[];
  55239. faceColors?: Color4[];
  55240. alignHorizontal?: number;
  55241. alignVertical?: number;
  55242. sideOrientation?: number;
  55243. updatable?: boolean;
  55244. }, scene?: Nullable<Scene>): Mesh;
  55245. /**
  55246. * Creates a sphere mesh
  55247. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55248. * * 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`)
  55249. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55250. * * 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
  55251. * * 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)
  55252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55253. * * 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
  55254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55255. * @param name defines the name of the mesh
  55256. * @param options defines the options used to create the mesh
  55257. * @param scene defines the hosting scene
  55258. * @returns the sphere mesh
  55259. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55260. */
  55261. static CreateSphere(name: string, options: {
  55262. segments?: number;
  55263. diameter?: number;
  55264. diameterX?: number;
  55265. diameterY?: number;
  55266. diameterZ?: number;
  55267. arc?: number;
  55268. slice?: number;
  55269. sideOrientation?: number;
  55270. frontUVs?: Vector4;
  55271. backUVs?: Vector4;
  55272. updatable?: boolean;
  55273. }, scene?: Nullable<Scene>): Mesh;
  55274. /**
  55275. * Creates a plane polygonal mesh. By default, this is a disc
  55276. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55277. * * 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
  55278. * * 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
  55279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55280. * * 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
  55281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55282. * @param name defines the name of the mesh
  55283. * @param options defines the options used to create the mesh
  55284. * @param scene defines the hosting scene
  55285. * @returns the plane polygonal mesh
  55286. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55287. */
  55288. static CreateDisc(name: string, options: {
  55289. radius?: number;
  55290. tessellation?: number;
  55291. arc?: number;
  55292. updatable?: boolean;
  55293. sideOrientation?: number;
  55294. frontUVs?: Vector4;
  55295. backUVs?: Vector4;
  55296. }, scene?: Nullable<Scene>): Mesh;
  55297. /**
  55298. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55299. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55300. * * 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`)
  55301. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55302. * * 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
  55303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55304. * * 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
  55305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55306. * @param name defines the name of the mesh
  55307. * @param options defines the options used to create the mesh
  55308. * @param scene defines the hosting scene
  55309. * @returns the icosahedron mesh
  55310. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55311. */
  55312. static CreateIcoSphere(name: string, options: {
  55313. radius?: number;
  55314. radiusX?: number;
  55315. radiusY?: number;
  55316. radiusZ?: number;
  55317. flat?: boolean;
  55318. subdivisions?: number;
  55319. sideOrientation?: number;
  55320. frontUVs?: Vector4;
  55321. backUVs?: Vector4;
  55322. updatable?: boolean;
  55323. }, scene?: Nullable<Scene>): Mesh;
  55324. /**
  55325. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55326. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55327. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55328. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55329. * * 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
  55330. * * 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
  55331. * * 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
  55332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55333. * * 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
  55334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55335. * * 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
  55336. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55337. * * 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
  55338. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55340. * @param name defines the name of the mesh
  55341. * @param options defines the options used to create the mesh
  55342. * @param scene defines the hosting scene
  55343. * @returns the ribbon mesh
  55344. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55346. */
  55347. static CreateRibbon(name: string, options: {
  55348. pathArray: Vector3[][];
  55349. closeArray?: boolean;
  55350. closePath?: boolean;
  55351. offset?: number;
  55352. updatable?: boolean;
  55353. sideOrientation?: number;
  55354. frontUVs?: Vector4;
  55355. backUVs?: Vector4;
  55356. instance?: Mesh;
  55357. invertUV?: boolean;
  55358. uvs?: Vector2[];
  55359. colors?: Color4[];
  55360. }, scene?: Nullable<Scene>): Mesh;
  55361. /**
  55362. * Creates a cylinder or a cone mesh
  55363. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55364. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55365. * * 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.
  55366. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55367. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55368. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55369. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55370. * * 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).
  55371. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55372. * * 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).
  55373. * * 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
  55374. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55375. * * 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
  55376. * * 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.
  55377. * * If `enclose` is false, a ring surface is one element.
  55378. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55379. * * 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
  55380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55383. * @param name defines the name of the mesh
  55384. * @param options defines the options used to create the mesh
  55385. * @param scene defines the hosting scene
  55386. * @returns the cylinder mesh
  55387. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55388. */
  55389. static CreateCylinder(name: string, options: {
  55390. height?: number;
  55391. diameterTop?: number;
  55392. diameterBottom?: number;
  55393. diameter?: number;
  55394. tessellation?: number;
  55395. subdivisions?: number;
  55396. arc?: number;
  55397. faceColors?: Color4[];
  55398. faceUV?: Vector4[];
  55399. updatable?: boolean;
  55400. hasRings?: boolean;
  55401. enclose?: boolean;
  55402. cap?: number;
  55403. sideOrientation?: number;
  55404. frontUVs?: Vector4;
  55405. backUVs?: Vector4;
  55406. }, scene?: Nullable<Scene>): Mesh;
  55407. /**
  55408. * Creates a torus mesh
  55409. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55410. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55411. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55413. * * 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
  55414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55415. * @param name defines the name of the mesh
  55416. * @param options defines the options used to create the mesh
  55417. * @param scene defines the hosting scene
  55418. * @returns the torus mesh
  55419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55420. */
  55421. static CreateTorus(name: string, options: {
  55422. diameter?: number;
  55423. thickness?: number;
  55424. tessellation?: number;
  55425. updatable?: boolean;
  55426. sideOrientation?: number;
  55427. frontUVs?: Vector4;
  55428. backUVs?: Vector4;
  55429. }, scene?: Nullable<Scene>): Mesh;
  55430. /**
  55431. * Creates a torus knot mesh
  55432. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55433. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55434. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55435. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55437. * * 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
  55438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55439. * @param name defines the name of the mesh
  55440. * @param options defines the options used to create the mesh
  55441. * @param scene defines the hosting scene
  55442. * @returns the torus knot mesh
  55443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55444. */
  55445. static CreateTorusKnot(name: string, options: {
  55446. radius?: number;
  55447. tube?: number;
  55448. radialSegments?: number;
  55449. tubularSegments?: number;
  55450. p?: number;
  55451. q?: number;
  55452. updatable?: boolean;
  55453. sideOrientation?: number;
  55454. frontUVs?: Vector4;
  55455. backUVs?: Vector4;
  55456. }, scene?: Nullable<Scene>): Mesh;
  55457. /**
  55458. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55459. * * 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
  55460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55461. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55462. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55463. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55464. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55465. * * 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
  55466. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55469. * @param name defines the name of the new line system
  55470. * @param options defines the options used to create the line system
  55471. * @param scene defines the hosting scene
  55472. * @returns a new line system mesh
  55473. */
  55474. static CreateLineSystem(name: string, options: {
  55475. lines: Vector3[][];
  55476. updatable?: boolean;
  55477. instance?: Nullable<LinesMesh>;
  55478. colors?: Nullable<Color4[][]>;
  55479. useVertexAlpha?: boolean;
  55480. }, scene: Nullable<Scene>): LinesMesh;
  55481. /**
  55482. * Creates a line mesh
  55483. * 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
  55484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55485. * * The parameter `points` is an array successive Vector3
  55486. * * 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
  55487. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55489. * * When updating an instance, remember that only point positions can change, not the number of points
  55490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55492. * @param name defines the name of the new line system
  55493. * @param options defines the options used to create the line system
  55494. * @param scene defines the hosting scene
  55495. * @returns a new line mesh
  55496. */
  55497. static CreateLines(name: string, options: {
  55498. points: Vector3[];
  55499. updatable?: boolean;
  55500. instance?: Nullable<LinesMesh>;
  55501. colors?: Color4[];
  55502. useVertexAlpha?: boolean;
  55503. }, scene?: Nullable<Scene>): LinesMesh;
  55504. /**
  55505. * Creates a dashed line mesh
  55506. * * 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
  55507. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55508. * * The parameter `points` is an array successive Vector3
  55509. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55510. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55511. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55512. * * 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
  55513. * * When updating an instance, remember that only point positions can change, not the number of points
  55514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55515. * @param name defines the name of the mesh
  55516. * @param options defines the options used to create the mesh
  55517. * @param scene defines the hosting scene
  55518. * @returns the dashed line mesh
  55519. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55520. */
  55521. static CreateDashedLines(name: string, options: {
  55522. points: Vector3[];
  55523. dashSize?: number;
  55524. gapSize?: number;
  55525. dashNb?: number;
  55526. updatable?: boolean;
  55527. instance?: LinesMesh;
  55528. }, scene?: Nullable<Scene>): LinesMesh;
  55529. /**
  55530. * 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.
  55531. * * 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.
  55532. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55533. * * 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.
  55534. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55535. * * 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
  55536. * * 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
  55537. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55539. * * 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
  55540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55542. * @param name defines the name of the mesh
  55543. * @param options defines the options used to create the mesh
  55544. * @param scene defines the hosting scene
  55545. * @returns the extruded shape mesh
  55546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55548. */
  55549. static ExtrudeShape(name: string, options: {
  55550. shape: Vector3[];
  55551. path: Vector3[];
  55552. scale?: number;
  55553. rotation?: number;
  55554. cap?: number;
  55555. updatable?: boolean;
  55556. sideOrientation?: number;
  55557. frontUVs?: Vector4;
  55558. backUVs?: Vector4;
  55559. instance?: Mesh;
  55560. invertUV?: boolean;
  55561. }, scene?: Nullable<Scene>): Mesh;
  55562. /**
  55563. * Creates an custom extruded shape mesh.
  55564. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55565. * * 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.
  55566. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55567. * * 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
  55568. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55569. * * 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
  55570. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55571. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55572. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55573. * * 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
  55574. * * 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
  55575. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55577. * * 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
  55578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55580. * @param name defines the name of the mesh
  55581. * @param options defines the options used to create the mesh
  55582. * @param scene defines the hosting scene
  55583. * @returns the custom extruded shape mesh
  55584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55585. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55587. */
  55588. static ExtrudeShapeCustom(name: string, options: {
  55589. shape: Vector3[];
  55590. path: Vector3[];
  55591. scaleFunction?: any;
  55592. rotationFunction?: any;
  55593. ribbonCloseArray?: boolean;
  55594. ribbonClosePath?: boolean;
  55595. cap?: number;
  55596. updatable?: boolean;
  55597. sideOrientation?: number;
  55598. frontUVs?: Vector4;
  55599. backUVs?: Vector4;
  55600. instance?: Mesh;
  55601. invertUV?: boolean;
  55602. }, scene?: Nullable<Scene>): Mesh;
  55603. /**
  55604. * Creates lathe mesh.
  55605. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55606. * * 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
  55607. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55608. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55609. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55610. * * 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
  55611. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55612. * * 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
  55613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55614. * * 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
  55615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55617. * @param name defines the name of the mesh
  55618. * @param options defines the options used to create the mesh
  55619. * @param scene defines the hosting scene
  55620. * @returns the lathe mesh
  55621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55622. */
  55623. static CreateLathe(name: string, options: {
  55624. shape: Vector3[];
  55625. radius?: number;
  55626. tessellation?: number;
  55627. clip?: number;
  55628. arc?: number;
  55629. closed?: boolean;
  55630. updatable?: boolean;
  55631. sideOrientation?: number;
  55632. frontUVs?: Vector4;
  55633. backUVs?: Vector4;
  55634. cap?: number;
  55635. invertUV?: boolean;
  55636. }, scene?: Nullable<Scene>): Mesh;
  55637. /**
  55638. * Creates a tiled plane mesh
  55639. * * You can set a limited pattern arrangement with the tiles
  55640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55641. * * 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
  55642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55643. * @param name defines the name of the mesh
  55644. * @param options defines the options used to create the mesh
  55645. * @param scene defines the hosting scene
  55646. * @returns the plane mesh
  55647. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55648. */
  55649. static CreateTiledPlane(name: string, options: {
  55650. pattern?: number;
  55651. tileSize?: number;
  55652. tileWidth?: number;
  55653. tileHeight?: number;
  55654. size?: number;
  55655. width?: number;
  55656. height?: number;
  55657. alignHorizontal?: number;
  55658. alignVertical?: number;
  55659. sideOrientation?: number;
  55660. frontUVs?: Vector4;
  55661. backUVs?: Vector4;
  55662. updatable?: boolean;
  55663. }, scene?: Nullable<Scene>): Mesh;
  55664. /**
  55665. * Creates a plane mesh
  55666. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55667. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55668. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55672. * @param name defines the name of the mesh
  55673. * @param options defines the options used to create the mesh
  55674. * @param scene defines the hosting scene
  55675. * @returns the plane mesh
  55676. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55677. */
  55678. static CreatePlane(name: string, options: {
  55679. size?: number;
  55680. width?: number;
  55681. height?: number;
  55682. sideOrientation?: number;
  55683. frontUVs?: Vector4;
  55684. backUVs?: Vector4;
  55685. updatable?: boolean;
  55686. sourcePlane?: Plane;
  55687. }, scene?: Nullable<Scene>): Mesh;
  55688. /**
  55689. * Creates a ground mesh
  55690. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55691. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55693. * @param name defines the name of the mesh
  55694. * @param options defines the options used to create the mesh
  55695. * @param scene defines the hosting scene
  55696. * @returns the ground mesh
  55697. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55698. */
  55699. static CreateGround(name: string, options: {
  55700. width?: number;
  55701. height?: number;
  55702. subdivisions?: number;
  55703. subdivisionsX?: number;
  55704. subdivisionsY?: number;
  55705. updatable?: boolean;
  55706. }, scene?: Nullable<Scene>): Mesh;
  55707. /**
  55708. * Creates a tiled ground mesh
  55709. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55710. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55711. * * 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
  55712. * * 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
  55713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55714. * @param name defines the name of the mesh
  55715. * @param options defines the options used to create the mesh
  55716. * @param scene defines the hosting scene
  55717. * @returns the tiled ground mesh
  55718. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55719. */
  55720. static CreateTiledGround(name: string, options: {
  55721. xmin: number;
  55722. zmin: number;
  55723. xmax: number;
  55724. zmax: number;
  55725. subdivisions?: {
  55726. w: number;
  55727. h: number;
  55728. };
  55729. precision?: {
  55730. w: number;
  55731. h: number;
  55732. };
  55733. updatable?: boolean;
  55734. }, scene?: Nullable<Scene>): Mesh;
  55735. /**
  55736. * Creates a ground mesh from a height map
  55737. * * The parameter `url` sets the URL of the height map image resource.
  55738. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55739. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55740. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55741. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55742. * * 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.
  55743. * * 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).
  55744. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55746. * @param name defines the name of the mesh
  55747. * @param url defines the url to the height map
  55748. * @param options defines the options used to create the mesh
  55749. * @param scene defines the hosting scene
  55750. * @returns the ground mesh
  55751. * @see https://doc.babylonjs.com/babylon101/height_map
  55752. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55753. */
  55754. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55755. width?: number;
  55756. height?: number;
  55757. subdivisions?: number;
  55758. minHeight?: number;
  55759. maxHeight?: number;
  55760. colorFilter?: Color3;
  55761. alphaFilter?: number;
  55762. updatable?: boolean;
  55763. onReady?: (mesh: GroundMesh) => void;
  55764. }, scene?: Nullable<Scene>): GroundMesh;
  55765. /**
  55766. * Creates a polygon mesh
  55767. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55768. * * 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
  55769. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55771. * * 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)
  55772. * * Remember you can only change the shape positions, not their number when updating a polygon
  55773. * @param name defines the name of the mesh
  55774. * @param options defines the options used to create the mesh
  55775. * @param scene defines the hosting scene
  55776. * @param earcutInjection can be used to inject your own earcut reference
  55777. * @returns the polygon mesh
  55778. */
  55779. static CreatePolygon(name: string, options: {
  55780. shape: Vector3[];
  55781. holes?: Vector3[][];
  55782. depth?: number;
  55783. faceUV?: Vector4[];
  55784. faceColors?: Color4[];
  55785. updatable?: boolean;
  55786. sideOrientation?: number;
  55787. frontUVs?: Vector4;
  55788. backUVs?: Vector4;
  55789. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55790. /**
  55791. * Creates an extruded polygon mesh, with depth in the Y direction.
  55792. * * 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)
  55793. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55794. * @param name defines the name of the mesh
  55795. * @param options defines the options used to create the mesh
  55796. * @param scene defines the hosting scene
  55797. * @param earcutInjection can be used to inject your own earcut reference
  55798. * @returns the polygon mesh
  55799. */
  55800. static ExtrudePolygon(name: string, options: {
  55801. shape: Vector3[];
  55802. holes?: Vector3[][];
  55803. depth?: number;
  55804. faceUV?: Vector4[];
  55805. faceColors?: Color4[];
  55806. updatable?: boolean;
  55807. sideOrientation?: number;
  55808. frontUVs?: Vector4;
  55809. backUVs?: Vector4;
  55810. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55811. /**
  55812. * Creates a tube mesh.
  55813. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55814. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55815. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55816. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55817. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55818. * * 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)
  55819. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55820. * * 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
  55821. * * 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
  55822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55823. * * 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
  55824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55826. * @param name defines the name of the mesh
  55827. * @param options defines the options used to create the mesh
  55828. * @param scene defines the hosting scene
  55829. * @returns the tube mesh
  55830. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55831. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55832. */
  55833. static CreateTube(name: string, options: {
  55834. path: Vector3[];
  55835. radius?: number;
  55836. tessellation?: number;
  55837. radiusFunction?: {
  55838. (i: number, distance: number): number;
  55839. };
  55840. cap?: number;
  55841. arc?: number;
  55842. updatable?: boolean;
  55843. sideOrientation?: number;
  55844. frontUVs?: Vector4;
  55845. backUVs?: Vector4;
  55846. instance?: Mesh;
  55847. invertUV?: boolean;
  55848. }, scene?: Nullable<Scene>): Mesh;
  55849. /**
  55850. * Creates a polyhedron mesh
  55851. * * 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
  55852. * * The parameter `size` (positive float, default 1) sets the polygon size
  55853. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55854. * * 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`
  55855. * * 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
  55856. * * 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)`)
  55857. * * 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
  55858. * * 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
  55859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55860. * * 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
  55861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55862. * @param name defines the name of the mesh
  55863. * @param options defines the options used to create the mesh
  55864. * @param scene defines the hosting scene
  55865. * @returns the polyhedron mesh
  55866. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55867. */
  55868. static CreatePolyhedron(name: string, options: {
  55869. type?: number;
  55870. size?: number;
  55871. sizeX?: number;
  55872. sizeY?: number;
  55873. sizeZ?: number;
  55874. custom?: any;
  55875. faceUV?: Vector4[];
  55876. faceColors?: Color4[];
  55877. flat?: boolean;
  55878. updatable?: boolean;
  55879. sideOrientation?: number;
  55880. frontUVs?: Vector4;
  55881. backUVs?: Vector4;
  55882. }, scene?: Nullable<Scene>): Mesh;
  55883. /**
  55884. * Creates a decal mesh.
  55885. * 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
  55886. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55887. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55888. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55889. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55890. * @param name defines the name of the mesh
  55891. * @param sourceMesh defines the mesh where the decal must be applied
  55892. * @param options defines the options used to create the mesh
  55893. * @param scene defines the hosting scene
  55894. * @returns the decal mesh
  55895. * @see https://doc.babylonjs.com/how_to/decals
  55896. */
  55897. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55898. position?: Vector3;
  55899. normal?: Vector3;
  55900. size?: Vector3;
  55901. angle?: number;
  55902. }): Mesh;
  55903. }
  55904. }
  55905. declare module BABYLON {
  55906. /**
  55907. * A simplifier interface for future simplification implementations
  55908. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55909. */
  55910. export interface ISimplifier {
  55911. /**
  55912. * Simplification of a given mesh according to the given settings.
  55913. * Since this requires computation, it is assumed that the function runs async.
  55914. * @param settings The settings of the simplification, including quality and distance
  55915. * @param successCallback A callback that will be called after the mesh was simplified.
  55916. * @param errorCallback in case of an error, this callback will be called. optional.
  55917. */
  55918. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55919. }
  55920. /**
  55921. * Expected simplification settings.
  55922. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55924. */
  55925. export interface ISimplificationSettings {
  55926. /**
  55927. * Gets or sets the expected quality
  55928. */
  55929. quality: number;
  55930. /**
  55931. * Gets or sets the distance when this optimized version should be used
  55932. */
  55933. distance: number;
  55934. /**
  55935. * Gets an already optimized mesh
  55936. */
  55937. optimizeMesh?: boolean;
  55938. }
  55939. /**
  55940. * Class used to specify simplification options
  55941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55942. */
  55943. export class SimplificationSettings implements ISimplificationSettings {
  55944. /** expected quality */
  55945. quality: number;
  55946. /** distance when this optimized version should be used */
  55947. distance: number;
  55948. /** already optimized mesh */
  55949. optimizeMesh?: boolean | undefined;
  55950. /**
  55951. * Creates a SimplificationSettings
  55952. * @param quality expected quality
  55953. * @param distance distance when this optimized version should be used
  55954. * @param optimizeMesh already optimized mesh
  55955. */
  55956. constructor(
  55957. /** expected quality */
  55958. quality: number,
  55959. /** distance when this optimized version should be used */
  55960. distance: number,
  55961. /** already optimized mesh */
  55962. optimizeMesh?: boolean | undefined);
  55963. }
  55964. /**
  55965. * Interface used to define a simplification task
  55966. */
  55967. export interface ISimplificationTask {
  55968. /**
  55969. * Array of settings
  55970. */
  55971. settings: Array<ISimplificationSettings>;
  55972. /**
  55973. * Simplification type
  55974. */
  55975. simplificationType: SimplificationType;
  55976. /**
  55977. * Mesh to simplify
  55978. */
  55979. mesh: Mesh;
  55980. /**
  55981. * Callback called on success
  55982. */
  55983. successCallback?: () => void;
  55984. /**
  55985. * Defines if parallel processing can be used
  55986. */
  55987. parallelProcessing: boolean;
  55988. }
  55989. /**
  55990. * Queue used to order the simplification tasks
  55991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55992. */
  55993. export class SimplificationQueue {
  55994. private _simplificationArray;
  55995. /**
  55996. * Gets a boolean indicating that the process is still running
  55997. */
  55998. running: boolean;
  55999. /**
  56000. * Creates a new queue
  56001. */
  56002. constructor();
  56003. /**
  56004. * Adds a new simplification task
  56005. * @param task defines a task to add
  56006. */
  56007. addTask(task: ISimplificationTask): void;
  56008. /**
  56009. * Execute next task
  56010. */
  56011. executeNext(): void;
  56012. /**
  56013. * Execute a simplification task
  56014. * @param task defines the task to run
  56015. */
  56016. runSimplification(task: ISimplificationTask): void;
  56017. private getSimplifier;
  56018. }
  56019. /**
  56020. * The implemented types of simplification
  56021. * At the moment only Quadratic Error Decimation is implemented
  56022. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56023. */
  56024. export enum SimplificationType {
  56025. /** Quadratic error decimation */
  56026. QUADRATIC = 0
  56027. }
  56028. }
  56029. declare module BABYLON {
  56030. interface Scene {
  56031. /** @hidden (Backing field) */
  56032. _simplificationQueue: SimplificationQueue;
  56033. /**
  56034. * Gets or sets the simplification queue attached to the scene
  56035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56036. */
  56037. simplificationQueue: SimplificationQueue;
  56038. }
  56039. interface Mesh {
  56040. /**
  56041. * Simplify the mesh according to the given array of settings.
  56042. * Function will return immediately and will simplify async
  56043. * @param settings a collection of simplification settings
  56044. * @param parallelProcessing should all levels calculate parallel or one after the other
  56045. * @param simplificationType the type of simplification to run
  56046. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56047. * @returns the current mesh
  56048. */
  56049. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56050. }
  56051. /**
  56052. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56053. * created in a scene
  56054. */
  56055. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56056. /**
  56057. * The component name helpfull to identify the component in the list of scene components.
  56058. */
  56059. readonly name: string;
  56060. /**
  56061. * The scene the component belongs to.
  56062. */
  56063. scene: Scene;
  56064. /**
  56065. * Creates a new instance of the component for the given scene
  56066. * @param scene Defines the scene to register the component in
  56067. */
  56068. constructor(scene: Scene);
  56069. /**
  56070. * Registers the component in a given scene
  56071. */
  56072. register(): void;
  56073. /**
  56074. * Rebuilds the elements related to this component in case of
  56075. * context lost for instance.
  56076. */
  56077. rebuild(): void;
  56078. /**
  56079. * Disposes the component and the associated ressources
  56080. */
  56081. dispose(): void;
  56082. private _beforeCameraUpdate;
  56083. }
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56088. */
  56089. export interface INavigationEnginePlugin {
  56090. /**
  56091. * plugin name
  56092. */
  56093. name: string;
  56094. /**
  56095. * Creates a navigation mesh
  56096. * @param meshes array of all the geometry used to compute the navigatio mesh
  56097. * @param parameters bunch of parameters used to filter geometry
  56098. */
  56099. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56100. /**
  56101. * Create a navigation mesh debug mesh
  56102. * @param scene is where the mesh will be added
  56103. * @returns debug display mesh
  56104. */
  56105. createDebugNavMesh(scene: Scene): Mesh;
  56106. /**
  56107. * Get a navigation mesh constrained position, closest to the parameter position
  56108. * @param position world position
  56109. * @returns the closest point to position constrained by the navigation mesh
  56110. */
  56111. getClosestPoint(position: Vector3): Vector3;
  56112. /**
  56113. * Get a navigation mesh constrained position, within a particular radius
  56114. * @param position world position
  56115. * @param maxRadius the maximum distance to the constrained world position
  56116. * @returns the closest point to position constrained by the navigation mesh
  56117. */
  56118. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56119. /**
  56120. * Compute the final position from a segment made of destination-position
  56121. * @param position world position
  56122. * @param destination world position
  56123. * @returns the resulting point along the navmesh
  56124. */
  56125. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56126. /**
  56127. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56128. * @param start world position
  56129. * @param end world position
  56130. * @returns array containing world position composing the path
  56131. */
  56132. computePath(start: Vector3, end: Vector3): Vector3[];
  56133. /**
  56134. * If this plugin is supported
  56135. * @returns true if plugin is supported
  56136. */
  56137. isSupported(): boolean;
  56138. /**
  56139. * Create a new Crowd so you can add agents
  56140. * @param maxAgents the maximum agent count in the crowd
  56141. * @param maxAgentRadius the maximum radius an agent can have
  56142. * @param scene to attach the crowd to
  56143. * @returns the crowd you can add agents to
  56144. */
  56145. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56146. /**
  56147. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56148. * The queries will try to find a solution within those bounds
  56149. * default is (1,1,1)
  56150. * @param extent x,y,z value that define the extent around the queries point of reference
  56151. */
  56152. setDefaultQueryExtent(extent: Vector3): void;
  56153. /**
  56154. * Get the Bounding box extent specified by setDefaultQueryExtent
  56155. * @returns the box extent values
  56156. */
  56157. getDefaultQueryExtent(): Vector3;
  56158. /**
  56159. * Release all resources
  56160. */
  56161. dispose(): void;
  56162. }
  56163. /**
  56164. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56165. */
  56166. export interface ICrowd {
  56167. /**
  56168. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56169. * You can attach anything to that node. The node position is updated in the scene update tick.
  56170. * @param pos world position that will be constrained by the navigation mesh
  56171. * @param parameters agent parameters
  56172. * @param transform hooked to the agent that will be update by the scene
  56173. * @returns agent index
  56174. */
  56175. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56176. /**
  56177. * Returns the agent position in world space
  56178. * @param index agent index returned by addAgent
  56179. * @returns world space position
  56180. */
  56181. getAgentPosition(index: number): Vector3;
  56182. /**
  56183. * Gets the agent velocity in world space
  56184. * @param index agent index returned by addAgent
  56185. * @returns world space velocity
  56186. */
  56187. getAgentVelocity(index: number): Vector3;
  56188. /**
  56189. * remove a particular agent previously created
  56190. * @param index agent index returned by addAgent
  56191. */
  56192. removeAgent(index: number): void;
  56193. /**
  56194. * get the list of all agents attached to this crowd
  56195. * @returns list of agent indices
  56196. */
  56197. getAgents(): number[];
  56198. /**
  56199. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56200. * @param deltaTime in seconds
  56201. */
  56202. update(deltaTime: number): void;
  56203. /**
  56204. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56205. * @param index agent index returned by addAgent
  56206. * @param destination targeted world position
  56207. */
  56208. agentGoto(index: number, destination: Vector3): void;
  56209. /**
  56210. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56211. * The queries will try to find a solution within those bounds
  56212. * default is (1,1,1)
  56213. * @param extent x,y,z value that define the extent around the queries point of reference
  56214. */
  56215. setDefaultQueryExtent(extent: Vector3): void;
  56216. /**
  56217. * Get the Bounding box extent specified by setDefaultQueryExtent
  56218. * @returns the box extent values
  56219. */
  56220. getDefaultQueryExtent(): Vector3;
  56221. /**
  56222. * Release all resources
  56223. */
  56224. dispose(): void;
  56225. }
  56226. /**
  56227. * Configures an agent
  56228. */
  56229. export interface IAgentParameters {
  56230. /**
  56231. * Agent radius. [Limit: >= 0]
  56232. */
  56233. radius: number;
  56234. /**
  56235. * Agent height. [Limit: > 0]
  56236. */
  56237. height: number;
  56238. /**
  56239. * Maximum allowed acceleration. [Limit: >= 0]
  56240. */
  56241. maxAcceleration: number;
  56242. /**
  56243. * Maximum allowed speed. [Limit: >= 0]
  56244. */
  56245. maxSpeed: number;
  56246. /**
  56247. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56248. */
  56249. collisionQueryRange: number;
  56250. /**
  56251. * The path visibility optimization range. [Limit: > 0]
  56252. */
  56253. pathOptimizationRange: number;
  56254. /**
  56255. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56256. */
  56257. separationWeight: number;
  56258. }
  56259. /**
  56260. * Configures the navigation mesh creation
  56261. */
  56262. export interface INavMeshParameters {
  56263. /**
  56264. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56265. */
  56266. cs: number;
  56267. /**
  56268. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56269. */
  56270. ch: number;
  56271. /**
  56272. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56273. */
  56274. walkableSlopeAngle: number;
  56275. /**
  56276. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56277. * be considered walkable. [Limit: >= 3] [Units: vx]
  56278. */
  56279. walkableHeight: number;
  56280. /**
  56281. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56282. */
  56283. walkableClimb: number;
  56284. /**
  56285. * The distance to erode/shrink the walkable area of the heightfield away from
  56286. * obstructions. [Limit: >=0] [Units: vx]
  56287. */
  56288. walkableRadius: number;
  56289. /**
  56290. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56291. */
  56292. maxEdgeLen: number;
  56293. /**
  56294. * The maximum distance a simplfied contour's border edges should deviate
  56295. * the original raw contour. [Limit: >=0] [Units: vx]
  56296. */
  56297. maxSimplificationError: number;
  56298. /**
  56299. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56300. */
  56301. minRegionArea: number;
  56302. /**
  56303. * Any regions with a span count smaller than this value will, if possible,
  56304. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56305. */
  56306. mergeRegionArea: number;
  56307. /**
  56308. * The maximum number of vertices allowed for polygons generated during the
  56309. * contour to polygon conversion process. [Limit: >= 3]
  56310. */
  56311. maxVertsPerPoly: number;
  56312. /**
  56313. * Sets the sampling distance to use when generating the detail mesh.
  56314. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56315. */
  56316. detailSampleDist: number;
  56317. /**
  56318. * The maximum distance the detail mesh surface should deviate from heightfield
  56319. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56320. */
  56321. detailSampleMaxError: number;
  56322. }
  56323. }
  56324. declare module BABYLON {
  56325. /**
  56326. * RecastJS navigation plugin
  56327. */
  56328. export class RecastJSPlugin implements INavigationEnginePlugin {
  56329. /**
  56330. * Reference to the Recast library
  56331. */
  56332. bjsRECAST: any;
  56333. /**
  56334. * plugin name
  56335. */
  56336. name: string;
  56337. /**
  56338. * the first navmesh created. We might extend this to support multiple navmeshes
  56339. */
  56340. navMesh: any;
  56341. /**
  56342. * Initializes the recastJS plugin
  56343. * @param recastInjection can be used to inject your own recast reference
  56344. */
  56345. constructor(recastInjection?: any);
  56346. /**
  56347. * Creates a navigation mesh
  56348. * @param meshes array of all the geometry used to compute the navigatio mesh
  56349. * @param parameters bunch of parameters used to filter geometry
  56350. */
  56351. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56352. /**
  56353. * Create a navigation mesh debug mesh
  56354. * @param scene is where the mesh will be added
  56355. * @returns debug display mesh
  56356. */
  56357. createDebugNavMesh(scene: Scene): Mesh;
  56358. /**
  56359. * Get a navigation mesh constrained position, closest to the parameter position
  56360. * @param position world position
  56361. * @returns the closest point to position constrained by the navigation mesh
  56362. */
  56363. getClosestPoint(position: Vector3): Vector3;
  56364. /**
  56365. * Get a navigation mesh constrained position, within a particular radius
  56366. * @param position world position
  56367. * @param maxRadius the maximum distance to the constrained world position
  56368. * @returns the closest point to position constrained by the navigation mesh
  56369. */
  56370. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56371. /**
  56372. * Compute the final position from a segment made of destination-position
  56373. * @param position world position
  56374. * @param destination world position
  56375. * @returns the resulting point along the navmesh
  56376. */
  56377. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56378. /**
  56379. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56380. * @param start world position
  56381. * @param end world position
  56382. * @returns array containing world position composing the path
  56383. */
  56384. computePath(start: Vector3, end: Vector3): Vector3[];
  56385. /**
  56386. * Create a new Crowd so you can add agents
  56387. * @param maxAgents the maximum agent count in the crowd
  56388. * @param maxAgentRadius the maximum radius an agent can have
  56389. * @param scene to attach the crowd to
  56390. * @returns the crowd you can add agents to
  56391. */
  56392. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56393. /**
  56394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56395. * The queries will try to find a solution within those bounds
  56396. * default is (1,1,1)
  56397. * @param extent x,y,z value that define the extent around the queries point of reference
  56398. */
  56399. setDefaultQueryExtent(extent: Vector3): void;
  56400. /**
  56401. * Get the Bounding box extent specified by setDefaultQueryExtent
  56402. * @returns the box extent values
  56403. */
  56404. getDefaultQueryExtent(): Vector3;
  56405. /**
  56406. * Disposes
  56407. */
  56408. dispose(): void;
  56409. /**
  56410. * If this plugin is supported
  56411. * @returns true if plugin is supported
  56412. */
  56413. isSupported(): boolean;
  56414. }
  56415. /**
  56416. * Recast detour crowd implementation
  56417. */
  56418. export class RecastJSCrowd implements ICrowd {
  56419. /**
  56420. * Recast/detour plugin
  56421. */
  56422. bjsRECASTPlugin: RecastJSPlugin;
  56423. /**
  56424. * Link to the detour crowd
  56425. */
  56426. recastCrowd: any;
  56427. /**
  56428. * One transform per agent
  56429. */
  56430. transforms: TransformNode[];
  56431. /**
  56432. * All agents created
  56433. */
  56434. agents: number[];
  56435. /**
  56436. * Link to the scene is kept to unregister the crowd from the scene
  56437. */
  56438. private _scene;
  56439. /**
  56440. * Observer for crowd updates
  56441. */
  56442. private _onBeforeAnimationsObserver;
  56443. /**
  56444. * Constructor
  56445. * @param plugin recastJS plugin
  56446. * @param maxAgents the maximum agent count in the crowd
  56447. * @param maxAgentRadius the maximum radius an agent can have
  56448. * @param scene to attach the crowd to
  56449. * @returns the crowd you can add agents to
  56450. */
  56451. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56452. /**
  56453. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56454. * You can attach anything to that node. The node position is updated in the scene update tick.
  56455. * @param pos world position that will be constrained by the navigation mesh
  56456. * @param parameters agent parameters
  56457. * @param transform hooked to the agent that will be update by the scene
  56458. * @returns agent index
  56459. */
  56460. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56461. /**
  56462. * Returns the agent position in world space
  56463. * @param index agent index returned by addAgent
  56464. * @returns world space position
  56465. */
  56466. getAgentPosition(index: number): Vector3;
  56467. /**
  56468. * Returns the agent velocity in world space
  56469. * @param index agent index returned by addAgent
  56470. * @returns world space velocity
  56471. */
  56472. getAgentVelocity(index: number): Vector3;
  56473. /**
  56474. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56475. * @param index agent index returned by addAgent
  56476. * @param destination targeted world position
  56477. */
  56478. agentGoto(index: number, destination: Vector3): void;
  56479. /**
  56480. * remove a particular agent previously created
  56481. * @param index agent index returned by addAgent
  56482. */
  56483. removeAgent(index: number): void;
  56484. /**
  56485. * get the list of all agents attached to this crowd
  56486. * @returns list of agent indices
  56487. */
  56488. getAgents(): number[];
  56489. /**
  56490. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56491. * @param deltaTime in seconds
  56492. */
  56493. update(deltaTime: number): void;
  56494. /**
  56495. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56496. * The queries will try to find a solution within those bounds
  56497. * default is (1,1,1)
  56498. * @param extent x,y,z value that define the extent around the queries point of reference
  56499. */
  56500. setDefaultQueryExtent(extent: Vector3): void;
  56501. /**
  56502. * Get the Bounding box extent specified by setDefaultQueryExtent
  56503. * @returns the box extent values
  56504. */
  56505. getDefaultQueryExtent(): Vector3;
  56506. /**
  56507. * Release all resources
  56508. */
  56509. dispose(): void;
  56510. }
  56511. }
  56512. declare module BABYLON {
  56513. /**
  56514. * Class used to enable access to IndexedDB
  56515. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56516. */
  56517. export class Database implements IOfflineProvider {
  56518. private _callbackManifestChecked;
  56519. private _currentSceneUrl;
  56520. private _db;
  56521. private _enableSceneOffline;
  56522. private _enableTexturesOffline;
  56523. private _manifestVersionFound;
  56524. private _mustUpdateRessources;
  56525. private _hasReachedQuota;
  56526. private _isSupported;
  56527. private _idbFactory;
  56528. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56529. private static IsUASupportingBlobStorage;
  56530. /**
  56531. * Gets a boolean indicating if Database storate is enabled (off by default)
  56532. */
  56533. static IDBStorageEnabled: boolean;
  56534. /**
  56535. * Gets a boolean indicating if scene must be saved in the database
  56536. */
  56537. readonly enableSceneOffline: boolean;
  56538. /**
  56539. * Gets a boolean indicating if textures must be saved in the database
  56540. */
  56541. readonly enableTexturesOffline: boolean;
  56542. /**
  56543. * Creates a new Database
  56544. * @param urlToScene defines the url to load the scene
  56545. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56546. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56547. */
  56548. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56549. private static _ParseURL;
  56550. private static _ReturnFullUrlLocation;
  56551. private _checkManifestFile;
  56552. /**
  56553. * Open the database and make it available
  56554. * @param successCallback defines the callback to call on success
  56555. * @param errorCallback defines the callback to call on error
  56556. */
  56557. open(successCallback: () => void, errorCallback: () => void): void;
  56558. /**
  56559. * Loads an image from the database
  56560. * @param url defines the url to load from
  56561. * @param image defines the target DOM image
  56562. */
  56563. loadImage(url: string, image: HTMLImageElement): void;
  56564. private _loadImageFromDBAsync;
  56565. private _saveImageIntoDBAsync;
  56566. private _checkVersionFromDB;
  56567. private _loadVersionFromDBAsync;
  56568. private _saveVersionIntoDBAsync;
  56569. /**
  56570. * Loads a file from database
  56571. * @param url defines the URL to load from
  56572. * @param sceneLoaded defines a callback to call on success
  56573. * @param progressCallBack defines a callback to call when progress changed
  56574. * @param errorCallback defines a callback to call on error
  56575. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56576. */
  56577. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56578. private _loadFileAsync;
  56579. private _saveFileAsync;
  56580. /**
  56581. * Validates if xhr data is correct
  56582. * @param xhr defines the request to validate
  56583. * @param dataType defines the expected data type
  56584. * @returns true if data is correct
  56585. */
  56586. private static _ValidateXHRData;
  56587. }
  56588. }
  56589. declare module BABYLON {
  56590. /** @hidden */
  56591. export var gpuUpdateParticlesPixelShader: {
  56592. name: string;
  56593. shader: string;
  56594. };
  56595. }
  56596. declare module BABYLON {
  56597. /** @hidden */
  56598. export var gpuUpdateParticlesVertexShader: {
  56599. name: string;
  56600. shader: string;
  56601. };
  56602. }
  56603. declare module BABYLON {
  56604. /** @hidden */
  56605. export var clipPlaneFragmentDeclaration2: {
  56606. name: string;
  56607. shader: string;
  56608. };
  56609. }
  56610. declare module BABYLON {
  56611. /** @hidden */
  56612. export var gpuRenderParticlesPixelShader: {
  56613. name: string;
  56614. shader: string;
  56615. };
  56616. }
  56617. declare module BABYLON {
  56618. /** @hidden */
  56619. export var clipPlaneVertexDeclaration2: {
  56620. name: string;
  56621. shader: string;
  56622. };
  56623. }
  56624. declare module BABYLON {
  56625. /** @hidden */
  56626. export var gpuRenderParticlesVertexShader: {
  56627. name: string;
  56628. shader: string;
  56629. };
  56630. }
  56631. declare module BABYLON {
  56632. /**
  56633. * This represents a GPU particle system in Babylon
  56634. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56635. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56636. */
  56637. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56638. /**
  56639. * The layer mask we are rendering the particles through.
  56640. */
  56641. layerMask: number;
  56642. private _capacity;
  56643. private _activeCount;
  56644. private _currentActiveCount;
  56645. private _accumulatedCount;
  56646. private _renderEffect;
  56647. private _updateEffect;
  56648. private _buffer0;
  56649. private _buffer1;
  56650. private _spriteBuffer;
  56651. private _updateVAO;
  56652. private _renderVAO;
  56653. private _targetIndex;
  56654. private _sourceBuffer;
  56655. private _targetBuffer;
  56656. private _engine;
  56657. private _currentRenderId;
  56658. private _started;
  56659. private _stopped;
  56660. private _timeDelta;
  56661. private _randomTexture;
  56662. private _randomTexture2;
  56663. private _attributesStrideSize;
  56664. private _updateEffectOptions;
  56665. private _randomTextureSize;
  56666. private _actualFrame;
  56667. private readonly _rawTextureWidth;
  56668. /**
  56669. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56670. */
  56671. static readonly IsSupported: boolean;
  56672. /**
  56673. * An event triggered when the system is disposed.
  56674. */
  56675. onDisposeObservable: Observable<GPUParticleSystem>;
  56676. /**
  56677. * Gets the maximum number of particles active at the same time.
  56678. * @returns The max number of active particles.
  56679. */
  56680. getCapacity(): number;
  56681. /**
  56682. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56683. * to override the particles.
  56684. */
  56685. forceDepthWrite: boolean;
  56686. /**
  56687. * Gets or set the number of active particles
  56688. */
  56689. activeParticleCount: number;
  56690. private _preWarmDone;
  56691. /**
  56692. * Is this system ready to be used/rendered
  56693. * @return true if the system is ready
  56694. */
  56695. isReady(): boolean;
  56696. /**
  56697. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56698. * @returns True if it has been started, otherwise false.
  56699. */
  56700. isStarted(): boolean;
  56701. /**
  56702. * Starts the particle system and begins to emit
  56703. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56704. */
  56705. start(delay?: number): void;
  56706. /**
  56707. * Stops the particle system.
  56708. */
  56709. stop(): void;
  56710. /**
  56711. * Remove all active particles
  56712. */
  56713. reset(): void;
  56714. /**
  56715. * Returns the string "GPUParticleSystem"
  56716. * @returns a string containing the class name
  56717. */
  56718. getClassName(): string;
  56719. private _colorGradientsTexture;
  56720. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56721. /**
  56722. * Adds a new color gradient
  56723. * @param gradient defines the gradient to use (between 0 and 1)
  56724. * @param color1 defines the color to affect to the specified gradient
  56725. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56726. * @returns the current particle system
  56727. */
  56728. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56729. /**
  56730. * Remove a specific color gradient
  56731. * @param gradient defines the gradient to remove
  56732. * @returns the current particle system
  56733. */
  56734. removeColorGradient(gradient: number): GPUParticleSystem;
  56735. private _angularSpeedGradientsTexture;
  56736. private _sizeGradientsTexture;
  56737. private _velocityGradientsTexture;
  56738. private _limitVelocityGradientsTexture;
  56739. private _dragGradientsTexture;
  56740. private _addFactorGradient;
  56741. /**
  56742. * Adds a new size gradient
  56743. * @param gradient defines the gradient to use (between 0 and 1)
  56744. * @param factor defines the size factor to affect to the specified gradient
  56745. * @returns the current particle system
  56746. */
  56747. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56748. /**
  56749. * Remove a specific size gradient
  56750. * @param gradient defines the gradient to remove
  56751. * @returns the current particle system
  56752. */
  56753. removeSizeGradient(gradient: number): GPUParticleSystem;
  56754. /**
  56755. * Adds a new angular speed gradient
  56756. * @param gradient defines the gradient to use (between 0 and 1)
  56757. * @param factor defines the angular speed to affect to the specified gradient
  56758. * @returns the current particle system
  56759. */
  56760. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56761. /**
  56762. * Remove a specific angular speed gradient
  56763. * @param gradient defines the gradient to remove
  56764. * @returns the current particle system
  56765. */
  56766. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56767. /**
  56768. * Adds a new velocity gradient
  56769. * @param gradient defines the gradient to use (between 0 and 1)
  56770. * @param factor defines the velocity to affect to the specified gradient
  56771. * @returns the current particle system
  56772. */
  56773. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56774. /**
  56775. * Remove a specific velocity gradient
  56776. * @param gradient defines the gradient to remove
  56777. * @returns the current particle system
  56778. */
  56779. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56780. /**
  56781. * Adds a new limit velocity gradient
  56782. * @param gradient defines the gradient to use (between 0 and 1)
  56783. * @param factor defines the limit velocity value to affect to the specified gradient
  56784. * @returns the current particle system
  56785. */
  56786. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56787. /**
  56788. * Remove a specific limit velocity gradient
  56789. * @param gradient defines the gradient to remove
  56790. * @returns the current particle system
  56791. */
  56792. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56793. /**
  56794. * Adds a new drag gradient
  56795. * @param gradient defines the gradient to use (between 0 and 1)
  56796. * @param factor defines the drag value to affect to the specified gradient
  56797. * @returns the current particle system
  56798. */
  56799. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56800. /**
  56801. * Remove a specific drag gradient
  56802. * @param gradient defines the gradient to remove
  56803. * @returns the current particle system
  56804. */
  56805. removeDragGradient(gradient: number): GPUParticleSystem;
  56806. /**
  56807. * Not supported by GPUParticleSystem
  56808. * @param gradient defines the gradient to use (between 0 and 1)
  56809. * @param factor defines the emit rate value to affect to the specified gradient
  56810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56811. * @returns the current particle system
  56812. */
  56813. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56814. /**
  56815. * Not supported by GPUParticleSystem
  56816. * @param gradient defines the gradient to remove
  56817. * @returns the current particle system
  56818. */
  56819. removeEmitRateGradient(gradient: number): IParticleSystem;
  56820. /**
  56821. * Not supported by GPUParticleSystem
  56822. * @param gradient defines the gradient to use (between 0 and 1)
  56823. * @param factor defines the start size value to affect to the specified gradient
  56824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56825. * @returns the current particle system
  56826. */
  56827. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56828. /**
  56829. * Not supported by GPUParticleSystem
  56830. * @param gradient defines the gradient to remove
  56831. * @returns the current particle system
  56832. */
  56833. removeStartSizeGradient(gradient: number): IParticleSystem;
  56834. /**
  56835. * Not supported by GPUParticleSystem
  56836. * @param gradient defines the gradient to use (between 0 and 1)
  56837. * @param min defines the color remap minimal range
  56838. * @param max defines the color remap maximal range
  56839. * @returns the current particle system
  56840. */
  56841. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56842. /**
  56843. * Not supported by GPUParticleSystem
  56844. * @param gradient defines the gradient to remove
  56845. * @returns the current particle system
  56846. */
  56847. removeColorRemapGradient(): IParticleSystem;
  56848. /**
  56849. * Not supported by GPUParticleSystem
  56850. * @param gradient defines the gradient to use (between 0 and 1)
  56851. * @param min defines the alpha remap minimal range
  56852. * @param max defines the alpha remap maximal range
  56853. * @returns the current particle system
  56854. */
  56855. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56856. /**
  56857. * Not supported by GPUParticleSystem
  56858. * @param gradient defines the gradient to remove
  56859. * @returns the current particle system
  56860. */
  56861. removeAlphaRemapGradient(): IParticleSystem;
  56862. /**
  56863. * Not supported by GPUParticleSystem
  56864. * @param gradient defines the gradient to use (between 0 and 1)
  56865. * @param color defines the color to affect to the specified gradient
  56866. * @returns the current particle system
  56867. */
  56868. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56869. /**
  56870. * Not supported by GPUParticleSystem
  56871. * @param gradient defines the gradient to remove
  56872. * @returns the current particle system
  56873. */
  56874. removeRampGradient(): IParticleSystem;
  56875. /**
  56876. * Not supported by GPUParticleSystem
  56877. * @returns the list of ramp gradients
  56878. */
  56879. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56880. /**
  56881. * Not supported by GPUParticleSystem
  56882. * Gets or sets a boolean indicating that ramp gradients must be used
  56883. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56884. */
  56885. useRampGradients: boolean;
  56886. /**
  56887. * Not supported by GPUParticleSystem
  56888. * @param gradient defines the gradient to use (between 0 and 1)
  56889. * @param factor defines the life time factor to affect to the specified gradient
  56890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56891. * @returns the current particle system
  56892. */
  56893. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56894. /**
  56895. * Not supported by GPUParticleSystem
  56896. * @param gradient defines the gradient to remove
  56897. * @returns the current particle system
  56898. */
  56899. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56900. /**
  56901. * Instantiates a GPU particle system.
  56902. * 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.
  56903. * @param name The name of the particle system
  56904. * @param options The options used to create the system
  56905. * @param scene The scene the particle system belongs to
  56906. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56907. */
  56908. constructor(name: string, options: Partial<{
  56909. capacity: number;
  56910. randomTextureSize: number;
  56911. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56912. protected _reset(): void;
  56913. private _createUpdateVAO;
  56914. private _createRenderVAO;
  56915. private _initialize;
  56916. /** @hidden */
  56917. _recreateUpdateEffect(): void;
  56918. /** @hidden */
  56919. _recreateRenderEffect(): void;
  56920. /**
  56921. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56922. * @param preWarm defines if we are in the pre-warmimg phase
  56923. */
  56924. animate(preWarm?: boolean): void;
  56925. private _createFactorGradientTexture;
  56926. private _createSizeGradientTexture;
  56927. private _createAngularSpeedGradientTexture;
  56928. private _createVelocityGradientTexture;
  56929. private _createLimitVelocityGradientTexture;
  56930. private _createDragGradientTexture;
  56931. private _createColorGradientTexture;
  56932. /**
  56933. * Renders the particle system in its current state
  56934. * @param preWarm defines if the system should only update the particles but not render them
  56935. * @returns the current number of particles
  56936. */
  56937. render(preWarm?: boolean): number;
  56938. /**
  56939. * Rebuilds the particle system
  56940. */
  56941. rebuild(): void;
  56942. private _releaseBuffers;
  56943. private _releaseVAOs;
  56944. /**
  56945. * Disposes the particle system and free the associated resources
  56946. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56947. */
  56948. dispose(disposeTexture?: boolean): void;
  56949. /**
  56950. * Clones the particle system.
  56951. * @param name The name of the cloned object
  56952. * @param newEmitter The new emitter to use
  56953. * @returns the cloned particle system
  56954. */
  56955. clone(name: string, newEmitter: any): GPUParticleSystem;
  56956. /**
  56957. * Serializes the particle system to a JSON object.
  56958. * @returns the JSON object
  56959. */
  56960. serialize(): any;
  56961. /**
  56962. * Parses a JSON object to create a GPU particle system.
  56963. * @param parsedParticleSystem The JSON object to parse
  56964. * @param scene The scene to create the particle system in
  56965. * @param rootUrl The root url to use to load external dependencies like texture
  56966. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56967. * @returns the parsed GPU particle system
  56968. */
  56969. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56970. }
  56971. }
  56972. declare module BABYLON {
  56973. /**
  56974. * Represents a set of particle systems working together to create a specific effect
  56975. */
  56976. export class ParticleSystemSet implements IDisposable {
  56977. private _emitterCreationOptions;
  56978. private _emitterNode;
  56979. /**
  56980. * Gets the particle system list
  56981. */
  56982. systems: IParticleSystem[];
  56983. /**
  56984. * Gets the emitter node used with this set
  56985. */
  56986. readonly emitterNode: Nullable<TransformNode>;
  56987. /**
  56988. * Creates a new emitter mesh as a sphere
  56989. * @param options defines the options used to create the sphere
  56990. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56991. * @param scene defines the hosting scene
  56992. */
  56993. setEmitterAsSphere(options: {
  56994. diameter: number;
  56995. segments: number;
  56996. color: Color3;
  56997. }, renderingGroupId: number, scene: Scene): void;
  56998. /**
  56999. * Starts all particle systems of the set
  57000. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57001. */
  57002. start(emitter?: AbstractMesh): void;
  57003. /**
  57004. * Release all associated resources
  57005. */
  57006. dispose(): void;
  57007. /**
  57008. * Serialize the set into a JSON compatible object
  57009. * @returns a JSON compatible representation of the set
  57010. */
  57011. serialize(): any;
  57012. /**
  57013. * Parse a new ParticleSystemSet from a serialized source
  57014. * @param data defines a JSON compatible representation of the set
  57015. * @param scene defines the hosting scene
  57016. * @param gpu defines if we want GPU particles or CPU particles
  57017. * @returns a new ParticleSystemSet
  57018. */
  57019. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57020. }
  57021. }
  57022. declare module BABYLON {
  57023. /**
  57024. * This class is made for on one-liner static method to help creating particle system set.
  57025. */
  57026. export class ParticleHelper {
  57027. /**
  57028. * Gets or sets base Assets URL
  57029. */
  57030. static BaseAssetsUrl: string;
  57031. /**
  57032. * Create a default particle system that you can tweak
  57033. * @param emitter defines the emitter to use
  57034. * @param capacity defines the system capacity (default is 500 particles)
  57035. * @param scene defines the hosting scene
  57036. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57037. * @returns the new Particle system
  57038. */
  57039. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57040. /**
  57041. * This is the main static method (one-liner) of this helper to create different particle systems
  57042. * @param type This string represents the type to the particle system to create
  57043. * @param scene The scene where the particle system should live
  57044. * @param gpu If the system will use gpu
  57045. * @returns the ParticleSystemSet created
  57046. */
  57047. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57048. /**
  57049. * Static function used to export a particle system to a ParticleSystemSet variable.
  57050. * Please note that the emitter shape is not exported
  57051. * @param systems defines the particle systems to export
  57052. * @returns the created particle system set
  57053. */
  57054. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57055. }
  57056. }
  57057. declare module BABYLON {
  57058. interface Engine {
  57059. /**
  57060. * Create an effect to use with particle systems.
  57061. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57062. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57063. * @param uniformsNames defines a list of attribute names
  57064. * @param samplers defines an array of string used to represent textures
  57065. * @param defines defines the string containing the defines to use to compile the shaders
  57066. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57067. * @param onCompiled defines a function to call when the effect creation is successful
  57068. * @param onError defines a function to call when the effect creation has failed
  57069. * @returns the new Effect
  57070. */
  57071. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57072. }
  57073. interface Mesh {
  57074. /**
  57075. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57076. * @returns an array of IParticleSystem
  57077. */
  57078. getEmittedParticleSystems(): IParticleSystem[];
  57079. /**
  57080. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57081. * @returns an array of IParticleSystem
  57082. */
  57083. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57084. }
  57085. /**
  57086. * @hidden
  57087. */
  57088. export var _IDoNeedToBeInTheBuild: number;
  57089. }
  57090. declare module BABYLON {
  57091. interface Scene {
  57092. /** @hidden (Backing field) */
  57093. _physicsEngine: Nullable<IPhysicsEngine>;
  57094. /**
  57095. * Gets the current physics engine
  57096. * @returns a IPhysicsEngine or null if none attached
  57097. */
  57098. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57099. /**
  57100. * Enables physics to the current scene
  57101. * @param gravity defines the scene's gravity for the physics engine
  57102. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57103. * @return a boolean indicating if the physics engine was initialized
  57104. */
  57105. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57106. /**
  57107. * Disables and disposes the physics engine associated with the scene
  57108. */
  57109. disablePhysicsEngine(): void;
  57110. /**
  57111. * Gets a boolean indicating if there is an active physics engine
  57112. * @returns a boolean indicating if there is an active physics engine
  57113. */
  57114. isPhysicsEnabled(): boolean;
  57115. /**
  57116. * Deletes a physics compound impostor
  57117. * @param compound defines the compound to delete
  57118. */
  57119. deleteCompoundImpostor(compound: any): void;
  57120. /**
  57121. * An event triggered when physic simulation is about to be run
  57122. */
  57123. onBeforePhysicsObservable: Observable<Scene>;
  57124. /**
  57125. * An event triggered when physic simulation has been done
  57126. */
  57127. onAfterPhysicsObservable: Observable<Scene>;
  57128. }
  57129. interface AbstractMesh {
  57130. /** @hidden */
  57131. _physicsImpostor: Nullable<PhysicsImpostor>;
  57132. /**
  57133. * Gets or sets impostor used for physic simulation
  57134. * @see http://doc.babylonjs.com/features/physics_engine
  57135. */
  57136. physicsImpostor: Nullable<PhysicsImpostor>;
  57137. /**
  57138. * Gets the current physics impostor
  57139. * @see http://doc.babylonjs.com/features/physics_engine
  57140. * @returns a physics impostor or null
  57141. */
  57142. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57143. /** Apply a physic impulse to the mesh
  57144. * @param force defines the force to apply
  57145. * @param contactPoint defines where to apply the force
  57146. * @returns the current mesh
  57147. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57148. */
  57149. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57150. /**
  57151. * Creates a physic joint between two meshes
  57152. * @param otherMesh defines the other mesh to use
  57153. * @param pivot1 defines the pivot to use on this mesh
  57154. * @param pivot2 defines the pivot to use on the other mesh
  57155. * @param options defines additional options (can be plugin dependent)
  57156. * @returns the current mesh
  57157. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57158. */
  57159. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57160. /** @hidden */
  57161. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57162. }
  57163. /**
  57164. * Defines the physics engine scene component responsible to manage a physics engine
  57165. */
  57166. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57167. /**
  57168. * The component name helpful to identify the component in the list of scene components.
  57169. */
  57170. readonly name: string;
  57171. /**
  57172. * The scene the component belongs to.
  57173. */
  57174. scene: Scene;
  57175. /**
  57176. * Creates a new instance of the component for the given scene
  57177. * @param scene Defines the scene to register the component in
  57178. */
  57179. constructor(scene: Scene);
  57180. /**
  57181. * Registers the component in a given scene
  57182. */
  57183. register(): void;
  57184. /**
  57185. * Rebuilds the elements related to this component in case of
  57186. * context lost for instance.
  57187. */
  57188. rebuild(): void;
  57189. /**
  57190. * Disposes the component and the associated ressources
  57191. */
  57192. dispose(): void;
  57193. }
  57194. }
  57195. declare module BABYLON {
  57196. /**
  57197. * A helper for physics simulations
  57198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57199. */
  57200. export class PhysicsHelper {
  57201. private _scene;
  57202. private _physicsEngine;
  57203. /**
  57204. * Initializes the Physics helper
  57205. * @param scene Babylon.js scene
  57206. */
  57207. constructor(scene: Scene);
  57208. /**
  57209. * Applies a radial explosion impulse
  57210. * @param origin the origin of the explosion
  57211. * @param radiusOrEventOptions the radius or the options of radial explosion
  57212. * @param strength the explosion strength
  57213. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57214. * @returns A physics radial explosion event, or null
  57215. */
  57216. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57217. /**
  57218. * Applies a radial explosion force
  57219. * @param origin the origin of the explosion
  57220. * @param radiusOrEventOptions the radius or the options of radial explosion
  57221. * @param strength the explosion strength
  57222. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57223. * @returns A physics radial explosion event, or null
  57224. */
  57225. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57226. /**
  57227. * Creates a gravitational field
  57228. * @param origin the origin of the explosion
  57229. * @param radiusOrEventOptions the radius or the options of radial explosion
  57230. * @param strength the explosion strength
  57231. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57232. * @returns A physics gravitational field event, or null
  57233. */
  57234. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57235. /**
  57236. * Creates a physics updraft event
  57237. * @param origin the origin of the updraft
  57238. * @param radiusOrEventOptions the radius or the options of the updraft
  57239. * @param strength the strength of the updraft
  57240. * @param height the height of the updraft
  57241. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57242. * @returns A physics updraft event, or null
  57243. */
  57244. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57245. /**
  57246. * Creates a physics vortex event
  57247. * @param origin the of the vortex
  57248. * @param radiusOrEventOptions the radius or the options of the vortex
  57249. * @param strength the strength of the vortex
  57250. * @param height the height of the vortex
  57251. * @returns a Physics vortex event, or null
  57252. * A physics vortex event or null
  57253. */
  57254. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57255. }
  57256. /**
  57257. * Represents a physics radial explosion event
  57258. */
  57259. class PhysicsRadialExplosionEvent {
  57260. private _scene;
  57261. private _options;
  57262. private _sphere;
  57263. private _dataFetched;
  57264. /**
  57265. * Initializes a radial explosioin event
  57266. * @param _scene BabylonJS scene
  57267. * @param _options The options for the vortex event
  57268. */
  57269. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57270. /**
  57271. * Returns the data related to the radial explosion event (sphere).
  57272. * @returns The radial explosion event data
  57273. */
  57274. getData(): PhysicsRadialExplosionEventData;
  57275. /**
  57276. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57277. * @param impostor A physics imposter
  57278. * @param origin the origin of the explosion
  57279. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57280. */
  57281. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57282. /**
  57283. * Triggers affecterd impostors callbacks
  57284. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57285. */
  57286. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57287. /**
  57288. * Disposes the sphere.
  57289. * @param force Specifies if the sphere should be disposed by force
  57290. */
  57291. dispose(force?: boolean): void;
  57292. /*** Helpers ***/
  57293. private _prepareSphere;
  57294. private _intersectsWithSphere;
  57295. }
  57296. /**
  57297. * Represents a gravitational field event
  57298. */
  57299. class PhysicsGravitationalFieldEvent {
  57300. private _physicsHelper;
  57301. private _scene;
  57302. private _origin;
  57303. private _options;
  57304. private _tickCallback;
  57305. private _sphere;
  57306. private _dataFetched;
  57307. /**
  57308. * Initializes the physics gravitational field event
  57309. * @param _physicsHelper A physics helper
  57310. * @param _scene BabylonJS scene
  57311. * @param _origin The origin position of the gravitational field event
  57312. * @param _options The options for the vortex event
  57313. */
  57314. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57315. /**
  57316. * Returns the data related to the gravitational field event (sphere).
  57317. * @returns A gravitational field event
  57318. */
  57319. getData(): PhysicsGravitationalFieldEventData;
  57320. /**
  57321. * Enables the gravitational field.
  57322. */
  57323. enable(): void;
  57324. /**
  57325. * Disables the gravitational field.
  57326. */
  57327. disable(): void;
  57328. /**
  57329. * Disposes the sphere.
  57330. * @param force The force to dispose from the gravitational field event
  57331. */
  57332. dispose(force?: boolean): void;
  57333. private _tick;
  57334. }
  57335. /**
  57336. * Represents a physics updraft event
  57337. */
  57338. class PhysicsUpdraftEvent {
  57339. private _scene;
  57340. private _origin;
  57341. private _options;
  57342. private _physicsEngine;
  57343. private _originTop;
  57344. private _originDirection;
  57345. private _tickCallback;
  57346. private _cylinder;
  57347. private _cylinderPosition;
  57348. private _dataFetched;
  57349. /**
  57350. * Initializes the physics updraft event
  57351. * @param _scene BabylonJS scene
  57352. * @param _origin The origin position of the updraft
  57353. * @param _options The options for the updraft event
  57354. */
  57355. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57356. /**
  57357. * Returns the data related to the updraft event (cylinder).
  57358. * @returns A physics updraft event
  57359. */
  57360. getData(): PhysicsUpdraftEventData;
  57361. /**
  57362. * Enables the updraft.
  57363. */
  57364. enable(): void;
  57365. /**
  57366. * Disables the updraft.
  57367. */
  57368. disable(): void;
  57369. /**
  57370. * Disposes the cylinder.
  57371. * @param force Specifies if the updraft should be disposed by force
  57372. */
  57373. dispose(force?: boolean): void;
  57374. private getImpostorHitData;
  57375. private _tick;
  57376. /*** Helpers ***/
  57377. private _prepareCylinder;
  57378. private _intersectsWithCylinder;
  57379. }
  57380. /**
  57381. * Represents a physics vortex event
  57382. */
  57383. class PhysicsVortexEvent {
  57384. private _scene;
  57385. private _origin;
  57386. private _options;
  57387. private _physicsEngine;
  57388. private _originTop;
  57389. private _tickCallback;
  57390. private _cylinder;
  57391. private _cylinderPosition;
  57392. private _dataFetched;
  57393. /**
  57394. * Initializes the physics vortex event
  57395. * @param _scene The BabylonJS scene
  57396. * @param _origin The origin position of the vortex
  57397. * @param _options The options for the vortex event
  57398. */
  57399. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57400. /**
  57401. * Returns the data related to the vortex event (cylinder).
  57402. * @returns The physics vortex event data
  57403. */
  57404. getData(): PhysicsVortexEventData;
  57405. /**
  57406. * Enables the vortex.
  57407. */
  57408. enable(): void;
  57409. /**
  57410. * Disables the cortex.
  57411. */
  57412. disable(): void;
  57413. /**
  57414. * Disposes the sphere.
  57415. * @param force
  57416. */
  57417. dispose(force?: boolean): void;
  57418. private getImpostorHitData;
  57419. private _tick;
  57420. /*** Helpers ***/
  57421. private _prepareCylinder;
  57422. private _intersectsWithCylinder;
  57423. }
  57424. /**
  57425. * Options fot the radial explosion event
  57426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57427. */
  57428. export class PhysicsRadialExplosionEventOptions {
  57429. /**
  57430. * The radius of the sphere for the radial explosion.
  57431. */
  57432. radius: number;
  57433. /**
  57434. * The strenth of the explosion.
  57435. */
  57436. strength: number;
  57437. /**
  57438. * The strenght of the force in correspondence to the distance of the affected object
  57439. */
  57440. falloff: PhysicsRadialImpulseFalloff;
  57441. /**
  57442. * Sphere options for the radial explosion.
  57443. */
  57444. sphere: {
  57445. segments: number;
  57446. diameter: number;
  57447. };
  57448. /**
  57449. * Sphere options for the radial explosion.
  57450. */
  57451. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57452. }
  57453. /**
  57454. * Options fot the updraft event
  57455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57456. */
  57457. export class PhysicsUpdraftEventOptions {
  57458. /**
  57459. * The radius of the cylinder for the vortex
  57460. */
  57461. radius: number;
  57462. /**
  57463. * The strenth of the updraft.
  57464. */
  57465. strength: number;
  57466. /**
  57467. * The height of the cylinder for the updraft.
  57468. */
  57469. height: number;
  57470. /**
  57471. * The mode for the the updraft.
  57472. */
  57473. updraftMode: PhysicsUpdraftMode;
  57474. }
  57475. /**
  57476. * Options fot the vortex event
  57477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57478. */
  57479. export class PhysicsVortexEventOptions {
  57480. /**
  57481. * The radius of the cylinder for the vortex
  57482. */
  57483. radius: number;
  57484. /**
  57485. * The strenth of the vortex.
  57486. */
  57487. strength: number;
  57488. /**
  57489. * The height of the cylinder for the vortex.
  57490. */
  57491. height: number;
  57492. /**
  57493. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57494. */
  57495. centripetalForceThreshold: number;
  57496. /**
  57497. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57498. */
  57499. centripetalForceMultiplier: number;
  57500. /**
  57501. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57502. */
  57503. centrifugalForceMultiplier: number;
  57504. /**
  57505. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57506. */
  57507. updraftForceMultiplier: number;
  57508. }
  57509. /**
  57510. * The strenght of the force in correspondence to the distance of the affected object
  57511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57512. */
  57513. export enum PhysicsRadialImpulseFalloff {
  57514. /** Defines that impulse is constant in strength across it's whole radius */
  57515. Constant = 0,
  57516. /** Defines that impulse gets weaker if it's further from the origin */
  57517. Linear = 1
  57518. }
  57519. /**
  57520. * The strength of the force in correspondence to the distance of the affected object
  57521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57522. */
  57523. export enum PhysicsUpdraftMode {
  57524. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57525. Center = 0,
  57526. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57527. Perpendicular = 1
  57528. }
  57529. /**
  57530. * Interface for a physics hit data
  57531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57532. */
  57533. export interface PhysicsHitData {
  57534. /**
  57535. * The force applied at the contact point
  57536. */
  57537. force: Vector3;
  57538. /**
  57539. * The contact point
  57540. */
  57541. contactPoint: Vector3;
  57542. /**
  57543. * The distance from the origin to the contact point
  57544. */
  57545. distanceFromOrigin: number;
  57546. }
  57547. /**
  57548. * Interface for radial explosion event data
  57549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57550. */
  57551. export interface PhysicsRadialExplosionEventData {
  57552. /**
  57553. * A sphere used for the radial explosion event
  57554. */
  57555. sphere: Mesh;
  57556. }
  57557. /**
  57558. * Interface for gravitational field event data
  57559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57560. */
  57561. export interface PhysicsGravitationalFieldEventData {
  57562. /**
  57563. * A sphere mesh used for the gravitational field event
  57564. */
  57565. sphere: Mesh;
  57566. }
  57567. /**
  57568. * Interface for updraft event data
  57569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57570. */
  57571. export interface PhysicsUpdraftEventData {
  57572. /**
  57573. * A cylinder used for the updraft event
  57574. */
  57575. cylinder: Mesh;
  57576. }
  57577. /**
  57578. * Interface for vortex event data
  57579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57580. */
  57581. export interface PhysicsVortexEventData {
  57582. /**
  57583. * A cylinder used for the vortex event
  57584. */
  57585. cylinder: Mesh;
  57586. }
  57587. /**
  57588. * Interface for an affected physics impostor
  57589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57590. */
  57591. export interface PhysicsAffectedImpostorWithData {
  57592. /**
  57593. * The impostor affected by the effect
  57594. */
  57595. impostor: PhysicsImpostor;
  57596. /**
  57597. * The data about the hit/horce from the explosion
  57598. */
  57599. hitData: PhysicsHitData;
  57600. }
  57601. }
  57602. declare module BABYLON {
  57603. /** @hidden */
  57604. export var blackAndWhitePixelShader: {
  57605. name: string;
  57606. shader: string;
  57607. };
  57608. }
  57609. declare module BABYLON {
  57610. /**
  57611. * Post process used to render in black and white
  57612. */
  57613. export class BlackAndWhitePostProcess extends PostProcess {
  57614. /**
  57615. * Linear about to convert he result to black and white (default: 1)
  57616. */
  57617. degree: number;
  57618. /**
  57619. * Creates a black and white post process
  57620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57621. * @param name The name of the effect.
  57622. * @param options The required width/height ratio to downsize to before computing the render pass.
  57623. * @param camera The camera to apply the render pass to.
  57624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57625. * @param engine The engine which the post process will be applied. (default: current engine)
  57626. * @param reusable If the post process can be reused on the same frame. (default: false)
  57627. */
  57628. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57629. }
  57630. }
  57631. declare module BABYLON {
  57632. /**
  57633. * This represents a set of one or more post processes in Babylon.
  57634. * A post process can be used to apply a shader to a texture after it is rendered.
  57635. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57636. */
  57637. export class PostProcessRenderEffect {
  57638. private _postProcesses;
  57639. private _getPostProcesses;
  57640. private _singleInstance;
  57641. private _cameras;
  57642. private _indicesForCamera;
  57643. /**
  57644. * Name of the effect
  57645. * @hidden
  57646. */
  57647. _name: string;
  57648. /**
  57649. * Instantiates a post process render effect.
  57650. * A post process can be used to apply a shader to a texture after it is rendered.
  57651. * @param engine The engine the effect is tied to
  57652. * @param name The name of the effect
  57653. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57654. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57655. */
  57656. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57657. /**
  57658. * Checks if all the post processes in the effect are supported.
  57659. */
  57660. readonly isSupported: boolean;
  57661. /**
  57662. * Updates the current state of the effect
  57663. * @hidden
  57664. */
  57665. _update(): void;
  57666. /**
  57667. * Attaches the effect on cameras
  57668. * @param cameras The camera to attach to.
  57669. * @hidden
  57670. */
  57671. _attachCameras(cameras: Camera): void;
  57672. /**
  57673. * Attaches the effect on cameras
  57674. * @param cameras The camera to attach to.
  57675. * @hidden
  57676. */
  57677. _attachCameras(cameras: Camera[]): void;
  57678. /**
  57679. * Detaches the effect on cameras
  57680. * @param cameras The camera to detatch from.
  57681. * @hidden
  57682. */
  57683. _detachCameras(cameras: Camera): void;
  57684. /**
  57685. * Detatches the effect on cameras
  57686. * @param cameras The camera to detatch from.
  57687. * @hidden
  57688. */
  57689. _detachCameras(cameras: Camera[]): void;
  57690. /**
  57691. * Enables the effect on given cameras
  57692. * @param cameras The camera to enable.
  57693. * @hidden
  57694. */
  57695. _enable(cameras: Camera): void;
  57696. /**
  57697. * Enables the effect on given cameras
  57698. * @param cameras The camera to enable.
  57699. * @hidden
  57700. */
  57701. _enable(cameras: Nullable<Camera[]>): void;
  57702. /**
  57703. * Disables the effect on the given cameras
  57704. * @param cameras The camera to disable.
  57705. * @hidden
  57706. */
  57707. _disable(cameras: Camera): void;
  57708. /**
  57709. * Disables the effect on the given cameras
  57710. * @param cameras The camera to disable.
  57711. * @hidden
  57712. */
  57713. _disable(cameras: Nullable<Camera[]>): void;
  57714. /**
  57715. * Gets a list of the post processes contained in the effect.
  57716. * @param camera The camera to get the post processes on.
  57717. * @returns The list of the post processes in the effect.
  57718. */
  57719. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57720. }
  57721. }
  57722. declare module BABYLON {
  57723. /** @hidden */
  57724. export var extractHighlightsPixelShader: {
  57725. name: string;
  57726. shader: string;
  57727. };
  57728. }
  57729. declare module BABYLON {
  57730. /**
  57731. * 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.
  57732. */
  57733. export class ExtractHighlightsPostProcess extends PostProcess {
  57734. /**
  57735. * The luminance threshold, pixels below this value will be set to black.
  57736. */
  57737. threshold: number;
  57738. /** @hidden */
  57739. _exposure: number;
  57740. /**
  57741. * Post process which has the input texture to be used when performing highlight extraction
  57742. * @hidden
  57743. */
  57744. _inputPostProcess: Nullable<PostProcess>;
  57745. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57746. }
  57747. }
  57748. declare module BABYLON {
  57749. /** @hidden */
  57750. export var bloomMergePixelShader: {
  57751. name: string;
  57752. shader: string;
  57753. };
  57754. }
  57755. declare module BABYLON {
  57756. /**
  57757. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57758. */
  57759. export class BloomMergePostProcess extends PostProcess {
  57760. /** Weight of the bloom to be added to the original input. */
  57761. weight: number;
  57762. /**
  57763. * Creates a new instance of @see BloomMergePostProcess
  57764. * @param name The name of the effect.
  57765. * @param originalFromInput Post process which's input will be used for the merge.
  57766. * @param blurred Blurred highlights post process which's output will be used.
  57767. * @param weight Weight of the bloom to be added to the original input.
  57768. * @param options The required width/height ratio to downsize to before computing the render pass.
  57769. * @param camera The camera to apply the render pass to.
  57770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57771. * @param engine The engine which the post process will be applied. (default: current engine)
  57772. * @param reusable If the post process can be reused on the same frame. (default: false)
  57773. * @param textureType Type of textures used when performing the post process. (default: 0)
  57774. * @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)
  57775. */
  57776. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57777. /** Weight of the bloom to be added to the original input. */
  57778. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57779. }
  57780. }
  57781. declare module BABYLON {
  57782. /**
  57783. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57784. */
  57785. export class BloomEffect extends PostProcessRenderEffect {
  57786. private bloomScale;
  57787. /**
  57788. * @hidden Internal
  57789. */
  57790. _effects: Array<PostProcess>;
  57791. /**
  57792. * @hidden Internal
  57793. */
  57794. _downscale: ExtractHighlightsPostProcess;
  57795. private _blurX;
  57796. private _blurY;
  57797. private _merge;
  57798. /**
  57799. * The luminance threshold to find bright areas of the image to bloom.
  57800. */
  57801. threshold: number;
  57802. /**
  57803. * The strength of the bloom.
  57804. */
  57805. weight: number;
  57806. /**
  57807. * Specifies the size of the bloom blur kernel, relative to the final output size
  57808. */
  57809. kernel: number;
  57810. /**
  57811. * Creates a new instance of @see BloomEffect
  57812. * @param scene The scene the effect belongs to.
  57813. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57814. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57815. * @param bloomWeight The the strength of bloom.
  57816. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57817. * @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)
  57818. */
  57819. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57820. /**
  57821. * Disposes each of the internal effects for a given camera.
  57822. * @param camera The camera to dispose the effect on.
  57823. */
  57824. disposeEffects(camera: Camera): void;
  57825. /**
  57826. * @hidden Internal
  57827. */
  57828. _updateEffects(): void;
  57829. /**
  57830. * Internal
  57831. * @returns if all the contained post processes are ready.
  57832. * @hidden
  57833. */
  57834. _isReady(): boolean;
  57835. }
  57836. }
  57837. declare module BABYLON {
  57838. /** @hidden */
  57839. export var chromaticAberrationPixelShader: {
  57840. name: string;
  57841. shader: string;
  57842. };
  57843. }
  57844. declare module BABYLON {
  57845. /**
  57846. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57847. */
  57848. export class ChromaticAberrationPostProcess extends PostProcess {
  57849. /**
  57850. * The amount of seperation of rgb channels (default: 30)
  57851. */
  57852. aberrationAmount: number;
  57853. /**
  57854. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57855. */
  57856. radialIntensity: number;
  57857. /**
  57858. * 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))
  57859. */
  57860. direction: Vector2;
  57861. /**
  57862. * 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))
  57863. */
  57864. centerPosition: Vector2;
  57865. /**
  57866. * Creates a new instance ChromaticAberrationPostProcess
  57867. * @param name The name of the effect.
  57868. * @param screenWidth The width of the screen to apply the effect on.
  57869. * @param screenHeight The height of the screen to apply the effect on.
  57870. * @param options The required width/height ratio to downsize to before computing the render pass.
  57871. * @param camera The camera to apply the render pass to.
  57872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57873. * @param engine The engine which the post process will be applied. (default: current engine)
  57874. * @param reusable If the post process can be reused on the same frame. (default: false)
  57875. * @param textureType Type of textures used when performing the post process. (default: 0)
  57876. * @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)
  57877. */
  57878. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. /** @hidden */
  57883. export var circleOfConfusionPixelShader: {
  57884. name: string;
  57885. shader: string;
  57886. };
  57887. }
  57888. declare module BABYLON {
  57889. /**
  57890. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57891. */
  57892. export class CircleOfConfusionPostProcess extends PostProcess {
  57893. /**
  57894. * 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.
  57895. */
  57896. lensSize: number;
  57897. /**
  57898. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57899. */
  57900. fStop: number;
  57901. /**
  57902. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57903. */
  57904. focusDistance: number;
  57905. /**
  57906. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57907. */
  57908. focalLength: number;
  57909. private _depthTexture;
  57910. /**
  57911. * Creates a new instance CircleOfConfusionPostProcess
  57912. * @param name The name of the effect.
  57913. * @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.
  57914. * @param options The required width/height ratio to downsize to before computing the render pass.
  57915. * @param camera The camera to apply the render pass to.
  57916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57917. * @param engine The engine which the post process will be applied. (default: current engine)
  57918. * @param reusable If the post process can be reused on the same frame. (default: false)
  57919. * @param textureType Type of textures used when performing the post process. (default: 0)
  57920. * @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)
  57921. */
  57922. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57923. /**
  57924. * 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.
  57925. */
  57926. depthTexture: RenderTargetTexture;
  57927. }
  57928. }
  57929. declare module BABYLON {
  57930. /** @hidden */
  57931. export var colorCorrectionPixelShader: {
  57932. name: string;
  57933. shader: string;
  57934. };
  57935. }
  57936. declare module BABYLON {
  57937. /**
  57938. *
  57939. * This post-process allows the modification of rendered colors by using
  57940. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57941. *
  57942. * The object needs to be provided an url to a texture containing the color
  57943. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57944. * Use an image editing software to tweak the LUT to match your needs.
  57945. *
  57946. * For an example of a color LUT, see here:
  57947. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57948. * For explanations on color grading, see here:
  57949. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57950. *
  57951. */
  57952. export class ColorCorrectionPostProcess extends PostProcess {
  57953. private _colorTableTexture;
  57954. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57955. }
  57956. }
  57957. declare module BABYLON {
  57958. /** @hidden */
  57959. export var convolutionPixelShader: {
  57960. name: string;
  57961. shader: string;
  57962. };
  57963. }
  57964. declare module BABYLON {
  57965. /**
  57966. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57967. * input texture to perform effects such as edge detection or sharpening
  57968. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57969. */
  57970. export class ConvolutionPostProcess extends PostProcess {
  57971. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57972. kernel: number[];
  57973. /**
  57974. * Creates a new instance ConvolutionPostProcess
  57975. * @param name The name of the effect.
  57976. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57977. * @param options The required width/height ratio to downsize to before computing the render pass.
  57978. * @param camera The camera to apply the render pass to.
  57979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57980. * @param engine The engine which the post process will be applied. (default: current engine)
  57981. * @param reusable If the post process can be reused on the same frame. (default: false)
  57982. * @param textureType Type of textures used when performing the post process. (default: 0)
  57983. */
  57984. constructor(name: string,
  57985. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57986. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57987. /**
  57988. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57989. */
  57990. static EdgeDetect0Kernel: number[];
  57991. /**
  57992. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57993. */
  57994. static EdgeDetect1Kernel: number[];
  57995. /**
  57996. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57997. */
  57998. static EdgeDetect2Kernel: number[];
  57999. /**
  58000. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58001. */
  58002. static SharpenKernel: number[];
  58003. /**
  58004. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58005. */
  58006. static EmbossKernel: number[];
  58007. /**
  58008. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58009. */
  58010. static GaussianKernel: number[];
  58011. }
  58012. }
  58013. declare module BABYLON {
  58014. /**
  58015. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58016. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58017. * based on samples that have a large difference in distance than the center pixel.
  58018. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58019. */
  58020. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58021. direction: Vector2;
  58022. /**
  58023. * Creates a new instance CircleOfConfusionPostProcess
  58024. * @param name The name of the effect.
  58025. * @param scene The scene the effect belongs to.
  58026. * @param direction The direction the blur should be applied.
  58027. * @param kernel The size of the kernel used to blur.
  58028. * @param options The required width/height ratio to downsize to before computing the render pass.
  58029. * @param camera The camera to apply the render pass to.
  58030. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58031. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58033. * @param engine The engine which the post process will be applied. (default: current engine)
  58034. * @param reusable If the post process can be reused on the same frame. (default: false)
  58035. * @param textureType Type of textures used when performing the post process. (default: 0)
  58036. * @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)
  58037. */
  58038. 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);
  58039. }
  58040. }
  58041. declare module BABYLON {
  58042. /** @hidden */
  58043. export var depthOfFieldMergePixelShader: {
  58044. name: string;
  58045. shader: string;
  58046. };
  58047. }
  58048. declare module BABYLON {
  58049. /**
  58050. * Options to be set when merging outputs from the default pipeline.
  58051. */
  58052. export class DepthOfFieldMergePostProcessOptions {
  58053. /**
  58054. * The original image to merge on top of
  58055. */
  58056. originalFromInput: PostProcess;
  58057. /**
  58058. * Parameters to perform the merge of the depth of field effect
  58059. */
  58060. depthOfField?: {
  58061. circleOfConfusion: PostProcess;
  58062. blurSteps: Array<PostProcess>;
  58063. };
  58064. /**
  58065. * Parameters to perform the merge of bloom effect
  58066. */
  58067. bloom?: {
  58068. blurred: PostProcess;
  58069. weight: number;
  58070. };
  58071. }
  58072. /**
  58073. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58074. */
  58075. export class DepthOfFieldMergePostProcess extends PostProcess {
  58076. private blurSteps;
  58077. /**
  58078. * Creates a new instance of DepthOfFieldMergePostProcess
  58079. * @param name The name of the effect.
  58080. * @param originalFromInput Post process which's input will be used for the merge.
  58081. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58082. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58083. * @param options The required width/height ratio to downsize to before computing the render pass.
  58084. * @param camera The camera to apply the render pass to.
  58085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58086. * @param engine The engine which the post process will be applied. (default: current engine)
  58087. * @param reusable If the post process can be reused on the same frame. (default: false)
  58088. * @param textureType Type of textures used when performing the post process. (default: 0)
  58089. * @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)
  58090. */
  58091. 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);
  58092. /**
  58093. * Updates the effect with the current post process compile time values and recompiles the shader.
  58094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58097. * @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
  58098. * @param onCompiled Called when the shader has been compiled.
  58099. * @param onError Called if there is an error when compiling a shader.
  58100. */
  58101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58102. }
  58103. }
  58104. declare module BABYLON {
  58105. /**
  58106. * Specifies the level of max blur that should be applied when using the depth of field effect
  58107. */
  58108. export enum DepthOfFieldEffectBlurLevel {
  58109. /**
  58110. * Subtle blur
  58111. */
  58112. Low = 0,
  58113. /**
  58114. * Medium blur
  58115. */
  58116. Medium = 1,
  58117. /**
  58118. * Large blur
  58119. */
  58120. High = 2
  58121. }
  58122. /**
  58123. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58124. */
  58125. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58126. private _circleOfConfusion;
  58127. /**
  58128. * @hidden Internal, blurs from high to low
  58129. */
  58130. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58131. private _depthOfFieldBlurY;
  58132. private _dofMerge;
  58133. /**
  58134. * @hidden Internal post processes in depth of field effect
  58135. */
  58136. _effects: Array<PostProcess>;
  58137. /**
  58138. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58139. */
  58140. focalLength: number;
  58141. /**
  58142. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58143. */
  58144. fStop: number;
  58145. /**
  58146. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58147. */
  58148. focusDistance: number;
  58149. /**
  58150. * 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.
  58151. */
  58152. lensSize: number;
  58153. /**
  58154. * Creates a new instance DepthOfFieldEffect
  58155. * @param scene The scene the effect belongs to.
  58156. * @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.
  58157. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58158. * @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)
  58159. */
  58160. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58161. /**
  58162. * Get the current class name of the current effet
  58163. * @returns "DepthOfFieldEffect"
  58164. */
  58165. getClassName(): string;
  58166. /**
  58167. * 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.
  58168. */
  58169. depthTexture: RenderTargetTexture;
  58170. /**
  58171. * Disposes each of the internal effects for a given camera.
  58172. * @param camera The camera to dispose the effect on.
  58173. */
  58174. disposeEffects(camera: Camera): void;
  58175. /**
  58176. * @hidden Internal
  58177. */
  58178. _updateEffects(): void;
  58179. /**
  58180. * Internal
  58181. * @returns if all the contained post processes are ready.
  58182. * @hidden
  58183. */
  58184. _isReady(): boolean;
  58185. }
  58186. }
  58187. declare module BABYLON {
  58188. /** @hidden */
  58189. export var displayPassPixelShader: {
  58190. name: string;
  58191. shader: string;
  58192. };
  58193. }
  58194. declare module BABYLON {
  58195. /**
  58196. * DisplayPassPostProcess which produces an output the same as it's input
  58197. */
  58198. export class DisplayPassPostProcess extends PostProcess {
  58199. /**
  58200. * Creates the DisplayPassPostProcess
  58201. * @param name The name of the effect.
  58202. * @param options The required width/height ratio to downsize to before computing the render pass.
  58203. * @param camera The camera to apply the render pass to.
  58204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58205. * @param engine The engine which the post process will be applied. (default: current engine)
  58206. * @param reusable If the post process can be reused on the same frame. (default: false)
  58207. */
  58208. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58209. }
  58210. }
  58211. declare module BABYLON {
  58212. /** @hidden */
  58213. export var filterPixelShader: {
  58214. name: string;
  58215. shader: string;
  58216. };
  58217. }
  58218. declare module BABYLON {
  58219. /**
  58220. * Applies a kernel filter to the image
  58221. */
  58222. export class FilterPostProcess extends PostProcess {
  58223. /** The matrix to be applied to the image */
  58224. kernelMatrix: Matrix;
  58225. /**
  58226. *
  58227. * @param name The name of the effect.
  58228. * @param kernelMatrix The matrix to be applied to the image
  58229. * @param options The required width/height ratio to downsize to before computing the render pass.
  58230. * @param camera The camera to apply the render pass to.
  58231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58232. * @param engine The engine which the post process will be applied. (default: current engine)
  58233. * @param reusable If the post process can be reused on the same frame. (default: false)
  58234. */
  58235. constructor(name: string,
  58236. /** The matrix to be applied to the image */
  58237. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /** @hidden */
  58242. export var fxaaPixelShader: {
  58243. name: string;
  58244. shader: string;
  58245. };
  58246. }
  58247. declare module BABYLON {
  58248. /** @hidden */
  58249. export var fxaaVertexShader: {
  58250. name: string;
  58251. shader: string;
  58252. };
  58253. }
  58254. declare module BABYLON {
  58255. /**
  58256. * Fxaa post process
  58257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58258. */
  58259. export class FxaaPostProcess extends PostProcess {
  58260. /** @hidden */
  58261. texelWidth: number;
  58262. /** @hidden */
  58263. texelHeight: number;
  58264. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58265. private _getDefines;
  58266. }
  58267. }
  58268. declare module BABYLON {
  58269. /** @hidden */
  58270. export var grainPixelShader: {
  58271. name: string;
  58272. shader: string;
  58273. };
  58274. }
  58275. declare module BABYLON {
  58276. /**
  58277. * The GrainPostProcess adds noise to the image at mid luminance levels
  58278. */
  58279. export class GrainPostProcess extends PostProcess {
  58280. /**
  58281. * The intensity of the grain added (default: 30)
  58282. */
  58283. intensity: number;
  58284. /**
  58285. * If the grain should be randomized on every frame
  58286. */
  58287. animated: boolean;
  58288. /**
  58289. * Creates a new instance of @see GrainPostProcess
  58290. * @param name The name of the effect.
  58291. * @param options The required width/height ratio to downsize to before computing the render pass.
  58292. * @param camera The camera to apply the render pass to.
  58293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58294. * @param engine The engine which the post process will be applied. (default: current engine)
  58295. * @param reusable If the post process can be reused on the same frame. (default: false)
  58296. * @param textureType Type of textures used when performing the post process. (default: 0)
  58297. * @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)
  58298. */
  58299. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58300. }
  58301. }
  58302. declare module BABYLON {
  58303. /** @hidden */
  58304. export var highlightsPixelShader: {
  58305. name: string;
  58306. shader: string;
  58307. };
  58308. }
  58309. declare module BABYLON {
  58310. /**
  58311. * Extracts highlights from the image
  58312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58313. */
  58314. export class HighlightsPostProcess extends PostProcess {
  58315. /**
  58316. * Extracts highlights from the image
  58317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58318. * @param name The name of the effect.
  58319. * @param options The required width/height ratio to downsize to before computing the render pass.
  58320. * @param camera The camera to apply the render pass to.
  58321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58322. * @param engine The engine which the post process will be applied. (default: current engine)
  58323. * @param reusable If the post process can be reused on the same frame. (default: false)
  58324. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58325. */
  58326. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58327. }
  58328. }
  58329. declare module BABYLON {
  58330. /** @hidden */
  58331. export var mrtFragmentDeclaration: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module BABYLON {
  58337. /** @hidden */
  58338. export var geometryPixelShader: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module BABYLON {
  58344. /** @hidden */
  58345. export var geometryVertexShader: {
  58346. name: string;
  58347. shader: string;
  58348. };
  58349. }
  58350. declare module BABYLON {
  58351. /** @hidden */
  58352. interface ISavedTransformationMatrix {
  58353. world: Matrix;
  58354. viewProjection: Matrix;
  58355. }
  58356. /**
  58357. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58358. */
  58359. export class GeometryBufferRenderer {
  58360. /**
  58361. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58362. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58363. */
  58364. static readonly POSITION_TEXTURE_TYPE: number;
  58365. /**
  58366. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58367. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58368. */
  58369. static readonly VELOCITY_TEXTURE_TYPE: number;
  58370. /**
  58371. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58372. * in order to compute objects velocities when enableVelocity is set to "true"
  58373. * @hidden
  58374. */
  58375. _previousTransformationMatrices: {
  58376. [index: number]: ISavedTransformationMatrix;
  58377. };
  58378. /**
  58379. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58380. * in order to compute objects velocities when enableVelocity is set to "true"
  58381. * @hidden
  58382. */
  58383. _previousBonesTransformationMatrices: {
  58384. [index: number]: Float32Array;
  58385. };
  58386. /**
  58387. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58388. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58389. */
  58390. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58391. private _scene;
  58392. private _multiRenderTarget;
  58393. private _ratio;
  58394. private _enablePosition;
  58395. private _enableVelocity;
  58396. private _positionIndex;
  58397. private _velocityIndex;
  58398. protected _effect: Effect;
  58399. protected _cachedDefines: string;
  58400. /**
  58401. * Set the render list (meshes to be rendered) used in the G buffer.
  58402. */
  58403. renderList: Mesh[];
  58404. /**
  58405. * Gets wether or not G buffer are supported by the running hardware.
  58406. * This requires draw buffer supports
  58407. */
  58408. readonly isSupported: boolean;
  58409. /**
  58410. * Returns the index of the given texture type in the G-Buffer textures array
  58411. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58412. * @returns the index of the given texture type in the G-Buffer textures array
  58413. */
  58414. getTextureIndex(textureType: number): number;
  58415. /**
  58416. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58417. */
  58418. /**
  58419. * Sets whether or not objects positions are enabled for the G buffer.
  58420. */
  58421. enablePosition: boolean;
  58422. /**
  58423. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58424. */
  58425. /**
  58426. * Sets wether or not objects velocities are enabled for the G buffer.
  58427. */
  58428. enableVelocity: boolean;
  58429. /**
  58430. * Gets the scene associated with the buffer.
  58431. */
  58432. readonly scene: Scene;
  58433. /**
  58434. * Gets the ratio used by the buffer during its creation.
  58435. * How big is the buffer related to the main canvas.
  58436. */
  58437. readonly ratio: number;
  58438. /** @hidden */
  58439. static _SceneComponentInitialization: (scene: Scene) => void;
  58440. /**
  58441. * Creates a new G Buffer for the scene
  58442. * @param scene The scene the buffer belongs to
  58443. * @param ratio How big is the buffer related to the main canvas.
  58444. */
  58445. constructor(scene: Scene, ratio?: number);
  58446. /**
  58447. * Checks wether everything is ready to render a submesh to the G buffer.
  58448. * @param subMesh the submesh to check readiness for
  58449. * @param useInstances is the mesh drawn using instance or not
  58450. * @returns true if ready otherwise false
  58451. */
  58452. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58453. /**
  58454. * Gets the current underlying G Buffer.
  58455. * @returns the buffer
  58456. */
  58457. getGBuffer(): MultiRenderTarget;
  58458. /**
  58459. * Gets the number of samples used to render the buffer (anti aliasing).
  58460. */
  58461. /**
  58462. * Sets the number of samples used to render the buffer (anti aliasing).
  58463. */
  58464. samples: number;
  58465. /**
  58466. * Disposes the renderer and frees up associated resources.
  58467. */
  58468. dispose(): void;
  58469. protected _createRenderTargets(): void;
  58470. private _copyBonesTransformationMatrices;
  58471. }
  58472. }
  58473. declare module BABYLON {
  58474. interface Scene {
  58475. /** @hidden (Backing field) */
  58476. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58477. /**
  58478. * Gets or Sets the current geometry buffer associated to the scene.
  58479. */
  58480. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58481. /**
  58482. * Enables a GeometryBufferRender and associates it with the scene
  58483. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58484. * @returns the GeometryBufferRenderer
  58485. */
  58486. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58487. /**
  58488. * Disables the GeometryBufferRender associated with the scene
  58489. */
  58490. disableGeometryBufferRenderer(): void;
  58491. }
  58492. /**
  58493. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58494. * in several rendering techniques.
  58495. */
  58496. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58497. /**
  58498. * The component name helpful to identify the component in the list of scene components.
  58499. */
  58500. readonly name: string;
  58501. /**
  58502. * The scene the component belongs to.
  58503. */
  58504. scene: Scene;
  58505. /**
  58506. * Creates a new instance of the component for the given scene
  58507. * @param scene Defines the scene to register the component in
  58508. */
  58509. constructor(scene: Scene);
  58510. /**
  58511. * Registers the component in a given scene
  58512. */
  58513. register(): void;
  58514. /**
  58515. * Rebuilds the elements related to this component in case of
  58516. * context lost for instance.
  58517. */
  58518. rebuild(): void;
  58519. /**
  58520. * Disposes the component and the associated ressources
  58521. */
  58522. dispose(): void;
  58523. private _gatherRenderTargets;
  58524. }
  58525. }
  58526. declare module BABYLON {
  58527. /** @hidden */
  58528. export var motionBlurPixelShader: {
  58529. name: string;
  58530. shader: string;
  58531. };
  58532. }
  58533. declare module BABYLON {
  58534. /**
  58535. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58536. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58537. * As an example, all you have to do is to create the post-process:
  58538. * var mb = new BABYLON.MotionBlurPostProcess(
  58539. * 'mb', // The name of the effect.
  58540. * scene, // The scene containing the objects to blur according to their velocity.
  58541. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58542. * camera // The camera to apply the render pass to.
  58543. * );
  58544. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58545. */
  58546. export class MotionBlurPostProcess extends PostProcess {
  58547. /**
  58548. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58549. */
  58550. motionStrength: number;
  58551. /**
  58552. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58553. */
  58554. /**
  58555. * Sets the number of iterations to be used for motion blur quality
  58556. */
  58557. motionBlurSamples: number;
  58558. private _motionBlurSamples;
  58559. private _geometryBufferRenderer;
  58560. /**
  58561. * Creates a new instance MotionBlurPostProcess
  58562. * @param name The name of the effect.
  58563. * @param scene The scene containing the objects to blur according to their velocity.
  58564. * @param options The required width/height ratio to downsize to before computing the render pass.
  58565. * @param camera The camera to apply the render pass to.
  58566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58567. * @param engine The engine which the post process will be applied. (default: current engine)
  58568. * @param reusable If the post process can be reused on the same frame. (default: false)
  58569. * @param textureType Type of textures used when performing the post process. (default: 0)
  58570. * @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)
  58571. */
  58572. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58573. /**
  58574. * Excludes the given skinned mesh from computing bones velocities.
  58575. * 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.
  58576. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58577. */
  58578. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58579. /**
  58580. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58581. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58582. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58583. */
  58584. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58585. /**
  58586. * Disposes the post process.
  58587. * @param camera The camera to dispose the post process on.
  58588. */
  58589. dispose(camera?: Camera): void;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /** @hidden */
  58594. export var refractionPixelShader: {
  58595. name: string;
  58596. shader: string;
  58597. };
  58598. }
  58599. declare module BABYLON {
  58600. /**
  58601. * Post process which applies a refractin texture
  58602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58603. */
  58604. export class RefractionPostProcess extends PostProcess {
  58605. /** the base color of the refraction (used to taint the rendering) */
  58606. color: Color3;
  58607. /** simulated refraction depth */
  58608. depth: number;
  58609. /** the coefficient of the base color (0 to remove base color tainting) */
  58610. colorLevel: number;
  58611. private _refTexture;
  58612. private _ownRefractionTexture;
  58613. /**
  58614. * Gets or sets the refraction texture
  58615. * Please note that you are responsible for disposing the texture if you set it manually
  58616. */
  58617. refractionTexture: Texture;
  58618. /**
  58619. * Initializes the RefractionPostProcess
  58620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58621. * @param name The name of the effect.
  58622. * @param refractionTextureUrl Url of the refraction texture to use
  58623. * @param color the base color of the refraction (used to taint the rendering)
  58624. * @param depth simulated refraction depth
  58625. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58626. * @param camera The camera to apply the render pass to.
  58627. * @param options The required width/height ratio to downsize to before computing the render pass.
  58628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58629. * @param engine The engine which the post process will be applied. (default: current engine)
  58630. * @param reusable If the post process can be reused on the same frame. (default: false)
  58631. */
  58632. constructor(name: string, refractionTextureUrl: string,
  58633. /** the base color of the refraction (used to taint the rendering) */
  58634. color: Color3,
  58635. /** simulated refraction depth */
  58636. depth: number,
  58637. /** the coefficient of the base color (0 to remove base color tainting) */
  58638. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58639. /**
  58640. * Disposes of the post process
  58641. * @param camera Camera to dispose post process on
  58642. */
  58643. dispose(camera: Camera): void;
  58644. }
  58645. }
  58646. declare module BABYLON {
  58647. /** @hidden */
  58648. export var sharpenPixelShader: {
  58649. name: string;
  58650. shader: string;
  58651. };
  58652. }
  58653. declare module BABYLON {
  58654. /**
  58655. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58656. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58657. */
  58658. export class SharpenPostProcess extends PostProcess {
  58659. /**
  58660. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58661. */
  58662. colorAmount: number;
  58663. /**
  58664. * How much sharpness should be applied (default: 0.3)
  58665. */
  58666. edgeAmount: number;
  58667. /**
  58668. * Creates a new instance ConvolutionPostProcess
  58669. * @param name The name of the effect.
  58670. * @param options The required width/height ratio to downsize to before computing the render pass.
  58671. * @param camera The camera to apply the render pass to.
  58672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58673. * @param engine The engine which the post process will be applied. (default: current engine)
  58674. * @param reusable If the post process can be reused on the same frame. (default: false)
  58675. * @param textureType Type of textures used when performing the post process. (default: 0)
  58676. * @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)
  58677. */
  58678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /**
  58683. * PostProcessRenderPipeline
  58684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58685. */
  58686. export class PostProcessRenderPipeline {
  58687. private engine;
  58688. private _renderEffects;
  58689. private _renderEffectsForIsolatedPass;
  58690. /**
  58691. * List of inspectable custom properties (used by the Inspector)
  58692. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58693. */
  58694. inspectableCustomProperties: IInspectable[];
  58695. /**
  58696. * @hidden
  58697. */
  58698. protected _cameras: Camera[];
  58699. /** @hidden */
  58700. _name: string;
  58701. /**
  58702. * Gets pipeline name
  58703. */
  58704. readonly name: string;
  58705. /**
  58706. * Initializes a PostProcessRenderPipeline
  58707. * @param engine engine to add the pipeline to
  58708. * @param name name of the pipeline
  58709. */
  58710. constructor(engine: Engine, name: string);
  58711. /**
  58712. * Gets the class name
  58713. * @returns "PostProcessRenderPipeline"
  58714. */
  58715. getClassName(): string;
  58716. /**
  58717. * If all the render effects in the pipeline are supported
  58718. */
  58719. readonly isSupported: boolean;
  58720. /**
  58721. * Adds an effect to the pipeline
  58722. * @param renderEffect the effect to add
  58723. */
  58724. addEffect(renderEffect: PostProcessRenderEffect): void;
  58725. /** @hidden */
  58726. _rebuild(): void;
  58727. /** @hidden */
  58728. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58729. /** @hidden */
  58730. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58731. /** @hidden */
  58732. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58733. /** @hidden */
  58734. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58735. /** @hidden */
  58736. _attachCameras(cameras: Camera, unique: boolean): void;
  58737. /** @hidden */
  58738. _attachCameras(cameras: Camera[], unique: boolean): void;
  58739. /** @hidden */
  58740. _detachCameras(cameras: Camera): void;
  58741. /** @hidden */
  58742. _detachCameras(cameras: Nullable<Camera[]>): void;
  58743. /** @hidden */
  58744. _update(): void;
  58745. /** @hidden */
  58746. _reset(): void;
  58747. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58748. /**
  58749. * Disposes of the pipeline
  58750. */
  58751. dispose(): void;
  58752. }
  58753. }
  58754. declare module BABYLON {
  58755. /**
  58756. * PostProcessRenderPipelineManager class
  58757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58758. */
  58759. export class PostProcessRenderPipelineManager {
  58760. private _renderPipelines;
  58761. /**
  58762. * Initializes a PostProcessRenderPipelineManager
  58763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58764. */
  58765. constructor();
  58766. /**
  58767. * Gets the list of supported render pipelines
  58768. */
  58769. readonly supportedPipelines: PostProcessRenderPipeline[];
  58770. /**
  58771. * Adds a pipeline to the manager
  58772. * @param renderPipeline The pipeline to add
  58773. */
  58774. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58775. /**
  58776. * Attaches a camera to the pipeline
  58777. * @param renderPipelineName The name of the pipeline to attach to
  58778. * @param cameras the camera to attach
  58779. * @param unique if the camera can be attached multiple times to the pipeline
  58780. */
  58781. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58782. /**
  58783. * Detaches a camera from the pipeline
  58784. * @param renderPipelineName The name of the pipeline to detach from
  58785. * @param cameras the camera to detach
  58786. */
  58787. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58788. /**
  58789. * Enables an effect by name on a pipeline
  58790. * @param renderPipelineName the name of the pipeline to enable the effect in
  58791. * @param renderEffectName the name of the effect to enable
  58792. * @param cameras the cameras that the effect should be enabled on
  58793. */
  58794. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58795. /**
  58796. * Disables an effect by name on a pipeline
  58797. * @param renderPipelineName the name of the pipeline to disable the effect in
  58798. * @param renderEffectName the name of the effect to disable
  58799. * @param cameras the cameras that the effect should be disabled on
  58800. */
  58801. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58802. /**
  58803. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58804. */
  58805. update(): void;
  58806. /** @hidden */
  58807. _rebuild(): void;
  58808. /**
  58809. * Disposes of the manager and pipelines
  58810. */
  58811. dispose(): void;
  58812. }
  58813. }
  58814. declare module BABYLON {
  58815. interface Scene {
  58816. /** @hidden (Backing field) */
  58817. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58818. /**
  58819. * Gets the postprocess render pipeline manager
  58820. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58821. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58822. */
  58823. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58824. }
  58825. /**
  58826. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58827. */
  58828. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58829. /**
  58830. * The component name helpfull to identify the component in the list of scene components.
  58831. */
  58832. readonly name: string;
  58833. /**
  58834. * The scene the component belongs to.
  58835. */
  58836. scene: Scene;
  58837. /**
  58838. * Creates a new instance of the component for the given scene
  58839. * @param scene Defines the scene to register the component in
  58840. */
  58841. constructor(scene: Scene);
  58842. /**
  58843. * Registers the component in a given scene
  58844. */
  58845. register(): void;
  58846. /**
  58847. * Rebuilds the elements related to this component in case of
  58848. * context lost for instance.
  58849. */
  58850. rebuild(): void;
  58851. /**
  58852. * Disposes the component and the associated ressources
  58853. */
  58854. dispose(): void;
  58855. private _gatherRenderTargets;
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /**
  58860. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58861. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58862. */
  58863. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58864. private _scene;
  58865. private _camerasToBeAttached;
  58866. /**
  58867. * ID of the sharpen post process,
  58868. */
  58869. private readonly SharpenPostProcessId;
  58870. /**
  58871. * @ignore
  58872. * ID of the image processing post process;
  58873. */
  58874. readonly ImageProcessingPostProcessId: string;
  58875. /**
  58876. * @ignore
  58877. * ID of the Fast Approximate Anti-Aliasing post process;
  58878. */
  58879. readonly FxaaPostProcessId: string;
  58880. /**
  58881. * ID of the chromatic aberration post process,
  58882. */
  58883. private readonly ChromaticAberrationPostProcessId;
  58884. /**
  58885. * ID of the grain post process
  58886. */
  58887. private readonly GrainPostProcessId;
  58888. /**
  58889. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58890. */
  58891. sharpen: SharpenPostProcess;
  58892. private _sharpenEffect;
  58893. private bloom;
  58894. /**
  58895. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58896. */
  58897. depthOfField: DepthOfFieldEffect;
  58898. /**
  58899. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58900. */
  58901. fxaa: FxaaPostProcess;
  58902. /**
  58903. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58904. */
  58905. imageProcessing: ImageProcessingPostProcess;
  58906. /**
  58907. * Chromatic aberration post process which will shift rgb colors in the image
  58908. */
  58909. chromaticAberration: ChromaticAberrationPostProcess;
  58910. private _chromaticAberrationEffect;
  58911. /**
  58912. * Grain post process which add noise to the image
  58913. */
  58914. grain: GrainPostProcess;
  58915. private _grainEffect;
  58916. /**
  58917. * Glow post process which adds a glow to emissive areas of the image
  58918. */
  58919. private _glowLayer;
  58920. /**
  58921. * Animations which can be used to tweak settings over a period of time
  58922. */
  58923. animations: Animation[];
  58924. private _imageProcessingConfigurationObserver;
  58925. private _sharpenEnabled;
  58926. private _bloomEnabled;
  58927. private _depthOfFieldEnabled;
  58928. private _depthOfFieldBlurLevel;
  58929. private _fxaaEnabled;
  58930. private _imageProcessingEnabled;
  58931. private _defaultPipelineTextureType;
  58932. private _bloomScale;
  58933. private _chromaticAberrationEnabled;
  58934. private _grainEnabled;
  58935. private _buildAllowed;
  58936. /**
  58937. * Gets active scene
  58938. */
  58939. readonly scene: Scene;
  58940. /**
  58941. * Enable or disable the sharpen process from the pipeline
  58942. */
  58943. sharpenEnabled: boolean;
  58944. private _resizeObserver;
  58945. private _hardwareScaleLevel;
  58946. private _bloomKernel;
  58947. /**
  58948. * Specifies the size of the bloom blur kernel, relative to the final output size
  58949. */
  58950. bloomKernel: number;
  58951. /**
  58952. * Specifies the weight of the bloom in the final rendering
  58953. */
  58954. private _bloomWeight;
  58955. /**
  58956. * Specifies the luma threshold for the area that will be blurred by the bloom
  58957. */
  58958. private _bloomThreshold;
  58959. private _hdr;
  58960. /**
  58961. * The strength of the bloom.
  58962. */
  58963. bloomWeight: number;
  58964. /**
  58965. * The strength of the bloom.
  58966. */
  58967. bloomThreshold: number;
  58968. /**
  58969. * The scale of the bloom, lower value will provide better performance.
  58970. */
  58971. bloomScale: number;
  58972. /**
  58973. * Enable or disable the bloom from the pipeline
  58974. */
  58975. bloomEnabled: boolean;
  58976. private _rebuildBloom;
  58977. /**
  58978. * If the depth of field is enabled.
  58979. */
  58980. depthOfFieldEnabled: boolean;
  58981. /**
  58982. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58983. */
  58984. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58985. /**
  58986. * If the anti aliasing is enabled.
  58987. */
  58988. fxaaEnabled: boolean;
  58989. private _samples;
  58990. /**
  58991. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58992. */
  58993. samples: number;
  58994. /**
  58995. * If image processing is enabled.
  58996. */
  58997. imageProcessingEnabled: boolean;
  58998. /**
  58999. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59000. */
  59001. glowLayerEnabled: boolean;
  59002. /**
  59003. * Gets the glow layer (or null if not defined)
  59004. */
  59005. readonly glowLayer: Nullable<GlowLayer>;
  59006. /**
  59007. * Enable or disable the chromaticAberration process from the pipeline
  59008. */
  59009. chromaticAberrationEnabled: boolean;
  59010. /**
  59011. * Enable or disable the grain process from the pipeline
  59012. */
  59013. grainEnabled: boolean;
  59014. /**
  59015. * @constructor
  59016. * @param name - The rendering pipeline name (default: "")
  59017. * @param hdr - If high dynamic range textures should be used (default: true)
  59018. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59019. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59020. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59021. */
  59022. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59023. /**
  59024. * Get the class name
  59025. * @returns "DefaultRenderingPipeline"
  59026. */
  59027. getClassName(): string;
  59028. /**
  59029. * Force the compilation of the entire pipeline.
  59030. */
  59031. prepare(): void;
  59032. private _hasCleared;
  59033. private _prevPostProcess;
  59034. private _prevPrevPostProcess;
  59035. private _setAutoClearAndTextureSharing;
  59036. private _depthOfFieldSceneObserver;
  59037. private _buildPipeline;
  59038. private _disposePostProcesses;
  59039. /**
  59040. * Adds a camera to the pipeline
  59041. * @param camera the camera to be added
  59042. */
  59043. addCamera(camera: Camera): void;
  59044. /**
  59045. * Removes a camera from the pipeline
  59046. * @param camera the camera to remove
  59047. */
  59048. removeCamera(camera: Camera): void;
  59049. /**
  59050. * Dispose of the pipeline and stop all post processes
  59051. */
  59052. dispose(): void;
  59053. /**
  59054. * Serialize the rendering pipeline (Used when exporting)
  59055. * @returns the serialized object
  59056. */
  59057. serialize(): any;
  59058. /**
  59059. * Parse the serialized pipeline
  59060. * @param source Source pipeline.
  59061. * @param scene The scene to load the pipeline to.
  59062. * @param rootUrl The URL of the serialized pipeline.
  59063. * @returns An instantiated pipeline from the serialized object.
  59064. */
  59065. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59066. }
  59067. }
  59068. declare module BABYLON {
  59069. /** @hidden */
  59070. export var lensHighlightsPixelShader: {
  59071. name: string;
  59072. shader: string;
  59073. };
  59074. }
  59075. declare module BABYLON {
  59076. /** @hidden */
  59077. export var depthOfFieldPixelShader: {
  59078. name: string;
  59079. shader: string;
  59080. };
  59081. }
  59082. declare module BABYLON {
  59083. /**
  59084. * BABYLON.JS Chromatic Aberration GLSL Shader
  59085. * Author: Olivier Guyot
  59086. * Separates very slightly R, G and B colors on the edges of the screen
  59087. * Inspired by Francois Tarlier & Martins Upitis
  59088. */
  59089. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59090. /**
  59091. * @ignore
  59092. * The chromatic aberration PostProcess id in the pipeline
  59093. */
  59094. LensChromaticAberrationEffect: string;
  59095. /**
  59096. * @ignore
  59097. * The highlights enhancing PostProcess id in the pipeline
  59098. */
  59099. HighlightsEnhancingEffect: string;
  59100. /**
  59101. * @ignore
  59102. * The depth-of-field PostProcess id in the pipeline
  59103. */
  59104. LensDepthOfFieldEffect: string;
  59105. private _scene;
  59106. private _depthTexture;
  59107. private _grainTexture;
  59108. private _chromaticAberrationPostProcess;
  59109. private _highlightsPostProcess;
  59110. private _depthOfFieldPostProcess;
  59111. private _edgeBlur;
  59112. private _grainAmount;
  59113. private _chromaticAberration;
  59114. private _distortion;
  59115. private _highlightsGain;
  59116. private _highlightsThreshold;
  59117. private _dofDistance;
  59118. private _dofAperture;
  59119. private _dofDarken;
  59120. private _dofPentagon;
  59121. private _blurNoise;
  59122. /**
  59123. * @constructor
  59124. *
  59125. * Effect parameters are as follow:
  59126. * {
  59127. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59128. * edge_blur: number; // from 0 to x (1 for realism)
  59129. * distortion: number; // from 0 to x (1 for realism)
  59130. * grain_amount: number; // from 0 to 1
  59131. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59132. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59133. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59134. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59135. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59136. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59137. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59138. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59139. * }
  59140. * Note: if an effect parameter is unset, effect is disabled
  59141. *
  59142. * @param name The rendering pipeline name
  59143. * @param parameters - An object containing all parameters (see above)
  59144. * @param scene The scene linked to this pipeline
  59145. * @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)
  59146. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59147. */
  59148. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59149. /**
  59150. * Get the class name
  59151. * @returns "LensRenderingPipeline"
  59152. */
  59153. getClassName(): string;
  59154. /**
  59155. * Gets associated scene
  59156. */
  59157. readonly scene: Scene;
  59158. /**
  59159. * Gets or sets the edge blur
  59160. */
  59161. edgeBlur: number;
  59162. /**
  59163. * Gets or sets the grain amount
  59164. */
  59165. grainAmount: number;
  59166. /**
  59167. * Gets or sets the chromatic aberration amount
  59168. */
  59169. chromaticAberration: number;
  59170. /**
  59171. * Gets or sets the depth of field aperture
  59172. */
  59173. dofAperture: number;
  59174. /**
  59175. * Gets or sets the edge distortion
  59176. */
  59177. edgeDistortion: number;
  59178. /**
  59179. * Gets or sets the depth of field distortion
  59180. */
  59181. dofDistortion: number;
  59182. /**
  59183. * Gets or sets the darken out of focus amount
  59184. */
  59185. darkenOutOfFocus: number;
  59186. /**
  59187. * Gets or sets a boolean indicating if blur noise is enabled
  59188. */
  59189. blurNoise: boolean;
  59190. /**
  59191. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59192. */
  59193. pentagonBokeh: boolean;
  59194. /**
  59195. * Gets or sets the highlight grain amount
  59196. */
  59197. highlightsGain: number;
  59198. /**
  59199. * Gets or sets the highlight threshold
  59200. */
  59201. highlightsThreshold: number;
  59202. /**
  59203. * Sets the amount of blur at the edges
  59204. * @param amount blur amount
  59205. */
  59206. setEdgeBlur(amount: number): void;
  59207. /**
  59208. * Sets edge blur to 0
  59209. */
  59210. disableEdgeBlur(): void;
  59211. /**
  59212. * Sets the amout of grain
  59213. * @param amount Amount of grain
  59214. */
  59215. setGrainAmount(amount: number): void;
  59216. /**
  59217. * Set grain amount to 0
  59218. */
  59219. disableGrain(): void;
  59220. /**
  59221. * Sets the chromatic aberration amount
  59222. * @param amount amount of chromatic aberration
  59223. */
  59224. setChromaticAberration(amount: number): void;
  59225. /**
  59226. * Sets chromatic aberration amount to 0
  59227. */
  59228. disableChromaticAberration(): void;
  59229. /**
  59230. * Sets the EdgeDistortion amount
  59231. * @param amount amount of EdgeDistortion
  59232. */
  59233. setEdgeDistortion(amount: number): void;
  59234. /**
  59235. * Sets edge distortion to 0
  59236. */
  59237. disableEdgeDistortion(): void;
  59238. /**
  59239. * Sets the FocusDistance amount
  59240. * @param amount amount of FocusDistance
  59241. */
  59242. setFocusDistance(amount: number): void;
  59243. /**
  59244. * Disables depth of field
  59245. */
  59246. disableDepthOfField(): void;
  59247. /**
  59248. * Sets the Aperture amount
  59249. * @param amount amount of Aperture
  59250. */
  59251. setAperture(amount: number): void;
  59252. /**
  59253. * Sets the DarkenOutOfFocus amount
  59254. * @param amount amount of DarkenOutOfFocus
  59255. */
  59256. setDarkenOutOfFocus(amount: number): void;
  59257. private _pentagonBokehIsEnabled;
  59258. /**
  59259. * Creates a pentagon bokeh effect
  59260. */
  59261. enablePentagonBokeh(): void;
  59262. /**
  59263. * Disables the pentagon bokeh effect
  59264. */
  59265. disablePentagonBokeh(): void;
  59266. /**
  59267. * Enables noise blur
  59268. */
  59269. enableNoiseBlur(): void;
  59270. /**
  59271. * Disables noise blur
  59272. */
  59273. disableNoiseBlur(): void;
  59274. /**
  59275. * Sets the HighlightsGain amount
  59276. * @param amount amount of HighlightsGain
  59277. */
  59278. setHighlightsGain(amount: number): void;
  59279. /**
  59280. * Sets the HighlightsThreshold amount
  59281. * @param amount amount of HighlightsThreshold
  59282. */
  59283. setHighlightsThreshold(amount: number): void;
  59284. /**
  59285. * Disables highlights
  59286. */
  59287. disableHighlights(): void;
  59288. /**
  59289. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59290. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59291. */
  59292. dispose(disableDepthRender?: boolean): void;
  59293. private _createChromaticAberrationPostProcess;
  59294. private _createHighlightsPostProcess;
  59295. private _createDepthOfFieldPostProcess;
  59296. private _createGrainTexture;
  59297. }
  59298. }
  59299. declare module BABYLON {
  59300. /** @hidden */
  59301. export var ssao2PixelShader: {
  59302. name: string;
  59303. shader: string;
  59304. };
  59305. }
  59306. declare module BABYLON {
  59307. /** @hidden */
  59308. export var ssaoCombinePixelShader: {
  59309. name: string;
  59310. shader: string;
  59311. };
  59312. }
  59313. declare module BABYLON {
  59314. /**
  59315. * Render pipeline to produce ssao effect
  59316. */
  59317. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59318. /**
  59319. * @ignore
  59320. * The PassPostProcess id in the pipeline that contains the original scene color
  59321. */
  59322. SSAOOriginalSceneColorEffect: string;
  59323. /**
  59324. * @ignore
  59325. * The SSAO PostProcess id in the pipeline
  59326. */
  59327. SSAORenderEffect: string;
  59328. /**
  59329. * @ignore
  59330. * The horizontal blur PostProcess id in the pipeline
  59331. */
  59332. SSAOBlurHRenderEffect: string;
  59333. /**
  59334. * @ignore
  59335. * The vertical blur PostProcess id in the pipeline
  59336. */
  59337. SSAOBlurVRenderEffect: string;
  59338. /**
  59339. * @ignore
  59340. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59341. */
  59342. SSAOCombineRenderEffect: string;
  59343. /**
  59344. * The output strength of the SSAO post-process. Default value is 1.0.
  59345. */
  59346. totalStrength: number;
  59347. /**
  59348. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59349. */
  59350. maxZ: number;
  59351. /**
  59352. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59353. */
  59354. minZAspect: number;
  59355. private _samples;
  59356. /**
  59357. * Number of samples used for the SSAO calculations. Default value is 8
  59358. */
  59359. samples: number;
  59360. private _textureSamples;
  59361. /**
  59362. * Number of samples to use for antialiasing
  59363. */
  59364. textureSamples: number;
  59365. /**
  59366. * Ratio object used for SSAO ratio and blur ratio
  59367. */
  59368. private _ratio;
  59369. /**
  59370. * Dynamically generated sphere sampler.
  59371. */
  59372. private _sampleSphere;
  59373. /**
  59374. * Blur filter offsets
  59375. */
  59376. private _samplerOffsets;
  59377. private _expensiveBlur;
  59378. /**
  59379. * If bilateral blur should be used
  59380. */
  59381. expensiveBlur: boolean;
  59382. /**
  59383. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59384. */
  59385. radius: number;
  59386. /**
  59387. * The base color of the SSAO post-process
  59388. * The final result is "base + ssao" between [0, 1]
  59389. */
  59390. base: number;
  59391. /**
  59392. * Support test.
  59393. */
  59394. static readonly IsSupported: boolean;
  59395. private _scene;
  59396. private _depthTexture;
  59397. private _normalTexture;
  59398. private _randomTexture;
  59399. private _originalColorPostProcess;
  59400. private _ssaoPostProcess;
  59401. private _blurHPostProcess;
  59402. private _blurVPostProcess;
  59403. private _ssaoCombinePostProcess;
  59404. private _firstUpdate;
  59405. /**
  59406. * Gets active scene
  59407. */
  59408. readonly scene: Scene;
  59409. /**
  59410. * @constructor
  59411. * @param name The rendering pipeline name
  59412. * @param scene The scene linked to this pipeline
  59413. * @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 }
  59414. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59415. */
  59416. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59417. /**
  59418. * Get the class name
  59419. * @returns "SSAO2RenderingPipeline"
  59420. */
  59421. getClassName(): string;
  59422. /**
  59423. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59424. */
  59425. dispose(disableGeometryBufferRenderer?: boolean): void;
  59426. private _createBlurPostProcess;
  59427. /** @hidden */
  59428. _rebuild(): void;
  59429. private _bits;
  59430. private _radicalInverse_VdC;
  59431. private _hammersley;
  59432. private _hemisphereSample_uniform;
  59433. private _generateHemisphere;
  59434. private _createSSAOPostProcess;
  59435. private _createSSAOCombinePostProcess;
  59436. private _createRandomTexture;
  59437. /**
  59438. * Serialize the rendering pipeline (Used when exporting)
  59439. * @returns the serialized object
  59440. */
  59441. serialize(): any;
  59442. /**
  59443. * Parse the serialized pipeline
  59444. * @param source Source pipeline.
  59445. * @param scene The scene to load the pipeline to.
  59446. * @param rootUrl The URL of the serialized pipeline.
  59447. * @returns An instantiated pipeline from the serialized object.
  59448. */
  59449. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59450. }
  59451. }
  59452. declare module BABYLON {
  59453. /** @hidden */
  59454. export var ssaoPixelShader: {
  59455. name: string;
  59456. shader: string;
  59457. };
  59458. }
  59459. declare module BABYLON {
  59460. /**
  59461. * Render pipeline to produce ssao effect
  59462. */
  59463. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59464. /**
  59465. * @ignore
  59466. * The PassPostProcess id in the pipeline that contains the original scene color
  59467. */
  59468. SSAOOriginalSceneColorEffect: string;
  59469. /**
  59470. * @ignore
  59471. * The SSAO PostProcess id in the pipeline
  59472. */
  59473. SSAORenderEffect: string;
  59474. /**
  59475. * @ignore
  59476. * The horizontal blur PostProcess id in the pipeline
  59477. */
  59478. SSAOBlurHRenderEffect: string;
  59479. /**
  59480. * @ignore
  59481. * The vertical blur PostProcess id in the pipeline
  59482. */
  59483. SSAOBlurVRenderEffect: string;
  59484. /**
  59485. * @ignore
  59486. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59487. */
  59488. SSAOCombineRenderEffect: string;
  59489. /**
  59490. * The output strength of the SSAO post-process. Default value is 1.0.
  59491. */
  59492. totalStrength: number;
  59493. /**
  59494. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59495. */
  59496. radius: number;
  59497. /**
  59498. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59499. * Must not be equal to fallOff and superior to fallOff.
  59500. * Default value is 0.0075
  59501. */
  59502. area: number;
  59503. /**
  59504. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59505. * Must not be equal to area and inferior to area.
  59506. * Default value is 0.000001
  59507. */
  59508. fallOff: number;
  59509. /**
  59510. * The base color of the SSAO post-process
  59511. * The final result is "base + ssao" between [0, 1]
  59512. */
  59513. base: number;
  59514. private _scene;
  59515. private _depthTexture;
  59516. private _randomTexture;
  59517. private _originalColorPostProcess;
  59518. private _ssaoPostProcess;
  59519. private _blurHPostProcess;
  59520. private _blurVPostProcess;
  59521. private _ssaoCombinePostProcess;
  59522. private _firstUpdate;
  59523. /**
  59524. * Gets active scene
  59525. */
  59526. readonly scene: Scene;
  59527. /**
  59528. * @constructor
  59529. * @param name - The rendering pipeline name
  59530. * @param scene - The scene linked to this pipeline
  59531. * @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 }
  59532. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59533. */
  59534. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59535. /**
  59536. * Get the class name
  59537. * @returns "SSAORenderingPipeline"
  59538. */
  59539. getClassName(): string;
  59540. /**
  59541. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59542. */
  59543. dispose(disableDepthRender?: boolean): void;
  59544. private _createBlurPostProcess;
  59545. /** @hidden */
  59546. _rebuild(): void;
  59547. private _createSSAOPostProcess;
  59548. private _createSSAOCombinePostProcess;
  59549. private _createRandomTexture;
  59550. }
  59551. }
  59552. declare module BABYLON {
  59553. /** @hidden */
  59554. export var standardPixelShader: {
  59555. name: string;
  59556. shader: string;
  59557. };
  59558. }
  59559. declare module BABYLON {
  59560. /**
  59561. * Standard rendering pipeline
  59562. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59563. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59564. */
  59565. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59566. /**
  59567. * Public members
  59568. */
  59569. /**
  59570. * Post-process which contains the original scene color before the pipeline applies all the effects
  59571. */
  59572. originalPostProcess: Nullable<PostProcess>;
  59573. /**
  59574. * Post-process used to down scale an image x4
  59575. */
  59576. downSampleX4PostProcess: Nullable<PostProcess>;
  59577. /**
  59578. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59579. */
  59580. brightPassPostProcess: Nullable<PostProcess>;
  59581. /**
  59582. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59583. */
  59584. blurHPostProcesses: PostProcess[];
  59585. /**
  59586. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59587. */
  59588. blurVPostProcesses: PostProcess[];
  59589. /**
  59590. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59591. */
  59592. textureAdderPostProcess: Nullable<PostProcess>;
  59593. /**
  59594. * Post-process used to create volumetric lighting effect
  59595. */
  59596. volumetricLightPostProcess: Nullable<PostProcess>;
  59597. /**
  59598. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59599. */
  59600. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59601. /**
  59602. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59603. */
  59604. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59605. /**
  59606. * Post-process used to merge the volumetric light effect and the real scene color
  59607. */
  59608. volumetricLightMergePostProces: Nullable<PostProcess>;
  59609. /**
  59610. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59611. */
  59612. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59613. /**
  59614. * Base post-process used to calculate the average luminance of the final image for HDR
  59615. */
  59616. luminancePostProcess: Nullable<PostProcess>;
  59617. /**
  59618. * Post-processes used to create down sample post-processes in order to get
  59619. * the average luminance of the final image for HDR
  59620. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59621. */
  59622. luminanceDownSamplePostProcesses: PostProcess[];
  59623. /**
  59624. * Post-process used to create a HDR effect (light adaptation)
  59625. */
  59626. hdrPostProcess: Nullable<PostProcess>;
  59627. /**
  59628. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59629. */
  59630. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59631. /**
  59632. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59633. */
  59634. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59635. /**
  59636. * Post-process used to merge the final HDR post-process and the real scene color
  59637. */
  59638. hdrFinalPostProcess: Nullable<PostProcess>;
  59639. /**
  59640. * Post-process used to create a lens flare effect
  59641. */
  59642. lensFlarePostProcess: Nullable<PostProcess>;
  59643. /**
  59644. * Post-process that merges the result of the lens flare post-process and the real scene color
  59645. */
  59646. lensFlareComposePostProcess: Nullable<PostProcess>;
  59647. /**
  59648. * Post-process used to create a motion blur effect
  59649. */
  59650. motionBlurPostProcess: Nullable<PostProcess>;
  59651. /**
  59652. * Post-process used to create a depth of field effect
  59653. */
  59654. depthOfFieldPostProcess: Nullable<PostProcess>;
  59655. /**
  59656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59657. */
  59658. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59659. /**
  59660. * Represents the brightness threshold in order to configure the illuminated surfaces
  59661. */
  59662. brightThreshold: number;
  59663. /**
  59664. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59665. */
  59666. blurWidth: number;
  59667. /**
  59668. * Sets if the blur for highlighted surfaces must be only horizontal
  59669. */
  59670. horizontalBlur: boolean;
  59671. /**
  59672. * Gets the overall exposure used by the pipeline
  59673. */
  59674. /**
  59675. * Sets the overall exposure used by the pipeline
  59676. */
  59677. exposure: number;
  59678. /**
  59679. * Texture used typically to simulate "dirty" on camera lens
  59680. */
  59681. lensTexture: Nullable<Texture>;
  59682. /**
  59683. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59684. */
  59685. volumetricLightCoefficient: number;
  59686. /**
  59687. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59688. */
  59689. volumetricLightPower: number;
  59690. /**
  59691. * Used the set the blur intensity to smooth the volumetric lights
  59692. */
  59693. volumetricLightBlurScale: number;
  59694. /**
  59695. * Light (spot or directional) used to generate the volumetric lights rays
  59696. * The source light must have a shadow generate so the pipeline can get its
  59697. * depth map
  59698. */
  59699. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59700. /**
  59701. * For eye adaptation, represents the minimum luminance the eye can see
  59702. */
  59703. hdrMinimumLuminance: number;
  59704. /**
  59705. * For eye adaptation, represents the decrease luminance speed
  59706. */
  59707. hdrDecreaseRate: number;
  59708. /**
  59709. * For eye adaptation, represents the increase luminance speed
  59710. */
  59711. hdrIncreaseRate: number;
  59712. /**
  59713. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59714. */
  59715. /**
  59716. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59717. */
  59718. hdrAutoExposure: boolean;
  59719. /**
  59720. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59721. */
  59722. lensColorTexture: Nullable<Texture>;
  59723. /**
  59724. * The overall strengh for the lens flare effect
  59725. */
  59726. lensFlareStrength: number;
  59727. /**
  59728. * Dispersion coefficient for lens flare ghosts
  59729. */
  59730. lensFlareGhostDispersal: number;
  59731. /**
  59732. * Main lens flare halo width
  59733. */
  59734. lensFlareHaloWidth: number;
  59735. /**
  59736. * Based on the lens distortion effect, defines how much the lens flare result
  59737. * is distorted
  59738. */
  59739. lensFlareDistortionStrength: number;
  59740. /**
  59741. * Configures the blur intensity used for for lens flare (halo)
  59742. */
  59743. lensFlareBlurWidth: number;
  59744. /**
  59745. * Lens star texture must be used to simulate rays on the flares and is available
  59746. * in the documentation
  59747. */
  59748. lensStarTexture: Nullable<Texture>;
  59749. /**
  59750. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59751. * flare effect by taking account of the dirt texture
  59752. */
  59753. lensFlareDirtTexture: Nullable<Texture>;
  59754. /**
  59755. * Represents the focal length for the depth of field effect
  59756. */
  59757. depthOfFieldDistance: number;
  59758. /**
  59759. * Represents the blur intensity for the blurred part of the depth of field effect
  59760. */
  59761. depthOfFieldBlurWidth: number;
  59762. /**
  59763. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59764. */
  59765. /**
  59766. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59767. */
  59768. motionStrength: number;
  59769. /**
  59770. * Gets wether or not the motion blur post-process is object based or screen based.
  59771. */
  59772. /**
  59773. * Sets wether or not the motion blur post-process should be object based or screen based
  59774. */
  59775. objectBasedMotionBlur: boolean;
  59776. /**
  59777. * List of animations for the pipeline (IAnimatable implementation)
  59778. */
  59779. animations: Animation[];
  59780. /**
  59781. * Private members
  59782. */
  59783. private _scene;
  59784. private _currentDepthOfFieldSource;
  59785. private _basePostProcess;
  59786. private _fixedExposure;
  59787. private _currentExposure;
  59788. private _hdrAutoExposure;
  59789. private _hdrCurrentLuminance;
  59790. private _motionStrength;
  59791. private _isObjectBasedMotionBlur;
  59792. private _floatTextureType;
  59793. private _camerasToBeAttached;
  59794. private _ratio;
  59795. private _bloomEnabled;
  59796. private _depthOfFieldEnabled;
  59797. private _vlsEnabled;
  59798. private _lensFlareEnabled;
  59799. private _hdrEnabled;
  59800. private _motionBlurEnabled;
  59801. private _fxaaEnabled;
  59802. private _motionBlurSamples;
  59803. private _volumetricLightStepsCount;
  59804. private _samples;
  59805. /**
  59806. * @ignore
  59807. * Specifies if the bloom pipeline is enabled
  59808. */
  59809. BloomEnabled: boolean;
  59810. /**
  59811. * @ignore
  59812. * Specifies if the depth of field pipeline is enabed
  59813. */
  59814. DepthOfFieldEnabled: boolean;
  59815. /**
  59816. * @ignore
  59817. * Specifies if the lens flare pipeline is enabed
  59818. */
  59819. LensFlareEnabled: boolean;
  59820. /**
  59821. * @ignore
  59822. * Specifies if the HDR pipeline is enabled
  59823. */
  59824. HDREnabled: boolean;
  59825. /**
  59826. * @ignore
  59827. * Specifies if the volumetric lights scattering effect is enabled
  59828. */
  59829. VLSEnabled: boolean;
  59830. /**
  59831. * @ignore
  59832. * Specifies if the motion blur effect is enabled
  59833. */
  59834. MotionBlurEnabled: boolean;
  59835. /**
  59836. * Specifies if anti-aliasing is enabled
  59837. */
  59838. fxaaEnabled: boolean;
  59839. /**
  59840. * Specifies the number of steps used to calculate the volumetric lights
  59841. * Typically in interval [50, 200]
  59842. */
  59843. volumetricLightStepsCount: number;
  59844. /**
  59845. * Specifies the number of samples used for the motion blur effect
  59846. * Typically in interval [16, 64]
  59847. */
  59848. motionBlurSamples: number;
  59849. /**
  59850. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59851. */
  59852. samples: number;
  59853. /**
  59854. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59855. * @constructor
  59856. * @param name The rendering pipeline name
  59857. * @param scene The scene linked to this pipeline
  59858. * @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)
  59859. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59860. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59861. */
  59862. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59863. private _buildPipeline;
  59864. private _createDownSampleX4PostProcess;
  59865. private _createBrightPassPostProcess;
  59866. private _createBlurPostProcesses;
  59867. private _createTextureAdderPostProcess;
  59868. private _createVolumetricLightPostProcess;
  59869. private _createLuminancePostProcesses;
  59870. private _createHdrPostProcess;
  59871. private _createLensFlarePostProcess;
  59872. private _createDepthOfFieldPostProcess;
  59873. private _createMotionBlurPostProcess;
  59874. private _getDepthTexture;
  59875. private _disposePostProcesses;
  59876. /**
  59877. * Dispose of the pipeline and stop all post processes
  59878. */
  59879. dispose(): void;
  59880. /**
  59881. * Serialize the rendering pipeline (Used when exporting)
  59882. * @returns the serialized object
  59883. */
  59884. serialize(): any;
  59885. /**
  59886. * Parse the serialized pipeline
  59887. * @param source Source pipeline.
  59888. * @param scene The scene to load the pipeline to.
  59889. * @param rootUrl The URL of the serialized pipeline.
  59890. * @returns An instantiated pipeline from the serialized object.
  59891. */
  59892. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59893. /**
  59894. * Luminance steps
  59895. */
  59896. static LuminanceSteps: number;
  59897. }
  59898. }
  59899. declare module BABYLON {
  59900. /** @hidden */
  59901. export var tonemapPixelShader: {
  59902. name: string;
  59903. shader: string;
  59904. };
  59905. }
  59906. declare module BABYLON {
  59907. /** Defines operator used for tonemapping */
  59908. export enum TonemappingOperator {
  59909. /** Hable */
  59910. Hable = 0,
  59911. /** Reinhard */
  59912. Reinhard = 1,
  59913. /** HejiDawson */
  59914. HejiDawson = 2,
  59915. /** Photographic */
  59916. Photographic = 3
  59917. }
  59918. /**
  59919. * Defines a post process to apply tone mapping
  59920. */
  59921. export class TonemapPostProcess extends PostProcess {
  59922. private _operator;
  59923. /** Defines the required exposure adjustement */
  59924. exposureAdjustment: number;
  59925. /**
  59926. * Creates a new TonemapPostProcess
  59927. * @param name defines the name of the postprocess
  59928. * @param _operator defines the operator to use
  59929. * @param exposureAdjustment defines the required exposure adjustement
  59930. * @param camera defines the camera to use (can be null)
  59931. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59932. * @param engine defines the hosting engine (can be ignore if camera is set)
  59933. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59934. */
  59935. constructor(name: string, _operator: TonemappingOperator,
  59936. /** Defines the required exposure adjustement */
  59937. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /** @hidden */
  59942. export var depthVertexShader: {
  59943. name: string;
  59944. shader: string;
  59945. };
  59946. }
  59947. declare module BABYLON {
  59948. /** @hidden */
  59949. export var volumetricLightScatteringPixelShader: {
  59950. name: string;
  59951. shader: string;
  59952. };
  59953. }
  59954. declare module BABYLON {
  59955. /** @hidden */
  59956. export var volumetricLightScatteringPassVertexShader: {
  59957. name: string;
  59958. shader: string;
  59959. };
  59960. }
  59961. declare module BABYLON {
  59962. /** @hidden */
  59963. export var volumetricLightScatteringPassPixelShader: {
  59964. name: string;
  59965. shader: string;
  59966. };
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59971. */
  59972. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59973. private _volumetricLightScatteringPass;
  59974. private _volumetricLightScatteringRTT;
  59975. private _viewPort;
  59976. private _screenCoordinates;
  59977. private _cachedDefines;
  59978. /**
  59979. * If not undefined, the mesh position is computed from the attached node position
  59980. */
  59981. attachedNode: {
  59982. position: Vector3;
  59983. };
  59984. /**
  59985. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59986. */
  59987. customMeshPosition: Vector3;
  59988. /**
  59989. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59990. */
  59991. useCustomMeshPosition: boolean;
  59992. /**
  59993. * If the post-process should inverse the light scattering direction
  59994. */
  59995. invert: boolean;
  59996. /**
  59997. * The internal mesh used by the post-process
  59998. */
  59999. mesh: Mesh;
  60000. /**
  60001. * @hidden
  60002. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60003. */
  60004. useDiffuseColor: boolean;
  60005. /**
  60006. * Array containing the excluded meshes not rendered in the internal pass
  60007. */
  60008. excludedMeshes: AbstractMesh[];
  60009. /**
  60010. * Controls the overall intensity of the post-process
  60011. */
  60012. exposure: number;
  60013. /**
  60014. * Dissipates each sample's contribution in range [0, 1]
  60015. */
  60016. decay: number;
  60017. /**
  60018. * Controls the overall intensity of each sample
  60019. */
  60020. weight: number;
  60021. /**
  60022. * Controls the density of each sample
  60023. */
  60024. density: number;
  60025. /**
  60026. * @constructor
  60027. * @param name The post-process name
  60028. * @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)
  60029. * @param camera The camera that the post-process will be attached to
  60030. * @param mesh The mesh used to create the light scattering
  60031. * @param samples The post-process quality, default 100
  60032. * @param samplingModeThe post-process filtering mode
  60033. * @param engine The babylon engine
  60034. * @param reusable If the post-process is reusable
  60035. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60036. */
  60037. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60038. /**
  60039. * Returns the string "VolumetricLightScatteringPostProcess"
  60040. * @returns "VolumetricLightScatteringPostProcess"
  60041. */
  60042. getClassName(): string;
  60043. private _isReady;
  60044. /**
  60045. * Sets the new light position for light scattering effect
  60046. * @param position The new custom light position
  60047. */
  60048. setCustomMeshPosition(position: Vector3): void;
  60049. /**
  60050. * Returns the light position for light scattering effect
  60051. * @return Vector3 The custom light position
  60052. */
  60053. getCustomMeshPosition(): Vector3;
  60054. /**
  60055. * Disposes the internal assets and detaches the post-process from the camera
  60056. */
  60057. dispose(camera: Camera): void;
  60058. /**
  60059. * Returns the render target texture used by the post-process
  60060. * @return the render target texture used by the post-process
  60061. */
  60062. getPass(): RenderTargetTexture;
  60063. private _meshExcluded;
  60064. private _createPass;
  60065. private _updateMeshScreenCoordinates;
  60066. /**
  60067. * Creates a default mesh for the Volumeric Light Scattering post-process
  60068. * @param name The mesh name
  60069. * @param scene The scene where to create the mesh
  60070. * @return the default mesh
  60071. */
  60072. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60073. }
  60074. }
  60075. declare module BABYLON {
  60076. interface Scene {
  60077. /** @hidden (Backing field) */
  60078. _boundingBoxRenderer: BoundingBoxRenderer;
  60079. /** @hidden (Backing field) */
  60080. _forceShowBoundingBoxes: boolean;
  60081. /**
  60082. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60083. */
  60084. forceShowBoundingBoxes: boolean;
  60085. /**
  60086. * Gets the bounding box renderer associated with the scene
  60087. * @returns a BoundingBoxRenderer
  60088. */
  60089. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60090. }
  60091. interface AbstractMesh {
  60092. /** @hidden (Backing field) */
  60093. _showBoundingBox: boolean;
  60094. /**
  60095. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60096. */
  60097. showBoundingBox: boolean;
  60098. }
  60099. /**
  60100. * Component responsible of rendering the bounding box of the meshes in a scene.
  60101. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60102. */
  60103. export class BoundingBoxRenderer implements ISceneComponent {
  60104. /**
  60105. * The component name helpfull to identify the component in the list of scene components.
  60106. */
  60107. readonly name: string;
  60108. /**
  60109. * The scene the component belongs to.
  60110. */
  60111. scene: Scene;
  60112. /**
  60113. * Color of the bounding box lines placed in front of an object
  60114. */
  60115. frontColor: Color3;
  60116. /**
  60117. * Color of the bounding box lines placed behind an object
  60118. */
  60119. backColor: Color3;
  60120. /**
  60121. * Defines if the renderer should show the back lines or not
  60122. */
  60123. showBackLines: boolean;
  60124. /**
  60125. * @hidden
  60126. */
  60127. renderList: SmartArray<BoundingBox>;
  60128. private _colorShader;
  60129. private _vertexBuffers;
  60130. private _indexBuffer;
  60131. private _fillIndexBuffer;
  60132. private _fillIndexData;
  60133. /**
  60134. * Instantiates a new bounding box renderer in a scene.
  60135. * @param scene the scene the renderer renders in
  60136. */
  60137. constructor(scene: Scene);
  60138. /**
  60139. * Registers the component in a given scene
  60140. */
  60141. register(): void;
  60142. private _evaluateSubMesh;
  60143. private _activeMesh;
  60144. private _prepareRessources;
  60145. private _createIndexBuffer;
  60146. /**
  60147. * Rebuilds the elements related to this component in case of
  60148. * context lost for instance.
  60149. */
  60150. rebuild(): void;
  60151. /**
  60152. * @hidden
  60153. */
  60154. reset(): void;
  60155. /**
  60156. * Render the bounding boxes of a specific rendering group
  60157. * @param renderingGroupId defines the rendering group to render
  60158. */
  60159. render(renderingGroupId: number): void;
  60160. /**
  60161. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60162. * @param mesh Define the mesh to render the occlusion bounding box for
  60163. */
  60164. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60165. /**
  60166. * Dispose and release the resources attached to this renderer.
  60167. */
  60168. dispose(): void;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /** @hidden */
  60173. export var depthPixelShader: {
  60174. name: string;
  60175. shader: string;
  60176. };
  60177. }
  60178. declare module BABYLON {
  60179. /**
  60180. * This represents a depth renderer in Babylon.
  60181. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60182. */
  60183. export class DepthRenderer {
  60184. private _scene;
  60185. private _depthMap;
  60186. private _effect;
  60187. private readonly _storeNonLinearDepth;
  60188. private readonly _clearColor;
  60189. /** Get if the depth renderer is using packed depth or not */
  60190. readonly isPacked: boolean;
  60191. private _cachedDefines;
  60192. private _camera;
  60193. /**
  60194. * Specifiess that the depth renderer will only be used within
  60195. * the camera it is created for.
  60196. * This can help forcing its rendering during the camera processing.
  60197. */
  60198. useOnlyInActiveCamera: boolean;
  60199. /** @hidden */
  60200. static _SceneComponentInitialization: (scene: Scene) => void;
  60201. /**
  60202. * Instantiates a depth renderer
  60203. * @param scene The scene the renderer belongs to
  60204. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60205. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60206. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60207. */
  60208. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60209. /**
  60210. * Creates the depth rendering effect and checks if the effect is ready.
  60211. * @param subMesh The submesh to be used to render the depth map of
  60212. * @param useInstances If multiple world instances should be used
  60213. * @returns if the depth renderer is ready to render the depth map
  60214. */
  60215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60216. /**
  60217. * Gets the texture which the depth map will be written to.
  60218. * @returns The depth map texture
  60219. */
  60220. getDepthMap(): RenderTargetTexture;
  60221. /**
  60222. * Disposes of the depth renderer.
  60223. */
  60224. dispose(): void;
  60225. }
  60226. }
  60227. declare module BABYLON {
  60228. interface Scene {
  60229. /** @hidden (Backing field) */
  60230. _depthRenderer: {
  60231. [id: string]: DepthRenderer;
  60232. };
  60233. /**
  60234. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60235. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60236. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60237. * @returns the created depth renderer
  60238. */
  60239. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60240. /**
  60241. * Disables a depth renderer for a given camera
  60242. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60243. */
  60244. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60245. }
  60246. /**
  60247. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60248. * in several rendering techniques.
  60249. */
  60250. export class DepthRendererSceneComponent implements ISceneComponent {
  60251. /**
  60252. * The component name helpfull to identify the component in the list of scene components.
  60253. */
  60254. readonly name: string;
  60255. /**
  60256. * The scene the component belongs to.
  60257. */
  60258. scene: Scene;
  60259. /**
  60260. * Creates a new instance of the component for the given scene
  60261. * @param scene Defines the scene to register the component in
  60262. */
  60263. constructor(scene: Scene);
  60264. /**
  60265. * Registers the component in a given scene
  60266. */
  60267. register(): void;
  60268. /**
  60269. * Rebuilds the elements related to this component in case of
  60270. * context lost for instance.
  60271. */
  60272. rebuild(): void;
  60273. /**
  60274. * Disposes the component and the associated ressources
  60275. */
  60276. dispose(): void;
  60277. private _gatherRenderTargets;
  60278. private _gatherActiveCameraRenderTargets;
  60279. }
  60280. }
  60281. declare module BABYLON {
  60282. /** @hidden */
  60283. export var outlinePixelShader: {
  60284. name: string;
  60285. shader: string;
  60286. };
  60287. }
  60288. declare module BABYLON {
  60289. /** @hidden */
  60290. export var outlineVertexShader: {
  60291. name: string;
  60292. shader: string;
  60293. };
  60294. }
  60295. declare module BABYLON {
  60296. interface Scene {
  60297. /** @hidden */
  60298. _outlineRenderer: OutlineRenderer;
  60299. /**
  60300. * Gets the outline renderer associated with the scene
  60301. * @returns a OutlineRenderer
  60302. */
  60303. getOutlineRenderer(): OutlineRenderer;
  60304. }
  60305. interface AbstractMesh {
  60306. /** @hidden (Backing field) */
  60307. _renderOutline: boolean;
  60308. /**
  60309. * Gets or sets a boolean indicating if the outline must be rendered as well
  60310. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60311. */
  60312. renderOutline: boolean;
  60313. /** @hidden (Backing field) */
  60314. _renderOverlay: boolean;
  60315. /**
  60316. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60317. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60318. */
  60319. renderOverlay: boolean;
  60320. }
  60321. /**
  60322. * This class is responsible to draw bothe outline/overlay of meshes.
  60323. * It should not be used directly but through the available method on mesh.
  60324. */
  60325. export class OutlineRenderer implements ISceneComponent {
  60326. /**
  60327. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60328. */
  60329. private static _StencilReference;
  60330. /**
  60331. * The name of the component. Each component must have a unique name.
  60332. */
  60333. name: string;
  60334. /**
  60335. * The scene the component belongs to.
  60336. */
  60337. scene: Scene;
  60338. /**
  60339. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60340. */
  60341. zOffset: number;
  60342. private _engine;
  60343. private _effect;
  60344. private _cachedDefines;
  60345. private _savedDepthWrite;
  60346. /**
  60347. * Instantiates a new outline renderer. (There could be only one per scene).
  60348. * @param scene Defines the scene it belongs to
  60349. */
  60350. constructor(scene: Scene);
  60351. /**
  60352. * Register the component to one instance of a scene.
  60353. */
  60354. register(): void;
  60355. /**
  60356. * Rebuilds the elements related to this component in case of
  60357. * context lost for instance.
  60358. */
  60359. rebuild(): void;
  60360. /**
  60361. * Disposes the component and the associated ressources.
  60362. */
  60363. dispose(): void;
  60364. /**
  60365. * Renders the outline in the canvas.
  60366. * @param subMesh Defines the sumesh to render
  60367. * @param batch Defines the batch of meshes in case of instances
  60368. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60369. */
  60370. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60371. /**
  60372. * Returns whether or not the outline renderer is ready for a given submesh.
  60373. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60374. * @param subMesh Defines the submesh to check readyness for
  60375. * @param useInstances Defines wheter wee are trying to render instances or not
  60376. * @returns true if ready otherwise false
  60377. */
  60378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60379. private _beforeRenderingMesh;
  60380. private _afterRenderingMesh;
  60381. }
  60382. }
  60383. declare module BABYLON {
  60384. /**
  60385. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60386. * @see http://doc.babylonjs.com/babylon101/sprites
  60387. */
  60388. export class SpritePackedManager extends SpriteManager {
  60389. /** defines the packed manager's name */
  60390. name: string;
  60391. /**
  60392. * Creates a new sprite manager from a packed sprite sheet
  60393. * @param name defines the manager's name
  60394. * @param imgUrl defines the sprite sheet url
  60395. * @param capacity defines the maximum allowed number of sprites
  60396. * @param scene defines the hosting scene
  60397. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60398. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60399. * @param samplingMode defines the smapling mode to use with spritesheet
  60400. * @param fromPacked set to true; do not alter
  60401. */
  60402. constructor(
  60403. /** defines the packed manager's name */
  60404. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60405. }
  60406. }
  60407. declare module BABYLON {
  60408. /**
  60409. * Defines the list of states available for a task inside a AssetsManager
  60410. */
  60411. export enum AssetTaskState {
  60412. /**
  60413. * Initialization
  60414. */
  60415. INIT = 0,
  60416. /**
  60417. * Running
  60418. */
  60419. RUNNING = 1,
  60420. /**
  60421. * Done
  60422. */
  60423. DONE = 2,
  60424. /**
  60425. * Error
  60426. */
  60427. ERROR = 3
  60428. }
  60429. /**
  60430. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60431. */
  60432. export abstract class AbstractAssetTask {
  60433. /**
  60434. * Task name
  60435. */ name: string;
  60436. /**
  60437. * Callback called when the task is successful
  60438. */
  60439. onSuccess: (task: any) => void;
  60440. /**
  60441. * Callback called when the task is not successful
  60442. */
  60443. onError: (task: any, message?: string, exception?: any) => void;
  60444. /**
  60445. * Creates a new AssetsManager
  60446. * @param name defines the name of the task
  60447. */
  60448. constructor(
  60449. /**
  60450. * Task name
  60451. */ name: string);
  60452. private _isCompleted;
  60453. private _taskState;
  60454. private _errorObject;
  60455. /**
  60456. * Get if the task is completed
  60457. */
  60458. readonly isCompleted: boolean;
  60459. /**
  60460. * Gets the current state of the task
  60461. */
  60462. readonly taskState: AssetTaskState;
  60463. /**
  60464. * Gets the current error object (if task is in error)
  60465. */
  60466. readonly errorObject: {
  60467. message?: string;
  60468. exception?: any;
  60469. };
  60470. /**
  60471. * Internal only
  60472. * @hidden
  60473. */
  60474. _setErrorObject(message?: string, exception?: any): void;
  60475. /**
  60476. * Execute the current task
  60477. * @param scene defines the scene where you want your assets to be loaded
  60478. * @param onSuccess is a callback called when the task is successfully executed
  60479. * @param onError is a callback called if an error occurs
  60480. */
  60481. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60482. /**
  60483. * Execute the current task
  60484. * @param scene defines the scene where you want your assets to be loaded
  60485. * @param onSuccess is a callback called when the task is successfully executed
  60486. * @param onError is a callback called if an error occurs
  60487. */
  60488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60489. /**
  60490. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60491. * This can be used with failed tasks that have the reason for failure fixed.
  60492. */
  60493. reset(): void;
  60494. private onErrorCallback;
  60495. private onDoneCallback;
  60496. }
  60497. /**
  60498. * Define the interface used by progress events raised during assets loading
  60499. */
  60500. export interface IAssetsProgressEvent {
  60501. /**
  60502. * Defines the number of remaining tasks to process
  60503. */
  60504. remainingCount: number;
  60505. /**
  60506. * Defines the total number of tasks
  60507. */
  60508. totalCount: number;
  60509. /**
  60510. * Defines the task that was just processed
  60511. */
  60512. task: AbstractAssetTask;
  60513. }
  60514. /**
  60515. * Class used to share progress information about assets loading
  60516. */
  60517. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60518. /**
  60519. * Defines the number of remaining tasks to process
  60520. */
  60521. remainingCount: number;
  60522. /**
  60523. * Defines the total number of tasks
  60524. */
  60525. totalCount: number;
  60526. /**
  60527. * Defines the task that was just processed
  60528. */
  60529. task: AbstractAssetTask;
  60530. /**
  60531. * Creates a AssetsProgressEvent
  60532. * @param remainingCount defines the number of remaining tasks to process
  60533. * @param totalCount defines the total number of tasks
  60534. * @param task defines the task that was just processed
  60535. */
  60536. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60537. }
  60538. /**
  60539. * Define a task used by AssetsManager to load meshes
  60540. */
  60541. export class MeshAssetTask extends AbstractAssetTask {
  60542. /**
  60543. * Defines the name of the task
  60544. */
  60545. name: string;
  60546. /**
  60547. * Defines the list of mesh's names you want to load
  60548. */
  60549. meshesNames: any;
  60550. /**
  60551. * Defines the root url to use as a base to load your meshes and associated resources
  60552. */
  60553. rootUrl: string;
  60554. /**
  60555. * Defines the filename of the scene to load from
  60556. */
  60557. sceneFilename: string;
  60558. /**
  60559. * Gets the list of loaded meshes
  60560. */
  60561. loadedMeshes: Array<AbstractMesh>;
  60562. /**
  60563. * Gets the list of loaded particle systems
  60564. */
  60565. loadedParticleSystems: Array<IParticleSystem>;
  60566. /**
  60567. * Gets the list of loaded skeletons
  60568. */
  60569. loadedSkeletons: Array<Skeleton>;
  60570. /**
  60571. * Gets the list of loaded animation groups
  60572. */
  60573. loadedAnimationGroups: Array<AnimationGroup>;
  60574. /**
  60575. * Callback called when the task is successful
  60576. */
  60577. onSuccess: (task: MeshAssetTask) => void;
  60578. /**
  60579. * Callback called when the task is successful
  60580. */
  60581. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60582. /**
  60583. * Creates a new MeshAssetTask
  60584. * @param name defines the name of the task
  60585. * @param meshesNames defines the list of mesh's names you want to load
  60586. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60587. * @param sceneFilename defines the filename of the scene to load from
  60588. */
  60589. constructor(
  60590. /**
  60591. * Defines the name of the task
  60592. */
  60593. name: string,
  60594. /**
  60595. * Defines the list of mesh's names you want to load
  60596. */
  60597. meshesNames: any,
  60598. /**
  60599. * Defines the root url to use as a base to load your meshes and associated resources
  60600. */
  60601. rootUrl: string,
  60602. /**
  60603. * Defines the filename of the scene to load from
  60604. */
  60605. sceneFilename: string);
  60606. /**
  60607. * Execute the current task
  60608. * @param scene defines the scene where you want your assets to be loaded
  60609. * @param onSuccess is a callback called when the task is successfully executed
  60610. * @param onError is a callback called if an error occurs
  60611. */
  60612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60613. }
  60614. /**
  60615. * Define a task used by AssetsManager to load text content
  60616. */
  60617. export class TextFileAssetTask extends AbstractAssetTask {
  60618. /**
  60619. * Defines the name of the task
  60620. */
  60621. name: string;
  60622. /**
  60623. * Defines the location of the file to load
  60624. */
  60625. url: string;
  60626. /**
  60627. * Gets the loaded text string
  60628. */
  60629. text: string;
  60630. /**
  60631. * Callback called when the task is successful
  60632. */
  60633. onSuccess: (task: TextFileAssetTask) => void;
  60634. /**
  60635. * Callback called when the task is successful
  60636. */
  60637. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60638. /**
  60639. * Creates a new TextFileAssetTask object
  60640. * @param name defines the name of the task
  60641. * @param url defines the location of the file to load
  60642. */
  60643. constructor(
  60644. /**
  60645. * Defines the name of the task
  60646. */
  60647. name: string,
  60648. /**
  60649. * Defines the location of the file to load
  60650. */
  60651. url: string);
  60652. /**
  60653. * Execute the current task
  60654. * @param scene defines the scene where you want your assets to be loaded
  60655. * @param onSuccess is a callback called when the task is successfully executed
  60656. * @param onError is a callback called if an error occurs
  60657. */
  60658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60659. }
  60660. /**
  60661. * Define a task used by AssetsManager to load binary data
  60662. */
  60663. export class BinaryFileAssetTask extends AbstractAssetTask {
  60664. /**
  60665. * Defines the name of the task
  60666. */
  60667. name: string;
  60668. /**
  60669. * Defines the location of the file to load
  60670. */
  60671. url: string;
  60672. /**
  60673. * Gets the lodaded data (as an array buffer)
  60674. */
  60675. data: ArrayBuffer;
  60676. /**
  60677. * Callback called when the task is successful
  60678. */
  60679. onSuccess: (task: BinaryFileAssetTask) => void;
  60680. /**
  60681. * Callback called when the task is successful
  60682. */
  60683. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60684. /**
  60685. * Creates a new BinaryFileAssetTask object
  60686. * @param name defines the name of the new task
  60687. * @param url defines the location of the file to load
  60688. */
  60689. constructor(
  60690. /**
  60691. * Defines the name of the task
  60692. */
  60693. name: string,
  60694. /**
  60695. * Defines the location of the file to load
  60696. */
  60697. url: string);
  60698. /**
  60699. * Execute the current task
  60700. * @param scene defines the scene where you want your assets to be loaded
  60701. * @param onSuccess is a callback called when the task is successfully executed
  60702. * @param onError is a callback called if an error occurs
  60703. */
  60704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60705. }
  60706. /**
  60707. * Define a task used by AssetsManager to load images
  60708. */
  60709. export class ImageAssetTask extends AbstractAssetTask {
  60710. /**
  60711. * Defines the name of the task
  60712. */
  60713. name: string;
  60714. /**
  60715. * Defines the location of the image to load
  60716. */
  60717. url: string;
  60718. /**
  60719. * Gets the loaded images
  60720. */
  60721. image: HTMLImageElement;
  60722. /**
  60723. * Callback called when the task is successful
  60724. */
  60725. onSuccess: (task: ImageAssetTask) => void;
  60726. /**
  60727. * Callback called when the task is successful
  60728. */
  60729. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60730. /**
  60731. * Creates a new ImageAssetTask
  60732. * @param name defines the name of the task
  60733. * @param url defines the location of the image to load
  60734. */
  60735. constructor(
  60736. /**
  60737. * Defines the name of the task
  60738. */
  60739. name: string,
  60740. /**
  60741. * Defines the location of the image to load
  60742. */
  60743. url: string);
  60744. /**
  60745. * Execute the current task
  60746. * @param scene defines the scene where you want your assets to be loaded
  60747. * @param onSuccess is a callback called when the task is successfully executed
  60748. * @param onError is a callback called if an error occurs
  60749. */
  60750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60751. }
  60752. /**
  60753. * Defines the interface used by texture loading tasks
  60754. */
  60755. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60756. /**
  60757. * Gets the loaded texture
  60758. */
  60759. texture: TEX;
  60760. }
  60761. /**
  60762. * Define a task used by AssetsManager to load 2D textures
  60763. */
  60764. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60765. /**
  60766. * Defines the name of the task
  60767. */
  60768. name: string;
  60769. /**
  60770. * Defines the location of the file to load
  60771. */
  60772. url: string;
  60773. /**
  60774. * Defines if mipmap should not be generated (default is false)
  60775. */
  60776. noMipmap?: boolean | undefined;
  60777. /**
  60778. * Defines if texture must be inverted on Y axis (default is false)
  60779. */
  60780. invertY?: boolean | undefined;
  60781. /**
  60782. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60783. */
  60784. samplingMode: number;
  60785. /**
  60786. * Gets the loaded texture
  60787. */
  60788. texture: Texture;
  60789. /**
  60790. * Callback called when the task is successful
  60791. */
  60792. onSuccess: (task: TextureAssetTask) => void;
  60793. /**
  60794. * Callback called when the task is successful
  60795. */
  60796. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60797. /**
  60798. * Creates a new TextureAssetTask object
  60799. * @param name defines the name of the task
  60800. * @param url defines the location of the file to load
  60801. * @param noMipmap defines if mipmap should not be generated (default is false)
  60802. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60803. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60804. */
  60805. constructor(
  60806. /**
  60807. * Defines the name of the task
  60808. */
  60809. name: string,
  60810. /**
  60811. * Defines the location of the file to load
  60812. */
  60813. url: string,
  60814. /**
  60815. * Defines if mipmap should not be generated (default is false)
  60816. */
  60817. noMipmap?: boolean | undefined,
  60818. /**
  60819. * Defines if texture must be inverted on Y axis (default is false)
  60820. */
  60821. invertY?: boolean | undefined,
  60822. /**
  60823. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60824. */
  60825. samplingMode?: number);
  60826. /**
  60827. * Execute the current task
  60828. * @param scene defines the scene where you want your assets to be loaded
  60829. * @param onSuccess is a callback called when the task is successfully executed
  60830. * @param onError is a callback called if an error occurs
  60831. */
  60832. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60833. }
  60834. /**
  60835. * Define a task used by AssetsManager to load cube textures
  60836. */
  60837. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60838. /**
  60839. * Defines the name of the task
  60840. */
  60841. name: string;
  60842. /**
  60843. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60844. */
  60845. url: string;
  60846. /**
  60847. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60848. */
  60849. extensions?: string[] | undefined;
  60850. /**
  60851. * Defines if mipmaps should not be generated (default is false)
  60852. */
  60853. noMipmap?: boolean | undefined;
  60854. /**
  60855. * Defines the explicit list of files (undefined by default)
  60856. */
  60857. files?: string[] | undefined;
  60858. /**
  60859. * Gets the loaded texture
  60860. */
  60861. texture: CubeTexture;
  60862. /**
  60863. * Callback called when the task is successful
  60864. */
  60865. onSuccess: (task: CubeTextureAssetTask) => void;
  60866. /**
  60867. * Callback called when the task is successful
  60868. */
  60869. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60870. /**
  60871. * Creates a new CubeTextureAssetTask
  60872. * @param name defines the name of the task
  60873. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60874. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60875. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60876. * @param files defines the explicit list of files (undefined by default)
  60877. */
  60878. constructor(
  60879. /**
  60880. * Defines the name of the task
  60881. */
  60882. name: string,
  60883. /**
  60884. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60885. */
  60886. url: string,
  60887. /**
  60888. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60889. */
  60890. extensions?: string[] | undefined,
  60891. /**
  60892. * Defines if mipmaps should not be generated (default is false)
  60893. */
  60894. noMipmap?: boolean | undefined,
  60895. /**
  60896. * Defines the explicit list of files (undefined by default)
  60897. */
  60898. files?: string[] | undefined);
  60899. /**
  60900. * Execute the current task
  60901. * @param scene defines the scene where you want your assets to be loaded
  60902. * @param onSuccess is a callback called when the task is successfully executed
  60903. * @param onError is a callback called if an error occurs
  60904. */
  60905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60906. }
  60907. /**
  60908. * Define a task used by AssetsManager to load HDR cube textures
  60909. */
  60910. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60911. /**
  60912. * Defines the name of the task
  60913. */
  60914. name: string;
  60915. /**
  60916. * Defines the location of the file to load
  60917. */
  60918. url: string;
  60919. /**
  60920. * Defines the desired size (the more it increases the longer the generation will be)
  60921. */
  60922. size: number;
  60923. /**
  60924. * Defines if mipmaps should not be generated (default is false)
  60925. */
  60926. noMipmap: boolean;
  60927. /**
  60928. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60929. */
  60930. generateHarmonics: boolean;
  60931. /**
  60932. * 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)
  60933. */
  60934. gammaSpace: boolean;
  60935. /**
  60936. * Internal Use Only
  60937. */
  60938. reserved: boolean;
  60939. /**
  60940. * Gets the loaded texture
  60941. */
  60942. texture: HDRCubeTexture;
  60943. /**
  60944. * Callback called when the task is successful
  60945. */
  60946. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60947. /**
  60948. * Callback called when the task is successful
  60949. */
  60950. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60951. /**
  60952. * Creates a new HDRCubeTextureAssetTask object
  60953. * @param name defines the name of the task
  60954. * @param url defines the location of the file to load
  60955. * @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.
  60956. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60957. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60958. * @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)
  60959. * @param reserved Internal use only
  60960. */
  60961. constructor(
  60962. /**
  60963. * Defines the name of the task
  60964. */
  60965. name: string,
  60966. /**
  60967. * Defines the location of the file to load
  60968. */
  60969. url: string,
  60970. /**
  60971. * Defines the desired size (the more it increases the longer the generation will be)
  60972. */
  60973. size: number,
  60974. /**
  60975. * Defines if mipmaps should not be generated (default is false)
  60976. */
  60977. noMipmap?: boolean,
  60978. /**
  60979. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60980. */
  60981. generateHarmonics?: boolean,
  60982. /**
  60983. * 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)
  60984. */
  60985. gammaSpace?: boolean,
  60986. /**
  60987. * Internal Use Only
  60988. */
  60989. reserved?: boolean);
  60990. /**
  60991. * Execute the current task
  60992. * @param scene defines the scene where you want your assets to be loaded
  60993. * @param onSuccess is a callback called when the task is successfully executed
  60994. * @param onError is a callback called if an error occurs
  60995. */
  60996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60997. }
  60998. /**
  60999. * Define a task used by AssetsManager to load Equirectangular cube textures
  61000. */
  61001. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61002. /**
  61003. * Defines the name of the task
  61004. */
  61005. name: string;
  61006. /**
  61007. * Defines the location of the file to load
  61008. */
  61009. url: string;
  61010. /**
  61011. * Defines the desired size (the more it increases the longer the generation will be)
  61012. */
  61013. size: number;
  61014. /**
  61015. * Defines if mipmaps should not be generated (default is false)
  61016. */
  61017. noMipmap: boolean;
  61018. /**
  61019. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61020. * but the standard material would require them in Gamma space) (default is true)
  61021. */
  61022. gammaSpace: boolean;
  61023. /**
  61024. * Gets the loaded texture
  61025. */
  61026. texture: EquiRectangularCubeTexture;
  61027. /**
  61028. * Callback called when the task is successful
  61029. */
  61030. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61031. /**
  61032. * Callback called when the task is successful
  61033. */
  61034. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61035. /**
  61036. * Creates a new EquiRectangularCubeTextureAssetTask object
  61037. * @param name defines the name of the task
  61038. * @param url defines the location of the file to load
  61039. * @param size defines the desired size (the more it increases the longer the generation will be)
  61040. * If the size is omitted this implies you are using a preprocessed cubemap.
  61041. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61042. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61043. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61044. * (default is true)
  61045. */
  61046. constructor(
  61047. /**
  61048. * Defines the name of the task
  61049. */
  61050. name: string,
  61051. /**
  61052. * Defines the location of the file to load
  61053. */
  61054. url: string,
  61055. /**
  61056. * Defines the desired size (the more it increases the longer the generation will be)
  61057. */
  61058. size: number,
  61059. /**
  61060. * Defines if mipmaps should not be generated (default is false)
  61061. */
  61062. noMipmap?: boolean,
  61063. /**
  61064. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61065. * but the standard material would require them in Gamma space) (default is true)
  61066. */
  61067. gammaSpace?: boolean);
  61068. /**
  61069. * Execute the current task
  61070. * @param scene defines the scene where you want your assets to be loaded
  61071. * @param onSuccess is a callback called when the task is successfully executed
  61072. * @param onError is a callback called if an error occurs
  61073. */
  61074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61075. }
  61076. /**
  61077. * This class can be used to easily import assets into a scene
  61078. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61079. */
  61080. export class AssetsManager {
  61081. private _scene;
  61082. private _isLoading;
  61083. protected _tasks: AbstractAssetTask[];
  61084. protected _waitingTasksCount: number;
  61085. protected _totalTasksCount: number;
  61086. /**
  61087. * Callback called when all tasks are processed
  61088. */
  61089. onFinish: (tasks: AbstractAssetTask[]) => void;
  61090. /**
  61091. * Callback called when a task is successful
  61092. */
  61093. onTaskSuccess: (task: AbstractAssetTask) => void;
  61094. /**
  61095. * Callback called when a task had an error
  61096. */
  61097. onTaskError: (task: AbstractAssetTask) => void;
  61098. /**
  61099. * Callback called when a task is done (whatever the result is)
  61100. */
  61101. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61102. /**
  61103. * Observable called when all tasks are processed
  61104. */
  61105. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61106. /**
  61107. * Observable called when a task had an error
  61108. */
  61109. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61110. /**
  61111. * Observable called when all tasks were executed
  61112. */
  61113. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61114. /**
  61115. * Observable called when a task is done (whatever the result is)
  61116. */
  61117. onProgressObservable: Observable<IAssetsProgressEvent>;
  61118. /**
  61119. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61121. */
  61122. useDefaultLoadingScreen: boolean;
  61123. /**
  61124. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61125. * when all assets have been downloaded.
  61126. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61127. */
  61128. autoHideLoadingUI: boolean;
  61129. /**
  61130. * Creates a new AssetsManager
  61131. * @param scene defines the scene to work on
  61132. */
  61133. constructor(scene: Scene);
  61134. /**
  61135. * Add a MeshAssetTask to the list of active tasks
  61136. * @param taskName defines the name of the new task
  61137. * @param meshesNames defines the name of meshes to load
  61138. * @param rootUrl defines the root url to use to locate files
  61139. * @param sceneFilename defines the filename of the scene file
  61140. * @returns a new MeshAssetTask object
  61141. */
  61142. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61143. /**
  61144. * Add a TextFileAssetTask to the list of active tasks
  61145. * @param taskName defines the name of the new task
  61146. * @param url defines the url of the file to load
  61147. * @returns a new TextFileAssetTask object
  61148. */
  61149. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61150. /**
  61151. * Add a BinaryFileAssetTask to the list of active tasks
  61152. * @param taskName defines the name of the new task
  61153. * @param url defines the url of the file to load
  61154. * @returns a new BinaryFileAssetTask object
  61155. */
  61156. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61157. /**
  61158. * Add a ImageAssetTask to the list of active tasks
  61159. * @param taskName defines the name of the new task
  61160. * @param url defines the url of the file to load
  61161. * @returns a new ImageAssetTask object
  61162. */
  61163. addImageTask(taskName: string, url: string): ImageAssetTask;
  61164. /**
  61165. * Add a TextureAssetTask to the list of active tasks
  61166. * @param taskName defines the name of the new task
  61167. * @param url defines the url of the file to load
  61168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61169. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61170. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61171. * @returns a new TextureAssetTask object
  61172. */
  61173. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61174. /**
  61175. * Add a CubeTextureAssetTask to the list of active tasks
  61176. * @param taskName defines the name of the new task
  61177. * @param url defines the url of the file to load
  61178. * @param extensions defines the extension to use to load the cube map (can be null)
  61179. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61180. * @param files defines the list of files to load (can be null)
  61181. * @returns a new CubeTextureAssetTask object
  61182. */
  61183. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61184. /**
  61185. *
  61186. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61187. * @param taskName defines the name of the new task
  61188. * @param url defines the url of the file to load
  61189. * @param size defines the size you want for the cubemap (can be null)
  61190. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61191. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61192. * @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)
  61193. * @param reserved Internal use only
  61194. * @returns a new HDRCubeTextureAssetTask object
  61195. */
  61196. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61197. /**
  61198. *
  61199. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61200. * @param taskName defines the name of the new task
  61201. * @param url defines the url of the file to load
  61202. * @param size defines the size you want for the cubemap (can be null)
  61203. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61204. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61205. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61206. * @returns a new EquiRectangularCubeTextureAssetTask object
  61207. */
  61208. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61209. /**
  61210. * Remove a task from the assets manager.
  61211. * @param task the task to remove
  61212. */
  61213. removeTask(task: AbstractAssetTask): void;
  61214. private _decreaseWaitingTasksCount;
  61215. private _runTask;
  61216. /**
  61217. * Reset the AssetsManager and remove all tasks
  61218. * @return the current instance of the AssetsManager
  61219. */
  61220. reset(): AssetsManager;
  61221. /**
  61222. * Start the loading process
  61223. * @return the current instance of the AssetsManager
  61224. */
  61225. load(): AssetsManager;
  61226. /**
  61227. * Start the loading process as an async operation
  61228. * @return a promise returning the list of failed tasks
  61229. */
  61230. loadAsync(): Promise<void>;
  61231. }
  61232. }
  61233. declare module BABYLON {
  61234. /**
  61235. * Wrapper class for promise with external resolve and reject.
  61236. */
  61237. export class Deferred<T> {
  61238. /**
  61239. * The promise associated with this deferred object.
  61240. */
  61241. readonly promise: Promise<T>;
  61242. private _resolve;
  61243. private _reject;
  61244. /**
  61245. * The resolve method of the promise associated with this deferred object.
  61246. */
  61247. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61248. /**
  61249. * The reject method of the promise associated with this deferred object.
  61250. */
  61251. readonly reject: (reason?: any) => void;
  61252. /**
  61253. * Constructor for this deferred object.
  61254. */
  61255. constructor();
  61256. }
  61257. }
  61258. declare module BABYLON {
  61259. /**
  61260. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61261. */
  61262. export class MeshExploder {
  61263. private _centerMesh;
  61264. private _meshes;
  61265. private _meshesOrigins;
  61266. private _toCenterVectors;
  61267. private _scaledDirection;
  61268. private _newPosition;
  61269. private _centerPosition;
  61270. /**
  61271. * Explodes meshes from a center mesh.
  61272. * @param meshes The meshes to explode.
  61273. * @param centerMesh The mesh to be center of explosion.
  61274. */
  61275. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61276. private _setCenterMesh;
  61277. /**
  61278. * Get class name
  61279. * @returns "MeshExploder"
  61280. */
  61281. getClassName(): string;
  61282. /**
  61283. * "Exploded meshes"
  61284. * @returns Array of meshes with the centerMesh at index 0.
  61285. */
  61286. getMeshes(): Array<Mesh>;
  61287. /**
  61288. * Explodes meshes giving a specific direction
  61289. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61290. */
  61291. explode(direction?: number): void;
  61292. }
  61293. }
  61294. declare module BABYLON {
  61295. /**
  61296. * Class used to help managing file picking and drag'n'drop
  61297. */
  61298. export class FilesInput {
  61299. /**
  61300. * List of files ready to be loaded
  61301. */
  61302. static readonly FilesToLoad: {
  61303. [key: string]: File;
  61304. };
  61305. /**
  61306. * Callback called when a file is processed
  61307. */
  61308. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61309. private _engine;
  61310. private _currentScene;
  61311. private _sceneLoadedCallback;
  61312. private _progressCallback;
  61313. private _additionalRenderLoopLogicCallback;
  61314. private _textureLoadingCallback;
  61315. private _startingProcessingFilesCallback;
  61316. private _onReloadCallback;
  61317. private _errorCallback;
  61318. private _elementToMonitor;
  61319. private _sceneFileToLoad;
  61320. private _filesToLoad;
  61321. /**
  61322. * Creates a new FilesInput
  61323. * @param engine defines the rendering engine
  61324. * @param scene defines the hosting scene
  61325. * @param sceneLoadedCallback callback called when scene is loaded
  61326. * @param progressCallback callback called to track progress
  61327. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61328. * @param textureLoadingCallback callback called when a texture is loading
  61329. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61330. * @param onReloadCallback callback called when a reload is requested
  61331. * @param errorCallback callback call if an error occurs
  61332. */
  61333. 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);
  61334. private _dragEnterHandler;
  61335. private _dragOverHandler;
  61336. private _dropHandler;
  61337. /**
  61338. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61339. * @param elementToMonitor defines the DOM element to track
  61340. */
  61341. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61342. /**
  61343. * Release all associated resources
  61344. */
  61345. dispose(): void;
  61346. private renderFunction;
  61347. private drag;
  61348. private drop;
  61349. private _traverseFolder;
  61350. private _processFiles;
  61351. /**
  61352. * Load files from a drop event
  61353. * @param event defines the drop event to use as source
  61354. */
  61355. loadFiles(event: any): void;
  61356. private _processReload;
  61357. /**
  61358. * Reload the current scene from the loaded files
  61359. */
  61360. reload(): void;
  61361. }
  61362. }
  61363. declare module BABYLON {
  61364. /**
  61365. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61367. */
  61368. export class SceneOptimization {
  61369. /**
  61370. * Defines the priority of this optimization (0 by default which means first in the list)
  61371. */
  61372. priority: number;
  61373. /**
  61374. * Gets a string describing the action executed by the current optimization
  61375. * @returns description string
  61376. */
  61377. getDescription(): string;
  61378. /**
  61379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61380. * @param scene defines the current scene where to apply this optimization
  61381. * @param optimizer defines the current optimizer
  61382. * @returns true if everything that can be done was applied
  61383. */
  61384. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61385. /**
  61386. * Creates the SceneOptimization object
  61387. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61388. * @param desc defines the description associated with the optimization
  61389. */
  61390. constructor(
  61391. /**
  61392. * Defines the priority of this optimization (0 by default which means first in the list)
  61393. */
  61394. priority?: number);
  61395. }
  61396. /**
  61397. * Defines an optimization used to reduce the size of render target textures
  61398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61399. */
  61400. export class TextureOptimization extends SceneOptimization {
  61401. /**
  61402. * Defines the priority of this optimization (0 by default which means first in the list)
  61403. */
  61404. priority: number;
  61405. /**
  61406. * 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
  61407. */
  61408. maximumSize: number;
  61409. /**
  61410. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61411. */
  61412. step: number;
  61413. /**
  61414. * Gets a string describing the action executed by the current optimization
  61415. * @returns description string
  61416. */
  61417. getDescription(): string;
  61418. /**
  61419. * Creates the TextureOptimization object
  61420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61421. * @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
  61422. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61423. */
  61424. constructor(
  61425. /**
  61426. * Defines the priority of this optimization (0 by default which means first in the list)
  61427. */
  61428. priority?: number,
  61429. /**
  61430. * 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
  61431. */
  61432. maximumSize?: number,
  61433. /**
  61434. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61435. */
  61436. step?: number);
  61437. /**
  61438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61439. * @param scene defines the current scene where to apply this optimization
  61440. * @param optimizer defines the current optimizer
  61441. * @returns true if everything that can be done was applied
  61442. */
  61443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61444. }
  61445. /**
  61446. * Defines an optimization used to increase or decrease the rendering resolution
  61447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61448. */
  61449. export class HardwareScalingOptimization extends SceneOptimization {
  61450. /**
  61451. * Defines the priority of this optimization (0 by default which means first in the list)
  61452. */
  61453. priority: number;
  61454. /**
  61455. * Defines the maximum scale to use (2 by default)
  61456. */
  61457. maximumScale: number;
  61458. /**
  61459. * Defines the step to use between two passes (0.5 by default)
  61460. */
  61461. step: number;
  61462. private _currentScale;
  61463. private _directionOffset;
  61464. /**
  61465. * Gets a string describing the action executed by the current optimization
  61466. * @return description string
  61467. */
  61468. getDescription(): string;
  61469. /**
  61470. * Creates the HardwareScalingOptimization object
  61471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61472. * @param maximumScale defines the maximum scale to use (2 by default)
  61473. * @param step defines the step to use between two passes (0.5 by default)
  61474. */
  61475. constructor(
  61476. /**
  61477. * Defines the priority of this optimization (0 by default which means first in the list)
  61478. */
  61479. priority?: number,
  61480. /**
  61481. * Defines the maximum scale to use (2 by default)
  61482. */
  61483. maximumScale?: number,
  61484. /**
  61485. * Defines the step to use between two passes (0.5 by default)
  61486. */
  61487. step?: number);
  61488. /**
  61489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61490. * @param scene defines the current scene where to apply this optimization
  61491. * @param optimizer defines the current optimizer
  61492. * @returns true if everything that can be done was applied
  61493. */
  61494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61495. }
  61496. /**
  61497. * Defines an optimization used to remove shadows
  61498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61499. */
  61500. export class ShadowsOptimization extends SceneOptimization {
  61501. /**
  61502. * Gets a string describing the action executed by the current optimization
  61503. * @return description string
  61504. */
  61505. getDescription(): string;
  61506. /**
  61507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61508. * @param scene defines the current scene where to apply this optimization
  61509. * @param optimizer defines the current optimizer
  61510. * @returns true if everything that can be done was applied
  61511. */
  61512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61513. }
  61514. /**
  61515. * Defines an optimization used to turn post-processes off
  61516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61517. */
  61518. export class PostProcessesOptimization extends SceneOptimization {
  61519. /**
  61520. * Gets a string describing the action executed by the current optimization
  61521. * @return description string
  61522. */
  61523. getDescription(): string;
  61524. /**
  61525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61526. * @param scene defines the current scene where to apply this optimization
  61527. * @param optimizer defines the current optimizer
  61528. * @returns true if everything that can be done was applied
  61529. */
  61530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61531. }
  61532. /**
  61533. * Defines an optimization used to turn lens flares off
  61534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61535. */
  61536. export class LensFlaresOptimization extends SceneOptimization {
  61537. /**
  61538. * Gets a string describing the action executed by the current optimization
  61539. * @return description string
  61540. */
  61541. getDescription(): string;
  61542. /**
  61543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61544. * @param scene defines the current scene where to apply this optimization
  61545. * @param optimizer defines the current optimizer
  61546. * @returns true if everything that can be done was applied
  61547. */
  61548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61549. }
  61550. /**
  61551. * Defines an optimization based on user defined callback.
  61552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61553. */
  61554. export class CustomOptimization extends SceneOptimization {
  61555. /**
  61556. * Callback called to apply the custom optimization.
  61557. */
  61558. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61559. /**
  61560. * Callback called to get custom description
  61561. */
  61562. onGetDescription: () => string;
  61563. /**
  61564. * Gets a string describing the action executed by the current optimization
  61565. * @returns description string
  61566. */
  61567. getDescription(): string;
  61568. /**
  61569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61570. * @param scene defines the current scene where to apply this optimization
  61571. * @param optimizer defines the current optimizer
  61572. * @returns true if everything that can be done was applied
  61573. */
  61574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61575. }
  61576. /**
  61577. * Defines an optimization used to turn particles off
  61578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61579. */
  61580. export class ParticlesOptimization extends SceneOptimization {
  61581. /**
  61582. * Gets a string describing the action executed by the current optimization
  61583. * @return description string
  61584. */
  61585. getDescription(): string;
  61586. /**
  61587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61588. * @param scene defines the current scene where to apply this optimization
  61589. * @param optimizer defines the current optimizer
  61590. * @returns true if everything that can be done was applied
  61591. */
  61592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61593. }
  61594. /**
  61595. * Defines an optimization used to turn render targets off
  61596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61597. */
  61598. export class RenderTargetsOptimization extends SceneOptimization {
  61599. /**
  61600. * Gets a string describing the action executed by the current optimization
  61601. * @return description string
  61602. */
  61603. getDescription(): string;
  61604. /**
  61605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61606. * @param scene defines the current scene where to apply this optimization
  61607. * @param optimizer defines the current optimizer
  61608. * @returns true if everything that can be done was applied
  61609. */
  61610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61611. }
  61612. /**
  61613. * Defines an optimization used to merge meshes with compatible materials
  61614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61615. */
  61616. export class MergeMeshesOptimization extends SceneOptimization {
  61617. private static _UpdateSelectionTree;
  61618. /**
  61619. * Gets or sets a boolean which defines if optimization octree has to be updated
  61620. */
  61621. /**
  61622. * Gets or sets a boolean which defines if optimization octree has to be updated
  61623. */
  61624. static UpdateSelectionTree: boolean;
  61625. /**
  61626. * Gets a string describing the action executed by the current optimization
  61627. * @return description string
  61628. */
  61629. getDescription(): string;
  61630. private _canBeMerged;
  61631. /**
  61632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61633. * @param scene defines the current scene where to apply this optimization
  61634. * @param optimizer defines the current optimizer
  61635. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61636. * @returns true if everything that can be done was applied
  61637. */
  61638. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61639. }
  61640. /**
  61641. * Defines a list of options used by SceneOptimizer
  61642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61643. */
  61644. export class SceneOptimizerOptions {
  61645. /**
  61646. * Defines the target frame rate to reach (60 by default)
  61647. */
  61648. targetFrameRate: number;
  61649. /**
  61650. * Defines the interval between two checkes (2000ms by default)
  61651. */
  61652. trackerDuration: number;
  61653. /**
  61654. * Gets the list of optimizations to apply
  61655. */
  61656. optimizations: SceneOptimization[];
  61657. /**
  61658. * Creates a new list of options used by SceneOptimizer
  61659. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61660. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61661. */
  61662. constructor(
  61663. /**
  61664. * Defines the target frame rate to reach (60 by default)
  61665. */
  61666. targetFrameRate?: number,
  61667. /**
  61668. * Defines the interval between two checkes (2000ms by default)
  61669. */
  61670. trackerDuration?: number);
  61671. /**
  61672. * Add a new optimization
  61673. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61674. * @returns the current SceneOptimizerOptions
  61675. */
  61676. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61677. /**
  61678. * Add a new custom optimization
  61679. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61680. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61682. * @returns the current SceneOptimizerOptions
  61683. */
  61684. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61685. /**
  61686. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61687. * @param targetFrameRate defines the target frame rate (60 by default)
  61688. * @returns a SceneOptimizerOptions object
  61689. */
  61690. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61691. /**
  61692. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61693. * @param targetFrameRate defines the target frame rate (60 by default)
  61694. * @returns a SceneOptimizerOptions object
  61695. */
  61696. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61697. /**
  61698. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61699. * @param targetFrameRate defines the target frame rate (60 by default)
  61700. * @returns a SceneOptimizerOptions object
  61701. */
  61702. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61703. }
  61704. /**
  61705. * Class used to run optimizations in order to reach a target frame rate
  61706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61707. */
  61708. export class SceneOptimizer implements IDisposable {
  61709. private _isRunning;
  61710. private _options;
  61711. private _scene;
  61712. private _currentPriorityLevel;
  61713. private _targetFrameRate;
  61714. private _trackerDuration;
  61715. private _currentFrameRate;
  61716. private _sceneDisposeObserver;
  61717. private _improvementMode;
  61718. /**
  61719. * Defines an observable called when the optimizer reaches the target frame rate
  61720. */
  61721. onSuccessObservable: Observable<SceneOptimizer>;
  61722. /**
  61723. * Defines an observable called when the optimizer enables an optimization
  61724. */
  61725. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61726. /**
  61727. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61728. */
  61729. onFailureObservable: Observable<SceneOptimizer>;
  61730. /**
  61731. * Gets a boolean indicating if the optimizer is in improvement mode
  61732. */
  61733. readonly isInImprovementMode: boolean;
  61734. /**
  61735. * Gets the current priority level (0 at start)
  61736. */
  61737. readonly currentPriorityLevel: number;
  61738. /**
  61739. * Gets the current frame rate checked by the SceneOptimizer
  61740. */
  61741. readonly currentFrameRate: number;
  61742. /**
  61743. * Gets or sets the current target frame rate (60 by default)
  61744. */
  61745. /**
  61746. * Gets or sets the current target frame rate (60 by default)
  61747. */
  61748. targetFrameRate: number;
  61749. /**
  61750. * Gets or sets the current interval between two checks (every 2000ms by default)
  61751. */
  61752. /**
  61753. * Gets or sets the current interval between two checks (every 2000ms by default)
  61754. */
  61755. trackerDuration: number;
  61756. /**
  61757. * Gets the list of active optimizations
  61758. */
  61759. readonly optimizations: SceneOptimization[];
  61760. /**
  61761. * Creates a new SceneOptimizer
  61762. * @param scene defines the scene to work on
  61763. * @param options defines the options to use with the SceneOptimizer
  61764. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61765. * @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)
  61766. */
  61767. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61768. /**
  61769. * Stops the current optimizer
  61770. */
  61771. stop(): void;
  61772. /**
  61773. * Reset the optimizer to initial step (current priority level = 0)
  61774. */
  61775. reset(): void;
  61776. /**
  61777. * Start the optimizer. By default it will try to reach a specific framerate
  61778. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61779. */
  61780. start(): void;
  61781. private _checkCurrentState;
  61782. /**
  61783. * Release all resources
  61784. */
  61785. dispose(): void;
  61786. /**
  61787. * Helper function to create a SceneOptimizer with one single line of code
  61788. * @param scene defines the scene to work on
  61789. * @param options defines the options to use with the SceneOptimizer
  61790. * @param onSuccess defines a callback to call on success
  61791. * @param onFailure defines a callback to call on failure
  61792. * @returns the new SceneOptimizer object
  61793. */
  61794. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61795. }
  61796. }
  61797. declare module BABYLON {
  61798. /**
  61799. * Class used to serialize a scene into a string
  61800. */
  61801. export class SceneSerializer {
  61802. /**
  61803. * Clear cache used by a previous serialization
  61804. */
  61805. static ClearCache(): void;
  61806. /**
  61807. * Serialize a scene into a JSON compatible object
  61808. * @param scene defines the scene to serialize
  61809. * @returns a JSON compatible object
  61810. */
  61811. static Serialize(scene: Scene): any;
  61812. /**
  61813. * Serialize a mesh into a JSON compatible object
  61814. * @param toSerialize defines the mesh to serialize
  61815. * @param withParents defines if parents must be serialized as well
  61816. * @param withChildren defines if children must be serialized as well
  61817. * @returns a JSON compatible object
  61818. */
  61819. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61820. }
  61821. }
  61822. declare module BABYLON {
  61823. /**
  61824. * Class used to host texture specific utilities
  61825. */
  61826. export class TextureTools {
  61827. /**
  61828. * Uses the GPU to create a copy texture rescaled at a given size
  61829. * @param texture Texture to copy from
  61830. * @param width defines the desired width
  61831. * @param height defines the desired height
  61832. * @param useBilinearMode defines if bilinear mode has to be used
  61833. * @return the generated texture
  61834. */
  61835. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /**
  61840. * This represents the different options available for the video capture.
  61841. */
  61842. export interface VideoRecorderOptions {
  61843. /** Defines the mime type of the video. */
  61844. mimeType: string;
  61845. /** Defines the FPS the video should be recorded at. */
  61846. fps: number;
  61847. /** Defines the chunk size for the recording data. */
  61848. recordChunckSize: number;
  61849. /** The audio tracks to attach to the recording. */
  61850. audioTracks?: MediaStreamTrack[];
  61851. }
  61852. /**
  61853. * This can help with recording videos from BabylonJS.
  61854. * This is based on the available WebRTC functionalities of the browser.
  61855. *
  61856. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61857. */
  61858. export class VideoRecorder {
  61859. private static readonly _defaultOptions;
  61860. /**
  61861. * Returns whether or not the VideoRecorder is available in your browser.
  61862. * @param engine Defines the Babylon Engine.
  61863. * @returns true if supported otherwise false.
  61864. */
  61865. static IsSupported(engine: Engine): boolean;
  61866. private readonly _options;
  61867. private _canvas;
  61868. private _mediaRecorder;
  61869. private _recordedChunks;
  61870. private _fileName;
  61871. private _resolve;
  61872. private _reject;
  61873. /**
  61874. * True when a recording is already in progress.
  61875. */
  61876. readonly isRecording: boolean;
  61877. /**
  61878. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61879. * @param engine Defines the BabylonJS Engine you wish to record.
  61880. * @param options Defines options that can be used to customize the capture.
  61881. */
  61882. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61883. /**
  61884. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61885. */
  61886. stopRecording(): void;
  61887. /**
  61888. * Starts recording the canvas for a max duration specified in parameters.
  61889. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61890. * If null no automatic download will start and you can rely on the promise to get the data back.
  61891. * @param maxDuration Defines the maximum recording time in seconds.
  61892. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61893. * @return A promise callback at the end of the recording with the video data in Blob.
  61894. */
  61895. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61896. /**
  61897. * Releases internal resources used during the recording.
  61898. */
  61899. dispose(): void;
  61900. private _handleDataAvailable;
  61901. private _handleError;
  61902. private _handleStop;
  61903. }
  61904. }
  61905. declare module BABYLON {
  61906. /**
  61907. * Class containing a set of static utilities functions for screenshots
  61908. */
  61909. export class ScreenshotTools {
  61910. /**
  61911. * Captures a screenshot of the current rendering
  61912. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61913. * @param engine defines the rendering engine
  61914. * @param camera defines the source camera
  61915. * @param size This parameter can be set to a single number or to an object with the
  61916. * following (optional) properties: precision, width, height. If a single number is passed,
  61917. * it will be used for both width and height. If an object is passed, the screenshot size
  61918. * will be derived from the parameters. The precision property is a multiplier allowing
  61919. * rendering at a higher or lower resolution
  61920. * @param successCallback defines the callback receives a single parameter which contains the
  61921. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61922. * src parameter of an <img> to display it
  61923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61924. * Check your browser for supported MIME types
  61925. */
  61926. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61927. /**
  61928. * Captures a screenshot of the current rendering
  61929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61930. * @param engine defines the rendering engine
  61931. * @param camera defines the source camera
  61932. * @param size This parameter can be set to a single number or to an object with the
  61933. * following (optional) properties: precision, width, height. If a single number is passed,
  61934. * it will be used for both width and height. If an object is passed, the screenshot size
  61935. * will be derived from the parameters. The precision property is a multiplier allowing
  61936. * rendering at a higher or lower resolution
  61937. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61938. * Check your browser for supported MIME types
  61939. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61940. * to the src parameter of an <img> to display it
  61941. */
  61942. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61943. /**
  61944. * Generates an image screenshot from the specified camera.
  61945. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61946. * @param engine The engine to use for rendering
  61947. * @param camera The camera to use for rendering
  61948. * @param size This parameter can be set to a single number or to an object with the
  61949. * following (optional) properties: precision, width, height. If a single number is passed,
  61950. * it will be used for both width and height. If an object is passed, the screenshot size
  61951. * will be derived from the parameters. The precision property is a multiplier allowing
  61952. * rendering at a higher or lower resolution
  61953. * @param successCallback The callback receives a single parameter which contains the
  61954. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61955. * src parameter of an <img> to display it
  61956. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61957. * Check your browser for supported MIME types
  61958. * @param samples Texture samples (default: 1)
  61959. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61960. * @param fileName A name for for the downloaded file.
  61961. */
  61962. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61963. /**
  61964. * Generates an image screenshot from the specified camera.
  61965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61966. * @param engine The engine to use for rendering
  61967. * @param camera The camera to use for rendering
  61968. * @param size This parameter can be set to a single number or to an object with the
  61969. * following (optional) properties: precision, width, height. If a single number is passed,
  61970. * it will be used for both width and height. If an object is passed, the screenshot size
  61971. * will be derived from the parameters. The precision property is a multiplier allowing
  61972. * rendering at a higher or lower resolution
  61973. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61974. * Check your browser for supported MIME types
  61975. * @param samples Texture samples (default: 1)
  61976. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61977. * @param fileName A name for for the downloaded file.
  61978. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61979. * to the src parameter of an <img> to display it
  61980. */
  61981. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61982. /**
  61983. * Gets height and width for screenshot size
  61984. * @private
  61985. */
  61986. private static _getScreenshotSize;
  61987. }
  61988. }
  61989. declare module BABYLON {
  61990. /**
  61991. * A cursor which tracks a point on a path
  61992. */
  61993. export class PathCursor {
  61994. private path;
  61995. /**
  61996. * Stores path cursor callbacks for when an onchange event is triggered
  61997. */
  61998. private _onchange;
  61999. /**
  62000. * The value of the path cursor
  62001. */
  62002. value: number;
  62003. /**
  62004. * The animation array of the path cursor
  62005. */
  62006. animations: Animation[];
  62007. /**
  62008. * Initializes the path cursor
  62009. * @param path The path to track
  62010. */
  62011. constructor(path: Path2);
  62012. /**
  62013. * Gets the cursor point on the path
  62014. * @returns A point on the path cursor at the cursor location
  62015. */
  62016. getPoint(): Vector3;
  62017. /**
  62018. * Moves the cursor ahead by the step amount
  62019. * @param step The amount to move the cursor forward
  62020. * @returns This path cursor
  62021. */
  62022. moveAhead(step?: number): PathCursor;
  62023. /**
  62024. * Moves the cursor behind by the step amount
  62025. * @param step The amount to move the cursor back
  62026. * @returns This path cursor
  62027. */
  62028. moveBack(step?: number): PathCursor;
  62029. /**
  62030. * Moves the cursor by the step amount
  62031. * If the step amount is greater than one, an exception is thrown
  62032. * @param step The amount to move the cursor
  62033. * @returns This path cursor
  62034. */
  62035. move(step: number): PathCursor;
  62036. /**
  62037. * Ensures that the value is limited between zero and one
  62038. * @returns This path cursor
  62039. */
  62040. private ensureLimits;
  62041. /**
  62042. * Runs onchange callbacks on change (used by the animation engine)
  62043. * @returns This path cursor
  62044. */
  62045. private raiseOnChange;
  62046. /**
  62047. * Executes a function on change
  62048. * @param f A path cursor onchange callback
  62049. * @returns This path cursor
  62050. */
  62051. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62052. }
  62053. }
  62054. declare module BABYLON {
  62055. /** @hidden */
  62056. export var blurPixelShader: {
  62057. name: string;
  62058. shader: string;
  62059. };
  62060. }
  62061. declare module BABYLON {
  62062. /** @hidden */
  62063. export var pointCloudVertexDeclaration: {
  62064. name: string;
  62065. shader: string;
  62066. };
  62067. }
  62068. // Mixins
  62069. interface Window {
  62070. mozIndexedDB: IDBFactory;
  62071. webkitIndexedDB: IDBFactory;
  62072. msIndexedDB: IDBFactory;
  62073. webkitURL: typeof URL;
  62074. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62075. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62076. WebGLRenderingContext: WebGLRenderingContext;
  62077. MSGesture: MSGesture;
  62078. CANNON: any;
  62079. AudioContext: AudioContext;
  62080. webkitAudioContext: AudioContext;
  62081. PointerEvent: any;
  62082. Math: Math;
  62083. Uint8Array: Uint8ArrayConstructor;
  62084. Float32Array: Float32ArrayConstructor;
  62085. mozURL: typeof URL;
  62086. msURL: typeof URL;
  62087. VRFrameData: any; // WebVR, from specs 1.1
  62088. DracoDecoderModule: any;
  62089. setImmediate(handler: (...args: any[]) => void): number;
  62090. }
  62091. interface HTMLCanvasElement {
  62092. requestPointerLock(): void;
  62093. msRequestPointerLock?(): void;
  62094. mozRequestPointerLock?(): void;
  62095. webkitRequestPointerLock?(): void;
  62096. /** Track wether a record is in progress */
  62097. isRecording: boolean;
  62098. /** Capture Stream method defined by some browsers */
  62099. captureStream(fps?: number): MediaStream;
  62100. }
  62101. interface CanvasRenderingContext2D {
  62102. msImageSmoothingEnabled: boolean;
  62103. }
  62104. interface MouseEvent {
  62105. mozMovementX: number;
  62106. mozMovementY: number;
  62107. webkitMovementX: number;
  62108. webkitMovementY: number;
  62109. msMovementX: number;
  62110. msMovementY: number;
  62111. }
  62112. interface Navigator {
  62113. mozGetVRDevices: (any: any) => any;
  62114. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62115. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62116. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62117. webkitGetGamepads(): Gamepad[];
  62118. msGetGamepads(): Gamepad[];
  62119. webkitGamepads(): Gamepad[];
  62120. }
  62121. interface HTMLVideoElement {
  62122. mozSrcObject: any;
  62123. }
  62124. interface Math {
  62125. fround(x: number): number;
  62126. imul(a: number, b: number): number;
  62127. }
  62128. interface WebGLRenderingContext {
  62129. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62130. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62131. vertexAttribDivisor(index: number, divisor: number): void;
  62132. createVertexArray(): any;
  62133. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62134. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62135. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62136. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62137. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62138. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62139. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62140. // Queries
  62141. createQuery(): WebGLQuery;
  62142. deleteQuery(query: WebGLQuery): void;
  62143. beginQuery(target: number, query: WebGLQuery): void;
  62144. endQuery(target: number): void;
  62145. getQueryParameter(query: WebGLQuery, pname: number): any;
  62146. getQuery(target: number, pname: number): any;
  62147. MAX_SAMPLES: number;
  62148. RGBA8: number;
  62149. READ_FRAMEBUFFER: number;
  62150. DRAW_FRAMEBUFFER: number;
  62151. UNIFORM_BUFFER: number;
  62152. HALF_FLOAT_OES: number;
  62153. RGBA16F: number;
  62154. RGBA32F: number;
  62155. R32F: number;
  62156. RG32F: number;
  62157. RGB32F: number;
  62158. R16F: number;
  62159. RG16F: number;
  62160. RGB16F: number;
  62161. RED: number;
  62162. RG: number;
  62163. R8: number;
  62164. RG8: number;
  62165. UNSIGNED_INT_24_8: number;
  62166. DEPTH24_STENCIL8: number;
  62167. /* Multiple Render Targets */
  62168. drawBuffers(buffers: number[]): void;
  62169. readBuffer(src: number): void;
  62170. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62171. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62172. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62173. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62174. // Occlusion Query
  62175. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62176. ANY_SAMPLES_PASSED: number;
  62177. QUERY_RESULT_AVAILABLE: number;
  62178. QUERY_RESULT: number;
  62179. }
  62180. interface WebGLProgram {
  62181. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62182. }
  62183. interface EXT_disjoint_timer_query {
  62184. QUERY_COUNTER_BITS_EXT: number;
  62185. TIME_ELAPSED_EXT: number;
  62186. TIMESTAMP_EXT: number;
  62187. GPU_DISJOINT_EXT: number;
  62188. QUERY_RESULT_EXT: number;
  62189. QUERY_RESULT_AVAILABLE_EXT: number;
  62190. queryCounterEXT(query: WebGLQuery, target: number): void;
  62191. createQueryEXT(): WebGLQuery;
  62192. beginQueryEXT(target: number, query: WebGLQuery): void;
  62193. endQueryEXT(target: number): void;
  62194. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62195. deleteQueryEXT(query: WebGLQuery): void;
  62196. }
  62197. interface WebGLUniformLocation {
  62198. _currentState: any;
  62199. }
  62200. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62201. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62202. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62203. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62204. interface WebGLRenderingContext {
  62205. readonly RASTERIZER_DISCARD: number;
  62206. readonly DEPTH_COMPONENT24: number;
  62207. readonly TEXTURE_3D: number;
  62208. readonly TEXTURE_2D_ARRAY: number;
  62209. readonly TEXTURE_COMPARE_FUNC: number;
  62210. readonly TEXTURE_COMPARE_MODE: number;
  62211. readonly COMPARE_REF_TO_TEXTURE: number;
  62212. readonly TEXTURE_WRAP_R: number;
  62213. readonly HALF_FLOAT: number;
  62214. readonly RGB8: number;
  62215. readonly RED_INTEGER: number;
  62216. readonly RG_INTEGER: number;
  62217. readonly RGB_INTEGER: number;
  62218. readonly RGBA_INTEGER: number;
  62219. readonly R8_SNORM: number;
  62220. readonly RG8_SNORM: number;
  62221. readonly RGB8_SNORM: number;
  62222. readonly RGBA8_SNORM: number;
  62223. readonly R8I: number;
  62224. readonly RG8I: number;
  62225. readonly RGB8I: number;
  62226. readonly RGBA8I: number;
  62227. readonly R8UI: number;
  62228. readonly RG8UI: number;
  62229. readonly RGB8UI: number;
  62230. readonly RGBA8UI: number;
  62231. readonly R16I: number;
  62232. readonly RG16I: number;
  62233. readonly RGB16I: number;
  62234. readonly RGBA16I: number;
  62235. readonly R16UI: number;
  62236. readonly RG16UI: number;
  62237. readonly RGB16UI: number;
  62238. readonly RGBA16UI: number;
  62239. readonly R32I: number;
  62240. readonly RG32I: number;
  62241. readonly RGB32I: number;
  62242. readonly RGBA32I: number;
  62243. readonly R32UI: number;
  62244. readonly RG32UI: number;
  62245. readonly RGB32UI: number;
  62246. readonly RGBA32UI: number;
  62247. readonly RGB10_A2UI: number;
  62248. readonly R11F_G11F_B10F: number;
  62249. readonly RGB9_E5: number;
  62250. readonly RGB10_A2: number;
  62251. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62252. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62253. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62254. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62255. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62256. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62257. 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;
  62258. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62259. readonly TRANSFORM_FEEDBACK: number;
  62260. readonly INTERLEAVED_ATTRIBS: number;
  62261. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62262. createTransformFeedback(): WebGLTransformFeedback;
  62263. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62264. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62265. beginTransformFeedback(primitiveMode: number): void;
  62266. endTransformFeedback(): void;
  62267. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62268. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62269. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62270. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62271. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62272. }
  62273. interface ImageBitmap {
  62274. readonly width: number;
  62275. readonly height: number;
  62276. close(): void;
  62277. }
  62278. interface WebGLQuery extends WebGLObject {
  62279. }
  62280. declare var WebGLQuery: {
  62281. prototype: WebGLQuery;
  62282. new(): WebGLQuery;
  62283. };
  62284. interface WebGLSampler extends WebGLObject {
  62285. }
  62286. declare var WebGLSampler: {
  62287. prototype: WebGLSampler;
  62288. new(): WebGLSampler;
  62289. };
  62290. interface WebGLSync extends WebGLObject {
  62291. }
  62292. declare var WebGLSync: {
  62293. prototype: WebGLSync;
  62294. new(): WebGLSync;
  62295. };
  62296. interface WebGLTransformFeedback extends WebGLObject {
  62297. }
  62298. declare var WebGLTransformFeedback: {
  62299. prototype: WebGLTransformFeedback;
  62300. new(): WebGLTransformFeedback;
  62301. };
  62302. interface WebGLVertexArrayObject extends WebGLObject {
  62303. }
  62304. declare var WebGLVertexArrayObject: {
  62305. prototype: WebGLVertexArrayObject;
  62306. new(): WebGLVertexArrayObject;
  62307. };
  62308. // Type definitions for WebVR API
  62309. // Project: https://w3c.github.io/webvr/
  62310. // Definitions by: six a <https://github.com/lostfictions>
  62311. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62312. interface VRDisplay extends EventTarget {
  62313. /**
  62314. * Dictionary of capabilities describing the VRDisplay.
  62315. */
  62316. readonly capabilities: VRDisplayCapabilities;
  62317. /**
  62318. * z-depth defining the far plane of the eye view frustum
  62319. * enables mapping of values in the render target depth
  62320. * attachment to scene coordinates. Initially set to 10000.0.
  62321. */
  62322. depthFar: number;
  62323. /**
  62324. * z-depth defining the near plane of the eye view frustum
  62325. * enables mapping of values in the render target depth
  62326. * attachment to scene coordinates. Initially set to 0.01.
  62327. */
  62328. depthNear: number;
  62329. /**
  62330. * An identifier for this distinct VRDisplay. Used as an
  62331. * association point in the Gamepad API.
  62332. */
  62333. readonly displayId: number;
  62334. /**
  62335. * A display name, a user-readable name identifying it.
  62336. */
  62337. readonly displayName: string;
  62338. readonly isConnected: boolean;
  62339. readonly isPresenting: boolean;
  62340. /**
  62341. * If this VRDisplay supports room-scale experiences, the optional
  62342. * stage attribute contains details on the room-scale parameters.
  62343. */
  62344. readonly stageParameters: VRStageParameters | null;
  62345. /**
  62346. * Passing the value returned by `requestAnimationFrame` to
  62347. * `cancelAnimationFrame` will unregister the callback.
  62348. * @param handle Define the hanle of the request to cancel
  62349. */
  62350. cancelAnimationFrame(handle: number): void;
  62351. /**
  62352. * Stops presenting to the VRDisplay.
  62353. * @returns a promise to know when it stopped
  62354. */
  62355. exitPresent(): Promise<void>;
  62356. /**
  62357. * Return the current VREyeParameters for the given eye.
  62358. * @param whichEye Define the eye we want the parameter for
  62359. * @returns the eye parameters
  62360. */
  62361. getEyeParameters(whichEye: string): VREyeParameters;
  62362. /**
  62363. * Populates the passed VRFrameData with the information required to render
  62364. * the current frame.
  62365. * @param frameData Define the data structure to populate
  62366. * @returns true if ok otherwise false
  62367. */
  62368. getFrameData(frameData: VRFrameData): boolean;
  62369. /**
  62370. * Get the layers currently being presented.
  62371. * @returns the list of VR layers
  62372. */
  62373. getLayers(): VRLayer[];
  62374. /**
  62375. * Return a VRPose containing the future predicted pose of the VRDisplay
  62376. * when the current frame will be presented. The value returned will not
  62377. * change until JavaScript has returned control to the browser.
  62378. *
  62379. * The VRPose will contain the position, orientation, velocity,
  62380. * and acceleration of each of these properties.
  62381. * @returns the pose object
  62382. */
  62383. getPose(): VRPose;
  62384. /**
  62385. * Return the current instantaneous pose of the VRDisplay, with no
  62386. * prediction applied.
  62387. * @returns the current instantaneous pose
  62388. */
  62389. getImmediatePose(): VRPose;
  62390. /**
  62391. * The callback passed to `requestAnimationFrame` will be called
  62392. * any time a new frame should be rendered. When the VRDisplay is
  62393. * presenting the callback will be called at the native refresh
  62394. * rate of the HMD. When not presenting this function acts
  62395. * identically to how window.requestAnimationFrame acts. Content should
  62396. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62397. * asynchronously from other displays and at differing refresh rates.
  62398. * @param callback Define the eaction to run next frame
  62399. * @returns the request handle it
  62400. */
  62401. requestAnimationFrame(callback: FrameRequestCallback): number;
  62402. /**
  62403. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62404. * Repeat calls while already presenting will update the VRLayers being displayed.
  62405. * @param layers Define the list of layer to present
  62406. * @returns a promise to know when the request has been fulfilled
  62407. */
  62408. requestPresent(layers: VRLayer[]): Promise<void>;
  62409. /**
  62410. * Reset the pose for this display, treating its current position and
  62411. * orientation as the "origin/zero" values. VRPose.position,
  62412. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62413. * updated when calling resetPose(). This should be called in only
  62414. * sitting-space experiences.
  62415. */
  62416. resetPose(): void;
  62417. /**
  62418. * The VRLayer provided to the VRDisplay will be captured and presented
  62419. * in the HMD. Calling this function has the same effect on the source
  62420. * canvas as any other operation that uses its source image, and canvases
  62421. * created without preserveDrawingBuffer set to true will be cleared.
  62422. * @param pose Define the pose to submit
  62423. */
  62424. submitFrame(pose?: VRPose): void;
  62425. }
  62426. declare var VRDisplay: {
  62427. prototype: VRDisplay;
  62428. new(): VRDisplay;
  62429. };
  62430. interface VRLayer {
  62431. leftBounds?: number[] | Float32Array | null;
  62432. rightBounds?: number[] | Float32Array | null;
  62433. source?: HTMLCanvasElement | null;
  62434. }
  62435. interface VRDisplayCapabilities {
  62436. readonly canPresent: boolean;
  62437. readonly hasExternalDisplay: boolean;
  62438. readonly hasOrientation: boolean;
  62439. readonly hasPosition: boolean;
  62440. readonly maxLayers: number;
  62441. }
  62442. interface VREyeParameters {
  62443. /** @deprecated */
  62444. readonly fieldOfView: VRFieldOfView;
  62445. readonly offset: Float32Array;
  62446. readonly renderHeight: number;
  62447. readonly renderWidth: number;
  62448. }
  62449. interface VRFieldOfView {
  62450. readonly downDegrees: number;
  62451. readonly leftDegrees: number;
  62452. readonly rightDegrees: number;
  62453. readonly upDegrees: number;
  62454. }
  62455. interface VRFrameData {
  62456. readonly leftProjectionMatrix: Float32Array;
  62457. readonly leftViewMatrix: Float32Array;
  62458. readonly pose: VRPose;
  62459. readonly rightProjectionMatrix: Float32Array;
  62460. readonly rightViewMatrix: Float32Array;
  62461. readonly timestamp: number;
  62462. }
  62463. interface VRPose {
  62464. readonly angularAcceleration: Float32Array | null;
  62465. readonly angularVelocity: Float32Array | null;
  62466. readonly linearAcceleration: Float32Array | null;
  62467. readonly linearVelocity: Float32Array | null;
  62468. readonly orientation: Float32Array | null;
  62469. readonly position: Float32Array | null;
  62470. readonly timestamp: number;
  62471. }
  62472. interface VRStageParameters {
  62473. sittingToStandingTransform?: Float32Array;
  62474. sizeX?: number;
  62475. sizeY?: number;
  62476. }
  62477. interface Navigator {
  62478. getVRDisplays(): Promise<VRDisplay[]>;
  62479. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62480. }
  62481. interface Window {
  62482. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62483. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62484. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62485. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62486. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62487. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62488. }
  62489. interface Gamepad {
  62490. readonly displayId: number;
  62491. }
  62492. type XRSessionMode =
  62493. | "inline"
  62494. | "immersive-vr"
  62495. | "immersive-ar";
  62496. type XRReferenceSpaceType =
  62497. | "viewer"
  62498. | "local"
  62499. | "local-floor"
  62500. | "bounded-floor"
  62501. | "unbounded";
  62502. type XREnvironmentBlendMode =
  62503. | "opaque"
  62504. | "additive"
  62505. | "alpha-blend";
  62506. type XRVisibilityState =
  62507. | "visible"
  62508. | "visible-blurred"
  62509. | "hidden";
  62510. type XRHandedness =
  62511. | "none"
  62512. | "left"
  62513. | "right";
  62514. type XRTargetRayMode =
  62515. | "gaze"
  62516. | "tracked-pointer"
  62517. | "screen";
  62518. type XREye =
  62519. | "none"
  62520. | "left"
  62521. | "right";
  62522. interface XRSpace extends EventTarget {
  62523. }
  62524. interface XRRenderState {
  62525. depthNear?: number;
  62526. depthFar?: number;
  62527. inlineVerticalFieldOfView?: number;
  62528. baseLayer?: XRWebGLLayer;
  62529. }
  62530. interface XRInputSource {
  62531. handedness: XRHandedness;
  62532. targetRayMode: XRTargetRayMode;
  62533. targetRaySpace: XRSpace;
  62534. gripSpace: XRSpace | undefined;
  62535. gamepad: Gamepad | undefined;
  62536. profiles: Array<string>;
  62537. }
  62538. interface XRSession {
  62539. addEventListener: Function;
  62540. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62541. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62542. requestAnimationFrame: Function;
  62543. end(): Promise<void>;
  62544. renderState: XRRenderState;
  62545. inputSources: Array<XRInputSource>;
  62546. }
  62547. interface XRReferenceSpace extends XRSpace {
  62548. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62549. onreset: any;
  62550. }
  62551. interface XRFrame {
  62552. session: XRSession;
  62553. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62554. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62555. }
  62556. interface XRViewerPose extends XRPose {
  62557. views: Array<XRView>;
  62558. }
  62559. interface XRPose {
  62560. transform: XRRigidTransform;
  62561. emulatedPosition: boolean;
  62562. }
  62563. declare var XRWebGLLayer: {
  62564. prototype: XRWebGLLayer;
  62565. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62566. };
  62567. interface XRWebGLLayer {
  62568. framebuffer: WebGLFramebuffer;
  62569. framebufferWidth: number;
  62570. framebufferHeight: number;
  62571. getViewport: Function;
  62572. }
  62573. interface XRRigidTransform {
  62574. position: DOMPointReadOnly;
  62575. orientation: DOMPointReadOnly;
  62576. matrix: Float32Array;
  62577. inverse: XRRigidTransform;
  62578. }
  62579. interface XRView {
  62580. eye: XREye;
  62581. projectionMatrix: Float32Array;
  62582. transform: XRRigidTransform;
  62583. }
  62584. interface XRInputSourceChangeEvent {
  62585. session: XRSession;
  62586. removed: Array<XRInputSource>;
  62587. added: Array<XRInputSource>;
  62588. }
  62589. declare module BABYLON.GUI {
  62590. /**
  62591. * Class used to specific a value and its associated unit
  62592. */
  62593. export class ValueAndUnit {
  62594. /** defines the unit to store */
  62595. unit: number;
  62596. /** defines a boolean indicating if the value can be negative */
  62597. negativeValueAllowed: boolean;
  62598. private _value;
  62599. private _originalUnit;
  62600. /**
  62601. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62602. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62603. */
  62604. ignoreAdaptiveScaling: boolean;
  62605. /**
  62606. * Creates a new ValueAndUnit
  62607. * @param value defines the value to store
  62608. * @param unit defines the unit to store
  62609. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62610. */
  62611. constructor(value: number,
  62612. /** defines the unit to store */
  62613. unit?: number,
  62614. /** defines a boolean indicating if the value can be negative */
  62615. negativeValueAllowed?: boolean);
  62616. /** Gets a boolean indicating if the value is a percentage */
  62617. readonly isPercentage: boolean;
  62618. /** Gets a boolean indicating if the value is store as pixel */
  62619. readonly isPixel: boolean;
  62620. /** Gets direct internal value */
  62621. readonly internalValue: number;
  62622. /**
  62623. * Gets value as pixel
  62624. * @param host defines the root host
  62625. * @param refValue defines the reference value for percentages
  62626. * @returns the value as pixel
  62627. */
  62628. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62629. /**
  62630. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62631. * @param value defines the value to store
  62632. * @param unit defines the unit to store
  62633. * @returns the current ValueAndUnit
  62634. */
  62635. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62636. /**
  62637. * Gets the value accordingly to its unit
  62638. * @param host defines the root host
  62639. * @returns the value
  62640. */
  62641. getValue(host: AdvancedDynamicTexture): number;
  62642. /**
  62643. * Gets a string representation of the value
  62644. * @param host defines the root host
  62645. * @param decimals defines an optional number of decimals to display
  62646. * @returns a string
  62647. */
  62648. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62649. /**
  62650. * Store a value parsed from a string
  62651. * @param source defines the source string
  62652. * @returns true if the value was successfully parsed
  62653. */
  62654. fromString(source: string | number): boolean;
  62655. private static _Regex;
  62656. private static _UNITMODE_PERCENTAGE;
  62657. private static _UNITMODE_PIXEL;
  62658. /** UNITMODE_PERCENTAGE */
  62659. static readonly UNITMODE_PERCENTAGE: number;
  62660. /** UNITMODE_PIXEL */
  62661. static readonly UNITMODE_PIXEL: number;
  62662. }
  62663. }
  62664. declare module BABYLON.GUI {
  62665. /**
  62666. * Define a style used by control to automatically setup properties based on a template.
  62667. * Only support font related properties so far
  62668. */
  62669. export class Style implements BABYLON.IDisposable {
  62670. private _fontFamily;
  62671. private _fontStyle;
  62672. private _fontWeight;
  62673. /** @hidden */
  62674. _host: AdvancedDynamicTexture;
  62675. /** @hidden */
  62676. _fontSize: ValueAndUnit;
  62677. /**
  62678. * BABYLON.Observable raised when the style values are changed
  62679. */
  62680. onChangedObservable: BABYLON.Observable<Style>;
  62681. /**
  62682. * Creates a new style object
  62683. * @param host defines the AdvancedDynamicTexture which hosts this style
  62684. */
  62685. constructor(host: AdvancedDynamicTexture);
  62686. /**
  62687. * Gets or sets the font size
  62688. */
  62689. fontSize: string | number;
  62690. /**
  62691. * Gets or sets the font family
  62692. */
  62693. fontFamily: string;
  62694. /**
  62695. * Gets or sets the font style
  62696. */
  62697. fontStyle: string;
  62698. /** Gets or sets font weight */
  62699. fontWeight: string;
  62700. /** Dispose all associated resources */
  62701. dispose(): void;
  62702. }
  62703. }
  62704. declare module BABYLON.GUI {
  62705. /**
  62706. * Class used to transport BABYLON.Vector2 information for pointer events
  62707. */
  62708. export class Vector2WithInfo extends BABYLON.Vector2 {
  62709. /** defines the current mouse button index */
  62710. buttonIndex: number;
  62711. /**
  62712. * Creates a new Vector2WithInfo
  62713. * @param source defines the vector2 data to transport
  62714. * @param buttonIndex defines the current mouse button index
  62715. */
  62716. constructor(source: BABYLON.Vector2,
  62717. /** defines the current mouse button index */
  62718. buttonIndex?: number);
  62719. }
  62720. /** Class used to provide 2D matrix features */
  62721. export class Matrix2D {
  62722. /** Gets the internal array of 6 floats used to store matrix data */
  62723. m: Float32Array;
  62724. /**
  62725. * Creates a new matrix
  62726. * @param m00 defines value for (0, 0)
  62727. * @param m01 defines value for (0, 1)
  62728. * @param m10 defines value for (1, 0)
  62729. * @param m11 defines value for (1, 1)
  62730. * @param m20 defines value for (2, 0)
  62731. * @param m21 defines value for (2, 1)
  62732. */
  62733. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62734. /**
  62735. * Fills the matrix from direct values
  62736. * @param m00 defines value for (0, 0)
  62737. * @param m01 defines value for (0, 1)
  62738. * @param m10 defines value for (1, 0)
  62739. * @param m11 defines value for (1, 1)
  62740. * @param m20 defines value for (2, 0)
  62741. * @param m21 defines value for (2, 1)
  62742. * @returns the current modified matrix
  62743. */
  62744. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62745. /**
  62746. * Gets matrix determinant
  62747. * @returns the determinant
  62748. */
  62749. determinant(): number;
  62750. /**
  62751. * Inverses the matrix and stores it in a target matrix
  62752. * @param result defines the target matrix
  62753. * @returns the current matrix
  62754. */
  62755. invertToRef(result: Matrix2D): Matrix2D;
  62756. /**
  62757. * Multiplies the current matrix with another one
  62758. * @param other defines the second operand
  62759. * @param result defines the target matrix
  62760. * @returns the current matrix
  62761. */
  62762. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62763. /**
  62764. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62765. * @param x defines the x coordinate to transform
  62766. * @param y defines the x coordinate to transform
  62767. * @param result defines the target vector2
  62768. * @returns the current matrix
  62769. */
  62770. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62771. /**
  62772. * Creates an identity matrix
  62773. * @returns a new matrix
  62774. */
  62775. static Identity(): Matrix2D;
  62776. /**
  62777. * Creates a translation matrix and stores it in a target matrix
  62778. * @param x defines the x coordinate of the translation
  62779. * @param y defines the y coordinate of the translation
  62780. * @param result defines the target matrix
  62781. */
  62782. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62783. /**
  62784. * Creates a scaling matrix and stores it in a target matrix
  62785. * @param x defines the x coordinate of the scaling
  62786. * @param y defines the y coordinate of the scaling
  62787. * @param result defines the target matrix
  62788. */
  62789. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62790. /**
  62791. * Creates a rotation matrix and stores it in a target matrix
  62792. * @param angle defines the rotation angle
  62793. * @param result defines the target matrix
  62794. */
  62795. static RotationToRef(angle: number, result: Matrix2D): void;
  62796. private static _TempPreTranslationMatrix;
  62797. private static _TempPostTranslationMatrix;
  62798. private static _TempRotationMatrix;
  62799. private static _TempScalingMatrix;
  62800. private static _TempCompose0;
  62801. private static _TempCompose1;
  62802. private static _TempCompose2;
  62803. /**
  62804. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62805. * @param tx defines the x coordinate of the translation
  62806. * @param ty defines the y coordinate of the translation
  62807. * @param angle defines the rotation angle
  62808. * @param scaleX defines the x coordinate of the scaling
  62809. * @param scaleY defines the y coordinate of the scaling
  62810. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62811. * @param result defines the target matrix
  62812. */
  62813. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62814. }
  62815. }
  62816. declare module BABYLON.GUI {
  62817. /**
  62818. * Class used to store 2D control sizes
  62819. */
  62820. export class Measure {
  62821. /** defines left coordinate */
  62822. left: number;
  62823. /** defines top coordinate */
  62824. top: number;
  62825. /** defines width dimension */
  62826. width: number;
  62827. /** defines height dimension */
  62828. height: number;
  62829. /**
  62830. * Creates a new measure
  62831. * @param left defines left coordinate
  62832. * @param top defines top coordinate
  62833. * @param width defines width dimension
  62834. * @param height defines height dimension
  62835. */
  62836. constructor(
  62837. /** defines left coordinate */
  62838. left: number,
  62839. /** defines top coordinate */
  62840. top: number,
  62841. /** defines width dimension */
  62842. width: number,
  62843. /** defines height dimension */
  62844. height: number);
  62845. /**
  62846. * Copy from another measure
  62847. * @param other defines the other measure to copy from
  62848. */
  62849. copyFrom(other: Measure): void;
  62850. /**
  62851. * Copy from a group of 4 floats
  62852. * @param left defines left coordinate
  62853. * @param top defines top coordinate
  62854. * @param width defines width dimension
  62855. * @param height defines height dimension
  62856. */
  62857. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62858. /**
  62859. * Computes the axis aligned bounding box measure for two given measures
  62860. * @param a Input measure
  62861. * @param b Input measure
  62862. * @param result the resulting bounding measure
  62863. */
  62864. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62865. /**
  62866. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62867. * @param transform the matrix to transform the measure before computing the AABB
  62868. * @param result the resulting AABB
  62869. */
  62870. transformToRef(transform: Matrix2D, result: Measure): void;
  62871. /**
  62872. * Check equality between this measure and another one
  62873. * @param other defines the other measures
  62874. * @returns true if both measures are equals
  62875. */
  62876. isEqualsTo(other: Measure): boolean;
  62877. /**
  62878. * Creates an empty measure
  62879. * @returns a new measure
  62880. */
  62881. static Empty(): Measure;
  62882. }
  62883. }
  62884. declare module BABYLON.GUI {
  62885. /**
  62886. * Interface used to define a control that can receive focus
  62887. */
  62888. export interface IFocusableControl {
  62889. /**
  62890. * Function called when the control receives the focus
  62891. */
  62892. onFocus(): void;
  62893. /**
  62894. * Function called when the control loses the focus
  62895. */
  62896. onBlur(): void;
  62897. /**
  62898. * Function called to let the control handle keyboard events
  62899. * @param evt defines the current keyboard event
  62900. */
  62901. processKeyboard(evt: KeyboardEvent): void;
  62902. /**
  62903. * Function called to get the list of controls that should not steal the focus from this control
  62904. * @returns an array of controls
  62905. */
  62906. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62907. }
  62908. /**
  62909. * Class used to create texture to support 2D GUI elements
  62910. * @see http://doc.babylonjs.com/how_to/gui
  62911. */
  62912. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62913. private _isDirty;
  62914. private _renderObserver;
  62915. private _resizeObserver;
  62916. private _preKeyboardObserver;
  62917. private _pointerMoveObserver;
  62918. private _pointerObserver;
  62919. private _canvasPointerOutObserver;
  62920. private _background;
  62921. /** @hidden */
  62922. _rootContainer: Container;
  62923. /** @hidden */
  62924. _lastPickedControl: Control;
  62925. /** @hidden */
  62926. _lastControlOver: {
  62927. [pointerId: number]: Control;
  62928. };
  62929. /** @hidden */
  62930. _lastControlDown: {
  62931. [pointerId: number]: Control;
  62932. };
  62933. /** @hidden */
  62934. _capturingControl: {
  62935. [pointerId: number]: Control;
  62936. };
  62937. /** @hidden */
  62938. _shouldBlockPointer: boolean;
  62939. /** @hidden */
  62940. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62941. /** @hidden */
  62942. _linkedControls: Control[];
  62943. private _isFullscreen;
  62944. private _fullscreenViewport;
  62945. private _idealWidth;
  62946. private _idealHeight;
  62947. private _useSmallestIdeal;
  62948. private _renderAtIdealSize;
  62949. private _focusedControl;
  62950. private _blockNextFocusCheck;
  62951. private _renderScale;
  62952. private _rootCanvas;
  62953. private _cursorChanged;
  62954. /**
  62955. * Define type to string to ensure compatibility across browsers
  62956. * Safari doesn't support DataTransfer constructor
  62957. */
  62958. private _clipboardData;
  62959. /**
  62960. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62961. */
  62962. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62963. /**
  62964. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62965. */
  62966. onControlPickedObservable: BABYLON.Observable<Control>;
  62967. /**
  62968. * BABYLON.Observable event triggered before layout is evaluated
  62969. */
  62970. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62971. /**
  62972. * BABYLON.Observable event triggered after the layout was evaluated
  62973. */
  62974. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62975. /**
  62976. * BABYLON.Observable event triggered before the texture is rendered
  62977. */
  62978. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62979. /**
  62980. * BABYLON.Observable event triggered after the texture was rendered
  62981. */
  62982. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62983. /**
  62984. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62985. */
  62986. premulAlpha: boolean;
  62987. /**
  62988. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62989. * Useful when you want more antialiasing
  62990. */
  62991. renderScale: number;
  62992. /** Gets or sets the background color */
  62993. background: string;
  62994. /**
  62995. * Gets or sets the ideal width used to design controls.
  62996. * The GUI will then rescale everything accordingly
  62997. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62998. */
  62999. idealWidth: number;
  63000. /**
  63001. * Gets or sets the ideal height used to design controls.
  63002. * The GUI will then rescale everything accordingly
  63003. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63004. */
  63005. idealHeight: number;
  63006. /**
  63007. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63008. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63009. */
  63010. useSmallestIdeal: boolean;
  63011. /**
  63012. * Gets or sets a boolean indicating if adaptive scaling must be used
  63013. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63014. */
  63015. renderAtIdealSize: boolean;
  63016. /**
  63017. * Gets the underlying layer used to render the texture when in fullscreen mode
  63018. */
  63019. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63020. /**
  63021. * Gets the root container control
  63022. */
  63023. readonly rootContainer: Container;
  63024. /**
  63025. * Returns an array containing the root container.
  63026. * This is mostly used to let the Inspector introspects the ADT
  63027. * @returns an array containing the rootContainer
  63028. */
  63029. getChildren(): Array<Container>;
  63030. /**
  63031. * Will return all controls that are inside this texture
  63032. * @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
  63033. * @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
  63034. * @return all child controls
  63035. */
  63036. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63037. /**
  63038. * Gets or sets the current focused control
  63039. */
  63040. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63041. /**
  63042. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63043. */
  63044. isForeground: boolean;
  63045. /**
  63046. * Gets or set information about clipboardData
  63047. */
  63048. clipboardData: string;
  63049. /**
  63050. * Creates a new AdvancedDynamicTexture
  63051. * @param name defines the name of the texture
  63052. * @param width defines the width of the texture
  63053. * @param height defines the height of the texture
  63054. * @param scene defines the hosting scene
  63055. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63056. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63057. */
  63058. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63059. /**
  63060. * Get the current class name of the texture useful for serialization or dynamic coding.
  63061. * @returns "AdvancedDynamicTexture"
  63062. */
  63063. getClassName(): string;
  63064. /**
  63065. * Function used to execute a function on all controls
  63066. * @param func defines the function to execute
  63067. * @param container defines the container where controls belong. If null the root container will be used
  63068. */
  63069. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63070. private _useInvalidateRectOptimization;
  63071. /**
  63072. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63073. */
  63074. useInvalidateRectOptimization: boolean;
  63075. private _invalidatedRectangle;
  63076. /**
  63077. * Invalidates a rectangle area on the gui texture
  63078. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63079. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63080. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63081. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63082. */
  63083. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63084. /**
  63085. * Marks the texture as dirty forcing a complete update
  63086. */
  63087. markAsDirty(): void;
  63088. /**
  63089. * Helper function used to create a new style
  63090. * @returns a new style
  63091. * @see http://doc.babylonjs.com/how_to/gui#styles
  63092. */
  63093. createStyle(): Style;
  63094. /**
  63095. * Adds a new control to the root container
  63096. * @param control defines the control to add
  63097. * @returns the current texture
  63098. */
  63099. addControl(control: Control): AdvancedDynamicTexture;
  63100. /**
  63101. * Removes a control from the root container
  63102. * @param control defines the control to remove
  63103. * @returns the current texture
  63104. */
  63105. removeControl(control: Control): AdvancedDynamicTexture;
  63106. /**
  63107. * Release all resources
  63108. */
  63109. dispose(): void;
  63110. private _onResize;
  63111. /** @hidden */
  63112. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63113. /**
  63114. * Get screen coordinates for a vector3
  63115. * @param position defines the position to project
  63116. * @param worldMatrix defines the world matrix to use
  63117. * @returns the projected position
  63118. */
  63119. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63120. private _checkUpdate;
  63121. private _clearMeasure;
  63122. private _render;
  63123. /** @hidden */
  63124. _changeCursor(cursor: string): void;
  63125. /** @hidden */
  63126. _registerLastControlDown(control: Control, pointerId: number): void;
  63127. private _doPicking;
  63128. /** @hidden */
  63129. _cleanControlAfterRemovalFromList(list: {
  63130. [pointerId: number]: Control;
  63131. }, control: Control): void;
  63132. /** @hidden */
  63133. _cleanControlAfterRemoval(control: Control): void;
  63134. /** Attach to all scene events required to support pointer events */
  63135. attach(): void;
  63136. /** @hidden */
  63137. private onClipboardCopy;
  63138. /** @hidden */
  63139. private onClipboardCut;
  63140. /** @hidden */
  63141. private onClipboardPaste;
  63142. /**
  63143. * Register the clipboard Events onto the canvas
  63144. */
  63145. registerClipboardEvents(): void;
  63146. /**
  63147. * Unregister the clipboard Events from the canvas
  63148. */
  63149. unRegisterClipboardEvents(): void;
  63150. /**
  63151. * Connect the texture to a hosting mesh to enable interactions
  63152. * @param mesh defines the mesh to attach to
  63153. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63154. */
  63155. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63156. /**
  63157. * Move the focus to a specific control
  63158. * @param control defines the control which will receive the focus
  63159. */
  63160. moveFocusToControl(control: IFocusableControl): void;
  63161. private _manageFocus;
  63162. private _attachToOnPointerOut;
  63163. /**
  63164. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63165. * @param mesh defines the mesh which will receive the texture
  63166. * @param width defines the texture width (1024 by default)
  63167. * @param height defines the texture height (1024 by default)
  63168. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63169. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63170. * @returns a new AdvancedDynamicTexture
  63171. */
  63172. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63173. /**
  63174. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63175. * In this mode the texture will rely on a layer for its rendering.
  63176. * This allows it to be treated like any other layer.
  63177. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63178. * LayerMask is set through advancedTexture.layer.layerMask
  63179. * @param name defines name for the texture
  63180. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63181. * @param scene defines the hsoting scene
  63182. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63183. * @returns a new AdvancedDynamicTexture
  63184. */
  63185. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63186. }
  63187. }
  63188. declare module BABYLON.GUI {
  63189. /**
  63190. * Root class used for all 2D controls
  63191. * @see http://doc.babylonjs.com/how_to/gui#controls
  63192. */
  63193. export class Control {
  63194. /** defines the name of the control */
  63195. name?: string | undefined;
  63196. /**
  63197. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63198. */
  63199. static AllowAlphaInheritance: boolean;
  63200. private _alpha;
  63201. private _alphaSet;
  63202. private _zIndex;
  63203. /** @hidden */
  63204. _host: AdvancedDynamicTexture;
  63205. /** Gets or sets the control parent */
  63206. parent: BABYLON.Nullable<Container>;
  63207. /** @hidden */
  63208. _currentMeasure: Measure;
  63209. private _fontFamily;
  63210. private _fontStyle;
  63211. private _fontWeight;
  63212. private _fontSize;
  63213. private _font;
  63214. /** @hidden */
  63215. _width: ValueAndUnit;
  63216. /** @hidden */
  63217. _height: ValueAndUnit;
  63218. /** @hidden */
  63219. protected _fontOffset: {
  63220. ascent: number;
  63221. height: number;
  63222. descent: number;
  63223. };
  63224. private _color;
  63225. private _style;
  63226. private _styleObserver;
  63227. /** @hidden */
  63228. protected _horizontalAlignment: number;
  63229. /** @hidden */
  63230. protected _verticalAlignment: number;
  63231. /** @hidden */
  63232. protected _isDirty: boolean;
  63233. /** @hidden */
  63234. protected _wasDirty: boolean;
  63235. /** @hidden */
  63236. _tempParentMeasure: Measure;
  63237. /** @hidden */
  63238. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63239. /** @hidden */
  63240. protected _cachedParentMeasure: Measure;
  63241. private _paddingLeft;
  63242. private _paddingRight;
  63243. private _paddingTop;
  63244. private _paddingBottom;
  63245. /** @hidden */
  63246. _left: ValueAndUnit;
  63247. /** @hidden */
  63248. _top: ValueAndUnit;
  63249. private _scaleX;
  63250. private _scaleY;
  63251. private _rotation;
  63252. private _transformCenterX;
  63253. private _transformCenterY;
  63254. /** @hidden */
  63255. _transformMatrix: Matrix2D;
  63256. /** @hidden */
  63257. protected _invertTransformMatrix: Matrix2D;
  63258. /** @hidden */
  63259. protected _transformedPosition: BABYLON.Vector2;
  63260. private _isMatrixDirty;
  63261. private _cachedOffsetX;
  63262. private _cachedOffsetY;
  63263. private _isVisible;
  63264. private _isHighlighted;
  63265. /** @hidden */
  63266. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63267. private _fontSet;
  63268. private _dummyVector2;
  63269. private _downCount;
  63270. private _enterCount;
  63271. private _doNotRender;
  63272. private _downPointerIds;
  63273. protected _isEnabled: boolean;
  63274. protected _disabledColor: string;
  63275. /** @hidden */
  63276. protected _rebuildLayout: boolean;
  63277. /** @hidden */
  63278. _isClipped: boolean;
  63279. /** @hidden */
  63280. _tag: any;
  63281. /**
  63282. * 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
  63283. */
  63284. uniqueId: number;
  63285. /**
  63286. * Gets or sets an object used to store user defined information for the node
  63287. */
  63288. metadata: any;
  63289. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63290. isHitTestVisible: boolean;
  63291. /** Gets or sets a boolean indicating if the control can block pointer events */
  63292. isPointerBlocker: boolean;
  63293. /** Gets or sets a boolean indicating if the control can be focusable */
  63294. isFocusInvisible: boolean;
  63295. /**
  63296. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63297. * 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
  63298. */
  63299. clipChildren: boolean;
  63300. /**
  63301. * Gets or sets a boolean indicating that control content must be clipped
  63302. * 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
  63303. */
  63304. clipContent: boolean;
  63305. /**
  63306. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63307. */
  63308. useBitmapCache: boolean;
  63309. private _cacheData;
  63310. private _shadowOffsetX;
  63311. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63312. shadowOffsetX: number;
  63313. private _shadowOffsetY;
  63314. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63315. shadowOffsetY: number;
  63316. private _shadowBlur;
  63317. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63318. shadowBlur: number;
  63319. private _shadowColor;
  63320. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63321. shadowColor: string;
  63322. /** Gets or sets the cursor to use when the control is hovered */
  63323. hoverCursor: string;
  63324. /** @hidden */
  63325. protected _linkOffsetX: ValueAndUnit;
  63326. /** @hidden */
  63327. protected _linkOffsetY: ValueAndUnit;
  63328. /** Gets the control type name */
  63329. readonly typeName: string;
  63330. /**
  63331. * Get the current class name of the control.
  63332. * @returns current class name
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * An event triggered when the pointer move over the control.
  63337. */
  63338. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63339. /**
  63340. * An event triggered when the pointer move out of the control.
  63341. */
  63342. onPointerOutObservable: BABYLON.Observable<Control>;
  63343. /**
  63344. * An event triggered when the pointer taps the control
  63345. */
  63346. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63347. /**
  63348. * An event triggered when pointer up
  63349. */
  63350. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63351. /**
  63352. * An event triggered when a control is clicked on
  63353. */
  63354. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63355. /**
  63356. * An event triggered when pointer enters the control
  63357. */
  63358. onPointerEnterObservable: BABYLON.Observable<Control>;
  63359. /**
  63360. * An event triggered when the control is marked as dirty
  63361. */
  63362. onDirtyObservable: BABYLON.Observable<Control>;
  63363. /**
  63364. * An event triggered before drawing the control
  63365. */
  63366. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63367. /**
  63368. * An event triggered after the control was drawn
  63369. */
  63370. onAfterDrawObservable: BABYLON.Observable<Control>;
  63371. /**
  63372. * Get the hosting AdvancedDynamicTexture
  63373. */
  63374. readonly host: AdvancedDynamicTexture;
  63375. /** Gets or set information about font offsets (used to render and align text) */
  63376. fontOffset: {
  63377. ascent: number;
  63378. height: number;
  63379. descent: number;
  63380. };
  63381. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63382. alpha: number;
  63383. /**
  63384. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63385. */
  63386. isHighlighted: boolean;
  63387. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63388. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63389. */
  63390. scaleX: number;
  63391. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63392. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63393. */
  63394. scaleY: number;
  63395. /** Gets or sets the rotation angle (0 by default)
  63396. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63397. */
  63398. rotation: number;
  63399. /** Gets or sets the transformation center on Y axis (0 by default)
  63400. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63401. */
  63402. transformCenterY: number;
  63403. /** Gets or sets the transformation center on X axis (0 by default)
  63404. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63405. */
  63406. transformCenterX: number;
  63407. /**
  63408. * Gets or sets the horizontal alignment
  63409. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63410. */
  63411. horizontalAlignment: number;
  63412. /**
  63413. * Gets or sets the vertical alignment
  63414. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63415. */
  63416. verticalAlignment: number;
  63417. /**
  63418. * Gets or sets control width
  63419. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63420. */
  63421. width: string | number;
  63422. /**
  63423. * Gets or sets the control width in pixel
  63424. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63425. */
  63426. widthInPixels: number;
  63427. /**
  63428. * Gets or sets control height
  63429. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63430. */
  63431. height: string | number;
  63432. /**
  63433. * Gets or sets control height in pixel
  63434. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63435. */
  63436. heightInPixels: number;
  63437. /** Gets or set font family */
  63438. fontFamily: string;
  63439. /** Gets or sets font style */
  63440. fontStyle: string;
  63441. /** Gets or sets font weight */
  63442. fontWeight: string;
  63443. /**
  63444. * Gets or sets style
  63445. * @see http://doc.babylonjs.com/how_to/gui#styles
  63446. */
  63447. style: BABYLON.Nullable<Style>;
  63448. /** @hidden */
  63449. readonly _isFontSizeInPercentage: boolean;
  63450. /** Gets or sets font size in pixels */
  63451. fontSizeInPixels: number;
  63452. /** Gets or sets font size */
  63453. fontSize: string | number;
  63454. /** Gets or sets foreground color */
  63455. color: string;
  63456. /** Gets or sets z index which is used to reorder controls on the z axis */
  63457. zIndex: number;
  63458. /** Gets or sets a boolean indicating if the control can be rendered */
  63459. notRenderable: boolean;
  63460. /** Gets or sets a boolean indicating if the control is visible */
  63461. isVisible: boolean;
  63462. /** Gets a boolean indicating that the control needs to update its rendering */
  63463. readonly isDirty: boolean;
  63464. /**
  63465. * Gets the current linked mesh (or null if none)
  63466. */
  63467. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63468. /**
  63469. * Gets or sets a value indicating the padding to use on the left of the control
  63470. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63471. */
  63472. paddingLeft: string | number;
  63473. /**
  63474. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63475. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63476. */
  63477. paddingLeftInPixels: number;
  63478. /**
  63479. * Gets or sets a value indicating the padding to use on the right of the control
  63480. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63481. */
  63482. paddingRight: string | number;
  63483. /**
  63484. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63485. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63486. */
  63487. paddingRightInPixels: number;
  63488. /**
  63489. * Gets or sets a value indicating the padding to use on the top of the control
  63490. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63491. */
  63492. paddingTop: string | number;
  63493. /**
  63494. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63495. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63496. */
  63497. paddingTopInPixels: number;
  63498. /**
  63499. * Gets or sets a value indicating the padding to use on the bottom of the control
  63500. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63501. */
  63502. paddingBottom: string | number;
  63503. /**
  63504. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63505. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63506. */
  63507. paddingBottomInPixels: number;
  63508. /**
  63509. * Gets or sets a value indicating the left coordinate of the control
  63510. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63511. */
  63512. left: string | number;
  63513. /**
  63514. * Gets or sets a value indicating the left coordinate in pixels of the control
  63515. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63516. */
  63517. leftInPixels: number;
  63518. /**
  63519. * Gets or sets a value indicating the top coordinate of the control
  63520. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63521. */
  63522. top: string | number;
  63523. /**
  63524. * Gets or sets a value indicating the top coordinate in pixels of the control
  63525. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63526. */
  63527. topInPixels: number;
  63528. /**
  63529. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63530. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63531. */
  63532. linkOffsetX: string | number;
  63533. /**
  63534. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63535. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63536. */
  63537. linkOffsetXInPixels: number;
  63538. /**
  63539. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63540. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63541. */
  63542. linkOffsetY: string | number;
  63543. /**
  63544. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63545. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63546. */
  63547. linkOffsetYInPixels: number;
  63548. /** Gets the center coordinate on X axis */
  63549. readonly centerX: number;
  63550. /** Gets the center coordinate on Y axis */
  63551. readonly centerY: number;
  63552. /** Gets or sets if control is Enabled*/
  63553. isEnabled: boolean;
  63554. /** Gets or sets background color of control if it's disabled*/
  63555. disabledColor: string;
  63556. /**
  63557. * Creates a new control
  63558. * @param name defines the name of the control
  63559. */
  63560. constructor(
  63561. /** defines the name of the control */
  63562. name?: string | undefined);
  63563. /** @hidden */
  63564. protected _getTypeName(): string;
  63565. /**
  63566. * Gets the first ascendant in the hierarchy of the given type
  63567. * @param className defines the required type
  63568. * @returns the ascendant or null if not found
  63569. */
  63570. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63571. /** @hidden */
  63572. _resetFontCache(): void;
  63573. /**
  63574. * Determines if a container is an ascendant of the current control
  63575. * @param container defines the container to look for
  63576. * @returns true if the container is one of the ascendant of the control
  63577. */
  63578. isAscendant(container: Control): boolean;
  63579. /**
  63580. * Gets coordinates in local control space
  63581. * @param globalCoordinates defines the coordinates to transform
  63582. * @returns the new coordinates in local space
  63583. */
  63584. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63585. /**
  63586. * Gets coordinates in local control space
  63587. * @param globalCoordinates defines the coordinates to transform
  63588. * @param result defines the target vector2 where to store the result
  63589. * @returns the current control
  63590. */
  63591. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63592. /**
  63593. * Gets coordinates in parent local control space
  63594. * @param globalCoordinates defines the coordinates to transform
  63595. * @returns the new coordinates in parent local space
  63596. */
  63597. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63598. /**
  63599. * Move the current control to a vector3 position projected onto the screen.
  63600. * @param position defines the target position
  63601. * @param scene defines the hosting scene
  63602. */
  63603. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63604. /** @hidden */
  63605. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63606. /**
  63607. * Will return all controls that have this control as ascendant
  63608. * @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
  63609. * @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
  63610. * @return all child controls
  63611. */
  63612. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63613. /**
  63614. * Link current control with a target mesh
  63615. * @param mesh defines the mesh to link with
  63616. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63617. */
  63618. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63619. /** @hidden */
  63620. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63621. /** @hidden */
  63622. _offsetLeft(offset: number): void;
  63623. /** @hidden */
  63624. _offsetTop(offset: number): void;
  63625. /** @hidden */
  63626. _markMatrixAsDirty(): void;
  63627. /** @hidden */
  63628. _flagDescendantsAsMatrixDirty(): void;
  63629. /** @hidden */
  63630. _intersectsRect(rect: Measure): boolean;
  63631. /** @hidden */
  63632. protected invalidateRect(): void;
  63633. /** @hidden */
  63634. _markAsDirty(force?: boolean): void;
  63635. /** @hidden */
  63636. _markAllAsDirty(): void;
  63637. /** @hidden */
  63638. _link(host: AdvancedDynamicTexture): void;
  63639. /** @hidden */
  63640. protected _transform(context?: CanvasRenderingContext2D): void;
  63641. /** @hidden */
  63642. _renderHighlight(context: CanvasRenderingContext2D): void;
  63643. /** @hidden */
  63644. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63645. /** @hidden */
  63646. protected _applyStates(context: CanvasRenderingContext2D): void;
  63647. /** @hidden */
  63648. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63649. /** @hidden */
  63650. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63651. protected _evaluateClippingState(parentMeasure: Measure): void;
  63652. /** @hidden */
  63653. _measure(): void;
  63654. /** @hidden */
  63655. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63656. /** @hidden */
  63657. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63658. /** @hidden */
  63659. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63660. /** @hidden */
  63661. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63662. private static _ClipMeasure;
  63663. private _tmpMeasureA;
  63664. private _clip;
  63665. /** @hidden */
  63666. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63667. /** @hidden */
  63668. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63669. /**
  63670. * Tests if a given coordinates belong to the current control
  63671. * @param x defines x coordinate to test
  63672. * @param y defines y coordinate to test
  63673. * @returns true if the coordinates are inside the control
  63674. */
  63675. contains(x: number, y: number): boolean;
  63676. /** @hidden */
  63677. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63678. /** @hidden */
  63679. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63680. /** @hidden */
  63681. _onPointerEnter(target: Control): boolean;
  63682. /** @hidden */
  63683. _onPointerOut(target: Control, force?: boolean): void;
  63684. /** @hidden */
  63685. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63686. /** @hidden */
  63687. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63688. /** @hidden */
  63689. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63690. /** @hidden */
  63691. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63692. private _prepareFont;
  63693. /** Releases associated resources */
  63694. dispose(): void;
  63695. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63696. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63697. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63698. private static _VERTICAL_ALIGNMENT_TOP;
  63699. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63700. private static _VERTICAL_ALIGNMENT_CENTER;
  63701. /** HORIZONTAL_ALIGNMENT_LEFT */
  63702. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63703. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63704. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63705. /** HORIZONTAL_ALIGNMENT_CENTER */
  63706. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63707. /** VERTICAL_ALIGNMENT_TOP */
  63708. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63709. /** VERTICAL_ALIGNMENT_BOTTOM */
  63710. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63711. /** VERTICAL_ALIGNMENT_CENTER */
  63712. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63713. private static _FontHeightSizes;
  63714. /** @hidden */
  63715. static _GetFontOffset(font: string): {
  63716. ascent: number;
  63717. height: number;
  63718. descent: number;
  63719. };
  63720. /**
  63721. * Creates a stack panel that can be used to render headers
  63722. * @param control defines the control to associate with the header
  63723. * @param text defines the text of the header
  63724. * @param size defines the size of the header
  63725. * @param options defines options used to configure the header
  63726. * @returns a new StackPanel
  63727. * @ignore
  63728. * @hidden
  63729. */
  63730. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63731. isHorizontal: boolean;
  63732. controlFirst: boolean;
  63733. }) => any;
  63734. /** @hidden */
  63735. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63736. }
  63737. }
  63738. declare module BABYLON.GUI {
  63739. /**
  63740. * Root class for 2D containers
  63741. * @see http://doc.babylonjs.com/how_to/gui#containers
  63742. */
  63743. export class Container extends Control {
  63744. name?: string | undefined;
  63745. /** @hidden */
  63746. protected _children: Control[];
  63747. /** @hidden */
  63748. protected _measureForChildren: Measure;
  63749. /** @hidden */
  63750. protected _background: string;
  63751. /** @hidden */
  63752. protected _adaptWidthToChildren: boolean;
  63753. /** @hidden */
  63754. protected _adaptHeightToChildren: boolean;
  63755. /**
  63756. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63757. */
  63758. logLayoutCycleErrors: boolean;
  63759. /**
  63760. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63761. */
  63762. maxLayoutCycle: number;
  63763. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63764. adaptHeightToChildren: boolean;
  63765. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63766. adaptWidthToChildren: boolean;
  63767. /** Gets or sets background color */
  63768. background: string;
  63769. /** Gets the list of children */
  63770. readonly children: Control[];
  63771. /**
  63772. * Creates a new Container
  63773. * @param name defines the name of the container
  63774. */
  63775. constructor(name?: string | undefined);
  63776. protected _getTypeName(): string;
  63777. _flagDescendantsAsMatrixDirty(): void;
  63778. /**
  63779. * Gets a child using its name
  63780. * @param name defines the child name to look for
  63781. * @returns the child control if found
  63782. */
  63783. getChildByName(name: string): BABYLON.Nullable<Control>;
  63784. /**
  63785. * Gets a child using its type and its name
  63786. * @param name defines the child name to look for
  63787. * @param type defines the child type to look for
  63788. * @returns the child control if found
  63789. */
  63790. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63791. /**
  63792. * Search for a specific control in children
  63793. * @param control defines the control to look for
  63794. * @returns true if the control is in child list
  63795. */
  63796. containsControl(control: Control): boolean;
  63797. /**
  63798. * Adds a new control to the current container
  63799. * @param control defines the control to add
  63800. * @returns the current container
  63801. */
  63802. addControl(control: BABYLON.Nullable<Control>): Container;
  63803. /**
  63804. * Removes all controls from the current container
  63805. * @returns the current container
  63806. */
  63807. clearControls(): Container;
  63808. /**
  63809. * Removes a control from the current container
  63810. * @param control defines the control to remove
  63811. * @returns the current container
  63812. */
  63813. removeControl(control: Control): Container;
  63814. /** @hidden */
  63815. _reOrderControl(control: Control): void;
  63816. /** @hidden */
  63817. _offsetLeft(offset: number): void;
  63818. /** @hidden */
  63819. _offsetTop(offset: number): void;
  63820. /** @hidden */
  63821. _markAllAsDirty(): void;
  63822. /** @hidden */
  63823. protected _localDraw(context: CanvasRenderingContext2D): void;
  63824. /** @hidden */
  63825. _link(host: AdvancedDynamicTexture): void;
  63826. /** @hidden */
  63827. protected _beforeLayout(): void;
  63828. /** @hidden */
  63829. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63830. /** @hidden */
  63831. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63832. protected _postMeasure(): void;
  63833. /** @hidden */
  63834. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63835. /** @hidden */
  63836. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63837. /** @hidden */
  63838. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63839. /** @hidden */
  63840. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63841. /** Releases associated resources */
  63842. dispose(): void;
  63843. }
  63844. }
  63845. declare module BABYLON.GUI {
  63846. /** Class used to create rectangle container */
  63847. export class Rectangle extends Container {
  63848. name?: string | undefined;
  63849. private _thickness;
  63850. private _cornerRadius;
  63851. /** Gets or sets border thickness */
  63852. thickness: number;
  63853. /** Gets or sets the corner radius angle */
  63854. cornerRadius: number;
  63855. /**
  63856. * Creates a new Rectangle
  63857. * @param name defines the control name
  63858. */
  63859. constructor(name?: string | undefined);
  63860. protected _getTypeName(): string;
  63861. protected _localDraw(context: CanvasRenderingContext2D): void;
  63862. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63863. private _drawRoundedRect;
  63864. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63865. }
  63866. }
  63867. declare module BABYLON.GUI {
  63868. /**
  63869. * Enum that determines the text-wrapping mode to use.
  63870. */
  63871. export enum TextWrapping {
  63872. /**
  63873. * Clip the text when it's larger than Control.width; this is the default mode.
  63874. */
  63875. Clip = 0,
  63876. /**
  63877. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63878. */
  63879. WordWrap = 1,
  63880. /**
  63881. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63882. */
  63883. Ellipsis = 2
  63884. }
  63885. /**
  63886. * Class used to create text block control
  63887. */
  63888. export class TextBlock extends Control {
  63889. /**
  63890. * Defines the name of the control
  63891. */
  63892. name?: string | undefined;
  63893. private _text;
  63894. private _textWrapping;
  63895. private _textHorizontalAlignment;
  63896. private _textVerticalAlignment;
  63897. private _lines;
  63898. private _resizeToFit;
  63899. private _lineSpacing;
  63900. private _outlineWidth;
  63901. private _outlineColor;
  63902. /**
  63903. * An event triggered after the text is changed
  63904. */
  63905. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63906. /**
  63907. * An event triggered after the text was broken up into lines
  63908. */
  63909. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63910. /**
  63911. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63912. */
  63913. readonly lines: any[];
  63914. /**
  63915. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63916. */
  63917. /**
  63918. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63919. */
  63920. resizeToFit: boolean;
  63921. /**
  63922. * Gets or sets a boolean indicating if text must be wrapped
  63923. */
  63924. /**
  63925. * Gets or sets a boolean indicating if text must be wrapped
  63926. */
  63927. textWrapping: TextWrapping | boolean;
  63928. /**
  63929. * Gets or sets text to display
  63930. */
  63931. /**
  63932. * Gets or sets text to display
  63933. */
  63934. text: string;
  63935. /**
  63936. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63937. */
  63938. /**
  63939. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63940. */
  63941. textHorizontalAlignment: number;
  63942. /**
  63943. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63944. */
  63945. /**
  63946. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63947. */
  63948. textVerticalAlignment: number;
  63949. /**
  63950. * Gets or sets line spacing value
  63951. */
  63952. /**
  63953. * Gets or sets line spacing value
  63954. */
  63955. lineSpacing: string | number;
  63956. /**
  63957. * Gets or sets outlineWidth of the text to display
  63958. */
  63959. /**
  63960. * Gets or sets outlineWidth of the text to display
  63961. */
  63962. outlineWidth: number;
  63963. /**
  63964. * Gets or sets outlineColor of the text to display
  63965. */
  63966. /**
  63967. * Gets or sets outlineColor of the text to display
  63968. */
  63969. outlineColor: string;
  63970. /**
  63971. * Creates a new TextBlock object
  63972. * @param name defines the name of the control
  63973. * @param text defines the text to display (emptry string by default)
  63974. */
  63975. constructor(
  63976. /**
  63977. * Defines the name of the control
  63978. */
  63979. name?: string | undefined, text?: string);
  63980. protected _getTypeName(): string;
  63981. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63982. private _drawText;
  63983. /** @hidden */
  63984. _draw(context: CanvasRenderingContext2D): void;
  63985. protected _applyStates(context: CanvasRenderingContext2D): void;
  63986. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63987. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63988. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63989. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63990. protected _renderLines(context: CanvasRenderingContext2D): void;
  63991. /**
  63992. * Given a width constraint applied on the text block, find the expected height
  63993. * @returns expected height
  63994. */
  63995. computeExpectedHeight(): number;
  63996. dispose(): void;
  63997. }
  63998. }
  63999. declare module BABYLON.GUI {
  64000. /**
  64001. * Class used to create 2D images
  64002. */
  64003. export class Image extends Control {
  64004. name?: string | undefined;
  64005. private static _WorkingCanvas;
  64006. private _domImage;
  64007. private _imageWidth;
  64008. private _imageHeight;
  64009. private _loaded;
  64010. private _stretch;
  64011. private _source;
  64012. private _autoScale;
  64013. private _sourceLeft;
  64014. private _sourceTop;
  64015. private _sourceWidth;
  64016. private _sourceHeight;
  64017. private _cellWidth;
  64018. private _cellHeight;
  64019. private _cellId;
  64020. private _populateNinePatchSlicesFromImage;
  64021. private _sliceLeft;
  64022. private _sliceRight;
  64023. private _sliceTop;
  64024. private _sliceBottom;
  64025. private _detectPointerOnOpaqueOnly;
  64026. /**
  64027. * BABYLON.Observable notified when the content is loaded
  64028. */
  64029. onImageLoadedObservable: BABYLON.Observable<Image>;
  64030. /**
  64031. * Gets a boolean indicating that the content is loaded
  64032. */
  64033. readonly isLoaded: boolean;
  64034. /**
  64035. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64036. */
  64037. populateNinePatchSlicesFromImage: boolean;
  64038. /**
  64039. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64040. * Beware using this as this will comsume more memory as the image has to be stored twice
  64041. */
  64042. detectPointerOnOpaqueOnly: boolean;
  64043. /**
  64044. * Gets or sets the left value for slicing (9-patch)
  64045. */
  64046. sliceLeft: number;
  64047. /**
  64048. * Gets or sets the right value for slicing (9-patch)
  64049. */
  64050. sliceRight: number;
  64051. /**
  64052. * Gets or sets the top value for slicing (9-patch)
  64053. */
  64054. sliceTop: number;
  64055. /**
  64056. * Gets or sets the bottom value for slicing (9-patch)
  64057. */
  64058. sliceBottom: number;
  64059. /**
  64060. * Gets or sets the left coordinate in the source image
  64061. */
  64062. sourceLeft: number;
  64063. /**
  64064. * Gets or sets the top coordinate in the source image
  64065. */
  64066. sourceTop: number;
  64067. /**
  64068. * Gets or sets the width to capture in the source image
  64069. */
  64070. sourceWidth: number;
  64071. /**
  64072. * Gets or sets the height to capture in the source image
  64073. */
  64074. sourceHeight: number;
  64075. /**
  64076. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64077. * @see http://doc.babylonjs.com/how_to/gui#image
  64078. */
  64079. autoScale: boolean;
  64080. /** Gets or sets the streching mode used by the image */
  64081. stretch: number;
  64082. /**
  64083. * Gets or sets the internal DOM image used to render the control
  64084. */
  64085. domImage: HTMLImageElement;
  64086. private _onImageLoaded;
  64087. private _extractNinePatchSliceDataFromImage;
  64088. /**
  64089. * Gets or sets image source url
  64090. */
  64091. source: BABYLON.Nullable<string>;
  64092. /**
  64093. * Gets or sets the cell width to use when animation sheet is enabled
  64094. * @see http://doc.babylonjs.com/how_to/gui#image
  64095. */
  64096. cellWidth: number;
  64097. /**
  64098. * Gets or sets the cell height to use when animation sheet is enabled
  64099. * @see http://doc.babylonjs.com/how_to/gui#image
  64100. */
  64101. cellHeight: number;
  64102. /**
  64103. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64104. * @see http://doc.babylonjs.com/how_to/gui#image
  64105. */
  64106. cellId: number;
  64107. /**
  64108. * Creates a new Image
  64109. * @param name defines the control name
  64110. * @param url defines the image url
  64111. */
  64112. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64113. /**
  64114. * Tests if a given coordinates belong to the current control
  64115. * @param x defines x coordinate to test
  64116. * @param y defines y coordinate to test
  64117. * @returns true if the coordinates are inside the control
  64118. */
  64119. contains(x: number, y: number): boolean;
  64120. protected _getTypeName(): string;
  64121. /** Force the control to synchronize with its content */
  64122. synchronizeSizeWithContent(): void;
  64123. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64124. private _prepareWorkingCanvasForOpaqueDetection;
  64125. private _drawImage;
  64126. _draw(context: CanvasRenderingContext2D): void;
  64127. private _renderCornerPatch;
  64128. private _renderNinePatch;
  64129. dispose(): void;
  64130. /** STRETCH_NONE */
  64131. static readonly STRETCH_NONE: number;
  64132. /** STRETCH_FILL */
  64133. static readonly STRETCH_FILL: number;
  64134. /** STRETCH_UNIFORM */
  64135. static readonly STRETCH_UNIFORM: number;
  64136. /** STRETCH_EXTEND */
  64137. static readonly STRETCH_EXTEND: number;
  64138. /** NINE_PATCH */
  64139. static readonly STRETCH_NINE_PATCH: number;
  64140. }
  64141. }
  64142. declare module BABYLON.GUI {
  64143. /**
  64144. * Class used to create 2D buttons
  64145. */
  64146. export class Button extends Rectangle {
  64147. name?: string | undefined;
  64148. /**
  64149. * Function called to generate a pointer enter animation
  64150. */
  64151. pointerEnterAnimation: () => void;
  64152. /**
  64153. * Function called to generate a pointer out animation
  64154. */
  64155. pointerOutAnimation: () => void;
  64156. /**
  64157. * Function called to generate a pointer down animation
  64158. */
  64159. pointerDownAnimation: () => void;
  64160. /**
  64161. * Function called to generate a pointer up animation
  64162. */
  64163. pointerUpAnimation: () => void;
  64164. /**
  64165. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64166. */
  64167. delegatePickingToChildren: boolean;
  64168. private _image;
  64169. /**
  64170. * Returns the image part of the button (if any)
  64171. */
  64172. readonly image: BABYLON.Nullable<Image>;
  64173. private _textBlock;
  64174. /**
  64175. * Returns the image part of the button (if any)
  64176. */
  64177. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64178. /**
  64179. * Creates a new Button
  64180. * @param name defines the name of the button
  64181. */
  64182. constructor(name?: string | undefined);
  64183. protected _getTypeName(): string;
  64184. /** @hidden */
  64185. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64186. /** @hidden */
  64187. _onPointerEnter(target: Control): boolean;
  64188. /** @hidden */
  64189. _onPointerOut(target: Control, force?: boolean): void;
  64190. /** @hidden */
  64191. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64192. /** @hidden */
  64193. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64194. /**
  64195. * Creates a new button made with an image and a text
  64196. * @param name defines the name of the button
  64197. * @param text defines the text of the button
  64198. * @param imageUrl defines the url of the image
  64199. * @returns a new Button
  64200. */
  64201. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64202. /**
  64203. * Creates a new button made with an image
  64204. * @param name defines the name of the button
  64205. * @param imageUrl defines the url of the image
  64206. * @returns a new Button
  64207. */
  64208. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64209. /**
  64210. * Creates a new button made with a text
  64211. * @param name defines the name of the button
  64212. * @param text defines the text of the button
  64213. * @returns a new Button
  64214. */
  64215. static CreateSimpleButton(name: string, text: string): Button;
  64216. /**
  64217. * Creates a new button made with an image and a centered text
  64218. * @param name defines the name of the button
  64219. * @param text defines the text of the button
  64220. * @param imageUrl defines the url of the image
  64221. * @returns a new Button
  64222. */
  64223. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64224. }
  64225. }
  64226. declare module BABYLON.GUI {
  64227. /**
  64228. * Class used to create a 2D stack panel container
  64229. */
  64230. export class StackPanel extends Container {
  64231. name?: string | undefined;
  64232. private _isVertical;
  64233. private _manualWidth;
  64234. private _manualHeight;
  64235. private _doNotTrackManualChanges;
  64236. /**
  64237. * Gets or sets a boolean indicating that layou warnings should be ignored
  64238. */
  64239. ignoreLayoutWarnings: boolean;
  64240. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64241. isVertical: boolean;
  64242. /**
  64243. * Gets or sets panel width.
  64244. * This value should not be set when in horizontal mode as it will be computed automatically
  64245. */
  64246. width: string | number;
  64247. /**
  64248. * Gets or sets panel height.
  64249. * This value should not be set when in vertical mode as it will be computed automatically
  64250. */
  64251. height: string | number;
  64252. /**
  64253. * Creates a new StackPanel
  64254. * @param name defines control name
  64255. */
  64256. constructor(name?: string | undefined);
  64257. protected _getTypeName(): string;
  64258. /** @hidden */
  64259. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64260. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64261. protected _postMeasure(): void;
  64262. }
  64263. }
  64264. declare module BABYLON.GUI {
  64265. /**
  64266. * Class used to represent a 2D checkbox
  64267. */
  64268. export class Checkbox extends Control {
  64269. name?: string | undefined;
  64270. private _isChecked;
  64271. private _background;
  64272. private _checkSizeRatio;
  64273. private _thickness;
  64274. /** Gets or sets border thickness */
  64275. thickness: number;
  64276. /**
  64277. * BABYLON.Observable raised when isChecked property changes
  64278. */
  64279. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64280. /** Gets or sets a value indicating the ratio between overall size and check size */
  64281. checkSizeRatio: number;
  64282. /** Gets or sets background color */
  64283. background: string;
  64284. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64285. isChecked: boolean;
  64286. /**
  64287. * Creates a new CheckBox
  64288. * @param name defines the control name
  64289. */
  64290. constructor(name?: string | undefined);
  64291. protected _getTypeName(): string;
  64292. /** @hidden */
  64293. _draw(context: CanvasRenderingContext2D): void;
  64294. /** @hidden */
  64295. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64296. /**
  64297. * Utility function to easily create a checkbox with a header
  64298. * @param title defines the label to use for the header
  64299. * @param onValueChanged defines the callback to call when value changes
  64300. * @returns a StackPanel containing the checkbox and a textBlock
  64301. */
  64302. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64303. }
  64304. }
  64305. declare module BABYLON.GUI {
  64306. /**
  64307. * Class used to store key control properties
  64308. */
  64309. export class KeyPropertySet {
  64310. /** Width */
  64311. width?: string;
  64312. /** Height */
  64313. height?: string;
  64314. /** Left padding */
  64315. paddingLeft?: string;
  64316. /** Right padding */
  64317. paddingRight?: string;
  64318. /** Top padding */
  64319. paddingTop?: string;
  64320. /** Bottom padding */
  64321. paddingBottom?: string;
  64322. /** Foreground color */
  64323. color?: string;
  64324. /** Background color */
  64325. background?: string;
  64326. }
  64327. /**
  64328. * Class used to create virtual keyboard
  64329. */
  64330. export class VirtualKeyboard extends StackPanel {
  64331. /** BABYLON.Observable raised when a key is pressed */
  64332. onKeyPressObservable: BABYLON.Observable<string>;
  64333. /** Gets or sets default key button width */
  64334. defaultButtonWidth: string;
  64335. /** Gets or sets default key button height */
  64336. defaultButtonHeight: string;
  64337. /** Gets or sets default key button left padding */
  64338. defaultButtonPaddingLeft: string;
  64339. /** Gets or sets default key button right padding */
  64340. defaultButtonPaddingRight: string;
  64341. /** Gets or sets default key button top padding */
  64342. defaultButtonPaddingTop: string;
  64343. /** Gets or sets default key button bottom padding */
  64344. defaultButtonPaddingBottom: string;
  64345. /** Gets or sets default key button foreground color */
  64346. defaultButtonColor: string;
  64347. /** Gets or sets default key button background color */
  64348. defaultButtonBackground: string;
  64349. /** Gets or sets shift button foreground color */
  64350. shiftButtonColor: string;
  64351. /** Gets or sets shift button thickness*/
  64352. selectedShiftThickness: number;
  64353. /** Gets shift key state */
  64354. shiftState: number;
  64355. protected _getTypeName(): string;
  64356. private _createKey;
  64357. /**
  64358. * Adds a new row of keys
  64359. * @param keys defines the list of keys to add
  64360. * @param propertySets defines the associated property sets
  64361. */
  64362. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64363. /**
  64364. * Set the shift key to a specific state
  64365. * @param shiftState defines the new shift state
  64366. */
  64367. applyShiftState(shiftState: number): void;
  64368. private _currentlyConnectedInputText;
  64369. private _connectedInputTexts;
  64370. private _onKeyPressObserver;
  64371. /** Gets the input text control currently attached to the keyboard */
  64372. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64373. /**
  64374. * Connects the keyboard with an input text control
  64375. *
  64376. * @param input defines the target control
  64377. */
  64378. connect(input: InputText): void;
  64379. /**
  64380. * Disconnects the keyboard from connected InputText controls
  64381. *
  64382. * @param input optionally defines a target control, otherwise all are disconnected
  64383. */
  64384. disconnect(input?: InputText): void;
  64385. private _removeConnectedInputObservables;
  64386. /**
  64387. * Release all resources
  64388. */
  64389. dispose(): void;
  64390. /**
  64391. * Creates a new keyboard using a default layout
  64392. *
  64393. * @param name defines control name
  64394. * @returns a new VirtualKeyboard
  64395. */
  64396. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64397. }
  64398. }
  64399. declare module BABYLON.GUI {
  64400. /**
  64401. * Class used to create input text control
  64402. */
  64403. export class InputText extends Control implements IFocusableControl {
  64404. name?: string | undefined;
  64405. private _text;
  64406. private _placeholderText;
  64407. private _background;
  64408. private _focusedBackground;
  64409. private _focusedColor;
  64410. private _placeholderColor;
  64411. private _thickness;
  64412. private _margin;
  64413. private _autoStretchWidth;
  64414. private _maxWidth;
  64415. private _isFocused;
  64416. private _blinkTimeout;
  64417. private _blinkIsEven;
  64418. private _cursorOffset;
  64419. private _scrollLeft;
  64420. private _textWidth;
  64421. private _clickedCoordinate;
  64422. private _deadKey;
  64423. private _addKey;
  64424. private _currentKey;
  64425. private _isTextHighlightOn;
  64426. private _textHighlightColor;
  64427. private _highligherOpacity;
  64428. private _highlightedText;
  64429. private _startHighlightIndex;
  64430. private _endHighlightIndex;
  64431. private _cursorIndex;
  64432. private _onFocusSelectAll;
  64433. private _isPointerDown;
  64434. private _onClipboardObserver;
  64435. private _onPointerDblTapObserver;
  64436. /** @hidden */
  64437. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64438. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64439. promptMessage: string;
  64440. /** Force disable prompt on mobile device */
  64441. disableMobilePrompt: boolean;
  64442. /** BABYLON.Observable raised when the text changes */
  64443. onTextChangedObservable: BABYLON.Observable<InputText>;
  64444. /** BABYLON.Observable raised just before an entered character is to be added */
  64445. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64446. /** BABYLON.Observable raised when the control gets the focus */
  64447. onFocusObservable: BABYLON.Observable<InputText>;
  64448. /** BABYLON.Observable raised when the control loses the focus */
  64449. onBlurObservable: BABYLON.Observable<InputText>;
  64450. /**Observable raised when the text is highlighted */
  64451. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64452. /**Observable raised when copy event is triggered */
  64453. onTextCopyObservable: BABYLON.Observable<InputText>;
  64454. /** BABYLON.Observable raised when cut event is triggered */
  64455. onTextCutObservable: BABYLON.Observable<InputText>;
  64456. /** BABYLON.Observable raised when paste event is triggered */
  64457. onTextPasteObservable: BABYLON.Observable<InputText>;
  64458. /** BABYLON.Observable raised when a key event was processed */
  64459. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64460. /** Gets or sets the maximum width allowed by the control */
  64461. maxWidth: string | number;
  64462. /** Gets the maximum width allowed by the control in pixels */
  64463. readonly maxWidthInPixels: number;
  64464. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64465. highligherOpacity: number;
  64466. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64467. onFocusSelectAll: boolean;
  64468. /** Gets or sets the text hightlight color */
  64469. textHighlightColor: string;
  64470. /** Gets or sets control margin */
  64471. margin: string;
  64472. /** Gets control margin in pixels */
  64473. readonly marginInPixels: number;
  64474. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64475. autoStretchWidth: boolean;
  64476. /** Gets or sets border thickness */
  64477. thickness: number;
  64478. /** Gets or sets the background color when focused */
  64479. focusedBackground: string;
  64480. /** Gets or sets the background color when focused */
  64481. focusedColor: string;
  64482. /** Gets or sets the background color */
  64483. background: string;
  64484. /** Gets or sets the placeholder color */
  64485. placeholderColor: string;
  64486. /** Gets or sets the text displayed when the control is empty */
  64487. placeholderText: string;
  64488. /** Gets or sets the dead key flag */
  64489. deadKey: boolean;
  64490. /** Gets or sets the highlight text */
  64491. highlightedText: string;
  64492. /** Gets or sets if the current key should be added */
  64493. addKey: boolean;
  64494. /** Gets or sets the value of the current key being entered */
  64495. currentKey: string;
  64496. /** Gets or sets the text displayed in the control */
  64497. text: string;
  64498. /** Gets or sets control width */
  64499. width: string | number;
  64500. /**
  64501. * Creates a new InputText
  64502. * @param name defines the control name
  64503. * @param text defines the text of the control
  64504. */
  64505. constructor(name?: string | undefined, text?: string);
  64506. /** @hidden */
  64507. onBlur(): void;
  64508. /** @hidden */
  64509. onFocus(): void;
  64510. protected _getTypeName(): string;
  64511. /**
  64512. * Function called to get the list of controls that should not steal the focus from this control
  64513. * @returns an array of controls
  64514. */
  64515. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64516. /** @hidden */
  64517. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64518. /** @hidden */
  64519. private _updateValueFromCursorIndex;
  64520. /** @hidden */
  64521. private _processDblClick;
  64522. /** @hidden */
  64523. private _selectAllText;
  64524. /**
  64525. * Handles the keyboard event
  64526. * @param evt Defines the KeyboardEvent
  64527. */
  64528. processKeyboard(evt: KeyboardEvent): void;
  64529. /** @hidden */
  64530. private _onCopyText;
  64531. /** @hidden */
  64532. private _onCutText;
  64533. /** @hidden */
  64534. private _onPasteText;
  64535. _draw(context: CanvasRenderingContext2D): void;
  64536. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64537. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64538. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64539. protected _beforeRenderText(text: string): string;
  64540. dispose(): void;
  64541. }
  64542. }
  64543. declare module BABYLON.GUI {
  64544. /**
  64545. * Class used to create a 2D grid container
  64546. */
  64547. export class Grid extends Container {
  64548. name?: string | undefined;
  64549. private _rowDefinitions;
  64550. private _columnDefinitions;
  64551. private _cells;
  64552. private _childControls;
  64553. /**
  64554. * Gets the number of columns
  64555. */
  64556. readonly columnCount: number;
  64557. /**
  64558. * Gets the number of rows
  64559. */
  64560. readonly rowCount: number;
  64561. /** Gets the list of children */
  64562. readonly children: Control[];
  64563. /** Gets the list of cells (e.g. the containers) */
  64564. readonly cells: {
  64565. [key: string]: Container;
  64566. };
  64567. /**
  64568. * Gets the definition of a specific row
  64569. * @param index defines the index of the row
  64570. * @returns the row definition
  64571. */
  64572. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64573. /**
  64574. * Gets the definition of a specific column
  64575. * @param index defines the index of the column
  64576. * @returns the column definition
  64577. */
  64578. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64579. /**
  64580. * Adds a new row to the grid
  64581. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64582. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64583. * @returns the current grid
  64584. */
  64585. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64586. /**
  64587. * Adds a new column to the grid
  64588. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64589. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64590. * @returns the current grid
  64591. */
  64592. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64593. /**
  64594. * Update a row definition
  64595. * @param index defines the index of the row to update
  64596. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64597. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64598. * @returns the current grid
  64599. */
  64600. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64601. /**
  64602. * Update a column definition
  64603. * @param index defines the index of the column to update
  64604. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64605. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64606. * @returns the current grid
  64607. */
  64608. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64609. /**
  64610. * Gets the list of children stored in a specific cell
  64611. * @param row defines the row to check
  64612. * @param column defines the column to check
  64613. * @returns the list of controls
  64614. */
  64615. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64616. /**
  64617. * Gets a string representing the child cell info (row x column)
  64618. * @param child defines the control to get info from
  64619. * @returns a string containing the child cell info (row x column)
  64620. */
  64621. getChildCellInfo(child: Control): string;
  64622. private _removeCell;
  64623. private _offsetCell;
  64624. /**
  64625. * Remove a column definition at specified index
  64626. * @param index defines the index of the column to remove
  64627. * @returns the current grid
  64628. */
  64629. removeColumnDefinition(index: number): Grid;
  64630. /**
  64631. * Remove a row definition at specified index
  64632. * @param index defines the index of the row to remove
  64633. * @returns the current grid
  64634. */
  64635. removeRowDefinition(index: number): Grid;
  64636. /**
  64637. * Adds a new control to the current grid
  64638. * @param control defines the control to add
  64639. * @param row defines the row where to add the control (0 by default)
  64640. * @param column defines the column where to add the control (0 by default)
  64641. * @returns the current grid
  64642. */
  64643. addControl(control: Control, row?: number, column?: number): Grid;
  64644. /**
  64645. * Removes a control from the current container
  64646. * @param control defines the control to remove
  64647. * @returns the current container
  64648. */
  64649. removeControl(control: Control): Container;
  64650. /**
  64651. * Creates a new Grid
  64652. * @param name defines control name
  64653. */
  64654. constructor(name?: string | undefined);
  64655. protected _getTypeName(): string;
  64656. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64657. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64658. _flagDescendantsAsMatrixDirty(): void;
  64659. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64660. /** Releases associated resources */
  64661. dispose(): void;
  64662. }
  64663. }
  64664. declare module BABYLON.GUI {
  64665. /** Class used to create color pickers */
  64666. export class ColorPicker extends Control {
  64667. name?: string | undefined;
  64668. private static _Epsilon;
  64669. private _colorWheelCanvas;
  64670. private _value;
  64671. private _tmpColor;
  64672. private _pointerStartedOnSquare;
  64673. private _pointerStartedOnWheel;
  64674. private _squareLeft;
  64675. private _squareTop;
  64676. private _squareSize;
  64677. private _h;
  64678. private _s;
  64679. private _v;
  64680. private _lastPointerDownID;
  64681. /**
  64682. * BABYLON.Observable raised when the value changes
  64683. */
  64684. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64685. /** Gets or sets the color of the color picker */
  64686. value: BABYLON.Color3;
  64687. /**
  64688. * Gets or sets control width
  64689. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64690. */
  64691. width: string | number;
  64692. /**
  64693. * Gets or sets control height
  64694. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64695. */
  64696. /** Gets or sets control height */
  64697. height: string | number;
  64698. /** Gets or sets control size */
  64699. size: string | number;
  64700. /**
  64701. * Creates a new ColorPicker
  64702. * @param name defines the control name
  64703. */
  64704. constructor(name?: string | undefined);
  64705. protected _getTypeName(): string;
  64706. /** @hidden */
  64707. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64708. private _updateSquareProps;
  64709. private _drawGradientSquare;
  64710. private _drawCircle;
  64711. private _createColorWheelCanvas;
  64712. /** @hidden */
  64713. _draw(context: CanvasRenderingContext2D): void;
  64714. private _pointerIsDown;
  64715. private _updateValueFromPointer;
  64716. private _isPointOnSquare;
  64717. private _isPointOnWheel;
  64718. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64719. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64720. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64721. /**
  64722. * This function expands the color picker by creating a color picker dialog with manual
  64723. * color value input and the ability to save colors into an array to be used later in
  64724. * subsequent launches of the dialogue.
  64725. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64726. * @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.
  64727. * @returns picked color as a hex string and the saved colors array as hex strings.
  64728. */
  64729. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64730. pickerWidth?: string;
  64731. pickerHeight?: string;
  64732. headerHeight?: string;
  64733. lastColor?: string;
  64734. swatchLimit?: number;
  64735. numSwatchesPerLine?: number;
  64736. savedColors?: Array<string>;
  64737. }): Promise<{
  64738. savedColors?: string[];
  64739. pickedColor: string;
  64740. }>;
  64741. }
  64742. }
  64743. declare module BABYLON.GUI {
  64744. /** Class used to create 2D ellipse containers */
  64745. export class Ellipse extends Container {
  64746. name?: string | undefined;
  64747. private _thickness;
  64748. /** Gets or sets border thickness */
  64749. thickness: number;
  64750. /**
  64751. * Creates a new Ellipse
  64752. * @param name defines the control name
  64753. */
  64754. constructor(name?: string | undefined);
  64755. protected _getTypeName(): string;
  64756. protected _localDraw(context: CanvasRenderingContext2D): void;
  64757. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64758. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64759. }
  64760. }
  64761. declare module BABYLON.GUI {
  64762. /**
  64763. * Class used to create a password control
  64764. */
  64765. export class InputPassword extends InputText {
  64766. protected _beforeRenderText(text: string): string;
  64767. }
  64768. }
  64769. declare module BABYLON.GUI {
  64770. /** Class used to render 2D lines */
  64771. export class Line extends Control {
  64772. name?: string | undefined;
  64773. private _lineWidth;
  64774. private _x1;
  64775. private _y1;
  64776. private _x2;
  64777. private _y2;
  64778. private _dash;
  64779. private _connectedControl;
  64780. private _connectedControlDirtyObserver;
  64781. /** Gets or sets the dash pattern */
  64782. dash: Array<number>;
  64783. /** Gets or sets the control connected with the line end */
  64784. connectedControl: Control;
  64785. /** Gets or sets start coordinates on X axis */
  64786. x1: string | number;
  64787. /** Gets or sets start coordinates on Y axis */
  64788. y1: string | number;
  64789. /** Gets or sets end coordinates on X axis */
  64790. x2: string | number;
  64791. /** Gets or sets end coordinates on Y axis */
  64792. y2: string | number;
  64793. /** Gets or sets line width */
  64794. lineWidth: number;
  64795. /** Gets or sets horizontal alignment */
  64796. horizontalAlignment: number;
  64797. /** Gets or sets vertical alignment */
  64798. verticalAlignment: number;
  64799. private readonly _effectiveX2;
  64800. private readonly _effectiveY2;
  64801. /**
  64802. * Creates a new Line
  64803. * @param name defines the control name
  64804. */
  64805. constructor(name?: string | undefined);
  64806. protected _getTypeName(): string;
  64807. _draw(context: CanvasRenderingContext2D): void;
  64808. _measure(): void;
  64809. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64810. /**
  64811. * Move one end of the line given 3D cartesian coordinates.
  64812. * @param position Targeted world position
  64813. * @param scene BABYLON.Scene
  64814. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64815. */
  64816. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64817. /**
  64818. * Move one end of the line to a position in screen absolute space.
  64819. * @param projectedPosition Position in screen absolute space (X, Y)
  64820. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64821. */
  64822. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64823. }
  64824. }
  64825. declare module BABYLON.GUI {
  64826. /**
  64827. * Class used to store a point for a MultiLine object.
  64828. * The point can be pure 2D coordinates, a mesh or a control
  64829. */
  64830. export class MultiLinePoint {
  64831. private _multiLine;
  64832. private _x;
  64833. private _y;
  64834. private _control;
  64835. private _mesh;
  64836. private _controlObserver;
  64837. private _meshObserver;
  64838. /** @hidden */
  64839. _point: BABYLON.Vector2;
  64840. /**
  64841. * Creates a new MultiLinePoint
  64842. * @param multiLine defines the source MultiLine object
  64843. */
  64844. constructor(multiLine: MultiLine);
  64845. /** Gets or sets x coordinate */
  64846. x: string | number;
  64847. /** Gets or sets y coordinate */
  64848. y: string | number;
  64849. /** Gets or sets the control associated with this point */
  64850. control: BABYLON.Nullable<Control>;
  64851. /** Gets or sets the mesh associated with this point */
  64852. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64853. /** Resets links */
  64854. resetLinks(): void;
  64855. /**
  64856. * Gets a translation vector
  64857. * @returns the translation vector
  64858. */
  64859. translate(): BABYLON.Vector2;
  64860. private _translatePoint;
  64861. /** Release associated resources */
  64862. dispose(): void;
  64863. }
  64864. }
  64865. declare module BABYLON.GUI {
  64866. /**
  64867. * Class used to create multi line control
  64868. */
  64869. export class MultiLine extends Control {
  64870. name?: string | undefined;
  64871. private _lineWidth;
  64872. private _dash;
  64873. private _points;
  64874. private _minX;
  64875. private _minY;
  64876. private _maxX;
  64877. private _maxY;
  64878. /**
  64879. * Creates a new MultiLine
  64880. * @param name defines the control name
  64881. */
  64882. constructor(name?: string | undefined);
  64883. /** Gets or sets dash pattern */
  64884. dash: Array<number>;
  64885. /**
  64886. * Gets point stored at specified index
  64887. * @param index defines the index to look for
  64888. * @returns the requested point if found
  64889. */
  64890. getAt(index: number): MultiLinePoint;
  64891. /** Function called when a point is updated */
  64892. onPointUpdate: () => void;
  64893. /**
  64894. * Adds new points to the point collection
  64895. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64896. * @returns the list of created MultiLinePoint
  64897. */
  64898. add(...items: (AbstractMesh | Control | {
  64899. x: string | number;
  64900. y: string | number;
  64901. })[]): MultiLinePoint[];
  64902. /**
  64903. * Adds a new point to the point collection
  64904. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64905. * @returns the created MultiLinePoint
  64906. */
  64907. push(item?: (AbstractMesh | Control | {
  64908. x: string | number;
  64909. y: string | number;
  64910. })): MultiLinePoint;
  64911. /**
  64912. * Remove a specific value or point from the active point collection
  64913. * @param value defines the value or point to remove
  64914. */
  64915. remove(value: number | MultiLinePoint): void;
  64916. /**
  64917. * Resets this object to initial state (no point)
  64918. */
  64919. reset(): void;
  64920. /**
  64921. * Resets all links
  64922. */
  64923. resetLinks(): void;
  64924. /** Gets or sets line width */
  64925. lineWidth: number;
  64926. horizontalAlignment: number;
  64927. verticalAlignment: number;
  64928. protected _getTypeName(): string;
  64929. _draw(context: CanvasRenderingContext2D): void;
  64930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64931. _measure(): void;
  64932. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64933. dispose(): void;
  64934. }
  64935. }
  64936. declare module BABYLON.GUI {
  64937. /**
  64938. * Class used to create radio button controls
  64939. */
  64940. export class RadioButton extends Control {
  64941. name?: string | undefined;
  64942. private _isChecked;
  64943. private _background;
  64944. private _checkSizeRatio;
  64945. private _thickness;
  64946. /** Gets or sets border thickness */
  64947. thickness: number;
  64948. /** Gets or sets group name */
  64949. group: string;
  64950. /** BABYLON.Observable raised when isChecked is changed */
  64951. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64952. /** Gets or sets a value indicating the ratio between overall size and check size */
  64953. checkSizeRatio: number;
  64954. /** Gets or sets background color */
  64955. background: string;
  64956. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64957. isChecked: boolean;
  64958. /**
  64959. * Creates a new RadioButton
  64960. * @param name defines the control name
  64961. */
  64962. constructor(name?: string | undefined);
  64963. protected _getTypeName(): string;
  64964. _draw(context: CanvasRenderingContext2D): void;
  64965. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64966. /**
  64967. * Utility function to easily create a radio button with a header
  64968. * @param title defines the label to use for the header
  64969. * @param group defines the group to use for the radio button
  64970. * @param isChecked defines the initial state of the radio button
  64971. * @param onValueChanged defines the callback to call when value changes
  64972. * @returns a StackPanel containing the radio button and a textBlock
  64973. */
  64974. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64975. }
  64976. }
  64977. declare module BABYLON.GUI {
  64978. /**
  64979. * Class used to create slider controls
  64980. */
  64981. export class BaseSlider extends Control {
  64982. name?: string | undefined;
  64983. protected _thumbWidth: ValueAndUnit;
  64984. private _minimum;
  64985. private _maximum;
  64986. private _value;
  64987. private _isVertical;
  64988. protected _barOffset: ValueAndUnit;
  64989. private _isThumbClamped;
  64990. protected _displayThumb: boolean;
  64991. private _step;
  64992. private _lastPointerDownID;
  64993. protected _effectiveBarOffset: number;
  64994. protected _renderLeft: number;
  64995. protected _renderTop: number;
  64996. protected _renderWidth: number;
  64997. protected _renderHeight: number;
  64998. protected _backgroundBoxLength: number;
  64999. protected _backgroundBoxThickness: number;
  65000. protected _effectiveThumbThickness: number;
  65001. /** BABYLON.Observable raised when the sldier value changes */
  65002. onValueChangedObservable: BABYLON.Observable<number>;
  65003. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65004. displayThumb: boolean;
  65005. /** Gets or sets a step to apply to values (0 by default) */
  65006. step: number;
  65007. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65008. barOffset: string | number;
  65009. /** Gets main bar offset in pixels*/
  65010. readonly barOffsetInPixels: number;
  65011. /** Gets or sets thumb width */
  65012. thumbWidth: string | number;
  65013. /** Gets thumb width in pixels */
  65014. readonly thumbWidthInPixels: number;
  65015. /** Gets or sets minimum value */
  65016. minimum: number;
  65017. /** Gets or sets maximum value */
  65018. maximum: number;
  65019. /** Gets or sets current value */
  65020. value: number;
  65021. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65022. isVertical: boolean;
  65023. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65024. isThumbClamped: boolean;
  65025. /**
  65026. * Creates a new BaseSlider
  65027. * @param name defines the control name
  65028. */
  65029. constructor(name?: string | undefined);
  65030. protected _getTypeName(): string;
  65031. protected _getThumbPosition(): number;
  65032. protected _getThumbThickness(type: string): number;
  65033. protected _prepareRenderingData(type: string): void;
  65034. private _pointerIsDown;
  65035. /** @hidden */
  65036. protected _updateValueFromPointer(x: number, y: number): void;
  65037. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65038. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65039. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65040. }
  65041. }
  65042. declare module BABYLON.GUI {
  65043. /**
  65044. * Class used to create slider controls
  65045. */
  65046. export class Slider extends BaseSlider {
  65047. name?: string | undefined;
  65048. private _background;
  65049. private _borderColor;
  65050. private _isThumbCircle;
  65051. protected _displayValueBar: boolean;
  65052. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65053. displayValueBar: boolean;
  65054. /** Gets or sets border color */
  65055. borderColor: string;
  65056. /** Gets or sets background color */
  65057. background: string;
  65058. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65059. isThumbCircle: boolean;
  65060. /**
  65061. * Creates a new Slider
  65062. * @param name defines the control name
  65063. */
  65064. constructor(name?: string | undefined);
  65065. protected _getTypeName(): string;
  65066. _draw(context: CanvasRenderingContext2D): void;
  65067. }
  65068. }
  65069. declare module BABYLON.GUI {
  65070. /** Class used to create a RadioGroup
  65071. * which contains groups of radio buttons
  65072. */
  65073. export class SelectorGroup {
  65074. /** name of SelectorGroup */
  65075. name: string;
  65076. private _groupPanel;
  65077. private _selectors;
  65078. private _groupHeader;
  65079. /**
  65080. * Creates a new SelectorGroup
  65081. * @param name of group, used as a group heading
  65082. */
  65083. constructor(
  65084. /** name of SelectorGroup */
  65085. name: string);
  65086. /** Gets the groupPanel of the SelectorGroup */
  65087. readonly groupPanel: StackPanel;
  65088. /** Gets the selectors array */
  65089. readonly selectors: StackPanel[];
  65090. /** Gets and sets the group header */
  65091. header: string;
  65092. /** @hidden */
  65093. private _addGroupHeader;
  65094. /** @hidden*/
  65095. _getSelector(selectorNb: number): StackPanel | undefined;
  65096. /** Removes the selector at the given position
  65097. * @param selectorNb the position of the selector within the group
  65098. */
  65099. removeSelector(selectorNb: number): void;
  65100. }
  65101. /** Class used to create a CheckboxGroup
  65102. * which contains groups of checkbox buttons
  65103. */
  65104. export class CheckboxGroup extends SelectorGroup {
  65105. /** Adds a checkbox as a control
  65106. * @param text is the label for the selector
  65107. * @param func is the function called when the Selector is checked
  65108. * @param checked is true when Selector is checked
  65109. */
  65110. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65111. /** @hidden */
  65112. _setSelectorLabel(selectorNb: number, label: string): void;
  65113. /** @hidden */
  65114. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65115. /** @hidden */
  65116. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65117. /** @hidden */
  65118. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65119. }
  65120. /** Class used to create a RadioGroup
  65121. * which contains groups of radio buttons
  65122. */
  65123. export class RadioGroup extends SelectorGroup {
  65124. private _selectNb;
  65125. /** Adds a radio button as a control
  65126. * @param label is the label for the selector
  65127. * @param func is the function called when the Selector is checked
  65128. * @param checked is true when Selector is checked
  65129. */
  65130. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65131. /** @hidden */
  65132. _setSelectorLabel(selectorNb: number, label: string): void;
  65133. /** @hidden */
  65134. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65135. /** @hidden */
  65136. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65137. /** @hidden */
  65138. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65139. }
  65140. /** Class used to create a SliderGroup
  65141. * which contains groups of slider buttons
  65142. */
  65143. export class SliderGroup extends SelectorGroup {
  65144. /**
  65145. * Adds a slider to the SelectorGroup
  65146. * @param label is the label for the SliderBar
  65147. * @param func is the function called when the Slider moves
  65148. * @param unit is a string describing the units used, eg degrees or metres
  65149. * @param min is the minimum value for the Slider
  65150. * @param max is the maximum value for the Slider
  65151. * @param value is the start value for the Slider between min and max
  65152. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65153. */
  65154. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65155. /** @hidden */
  65156. _setSelectorLabel(selectorNb: number, label: string): void;
  65157. /** @hidden */
  65158. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65159. /** @hidden */
  65160. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65161. /** @hidden */
  65162. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65163. }
  65164. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65165. * @see http://doc.babylonjs.com/how_to/selector
  65166. */
  65167. export class SelectionPanel extends Rectangle {
  65168. /** name of SelectionPanel */
  65169. name: string;
  65170. /** an array of SelectionGroups */
  65171. groups: SelectorGroup[];
  65172. private _panel;
  65173. private _buttonColor;
  65174. private _buttonBackground;
  65175. private _headerColor;
  65176. private _barColor;
  65177. private _barHeight;
  65178. private _spacerHeight;
  65179. private _labelColor;
  65180. private _groups;
  65181. private _bars;
  65182. /**
  65183. * Creates a new SelectionPanel
  65184. * @param name of SelectionPanel
  65185. * @param groups is an array of SelectionGroups
  65186. */
  65187. constructor(
  65188. /** name of SelectionPanel */
  65189. name: string,
  65190. /** an array of SelectionGroups */
  65191. groups?: SelectorGroup[]);
  65192. protected _getTypeName(): string;
  65193. /** Gets or sets the headerColor */
  65194. headerColor: string;
  65195. private _setHeaderColor;
  65196. /** Gets or sets the button color */
  65197. buttonColor: string;
  65198. private _setbuttonColor;
  65199. /** Gets or sets the label color */
  65200. labelColor: string;
  65201. private _setLabelColor;
  65202. /** Gets or sets the button background */
  65203. buttonBackground: string;
  65204. private _setButtonBackground;
  65205. /** Gets or sets the color of separator bar */
  65206. barColor: string;
  65207. private _setBarColor;
  65208. /** Gets or sets the height of separator bar */
  65209. barHeight: string;
  65210. private _setBarHeight;
  65211. /** Gets or sets the height of spacers*/
  65212. spacerHeight: string;
  65213. private _setSpacerHeight;
  65214. /** Adds a bar between groups */
  65215. private _addSpacer;
  65216. /** Add a group to the selection panel
  65217. * @param group is the selector group to add
  65218. */
  65219. addGroup(group: SelectorGroup): void;
  65220. /** Remove the group from the given position
  65221. * @param groupNb is the position of the group in the list
  65222. */
  65223. removeGroup(groupNb: number): void;
  65224. /** Change a group header label
  65225. * @param label is the new group header label
  65226. * @param groupNb is the number of the group to relabel
  65227. * */
  65228. setHeaderName(label: string, groupNb: number): void;
  65229. /** Change selector label to the one given
  65230. * @param label is the new selector label
  65231. * @param groupNb is the number of the groupcontaining the selector
  65232. * @param selectorNb is the number of the selector within a group to relabel
  65233. * */
  65234. relabel(label: string, groupNb: number, selectorNb: number): void;
  65235. /** For a given group position remove the selector at the given position
  65236. * @param groupNb is the number of the group to remove the selector from
  65237. * @param selectorNb is the number of the selector within the group
  65238. */
  65239. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65240. /** For a given group position of correct type add a checkbox button
  65241. * @param groupNb is the number of the group to remove the selector from
  65242. * @param label is the label for the selector
  65243. * @param func is the function called when the Selector is checked
  65244. * @param checked is true when Selector is checked
  65245. */
  65246. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65247. /** For a given group position of correct type add a radio button
  65248. * @param groupNb is the number of the group to remove the selector from
  65249. * @param label is the label for the selector
  65250. * @param func is the function called when the Selector is checked
  65251. * @param checked is true when Selector is checked
  65252. */
  65253. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65254. /**
  65255. * For a given slider group add a slider
  65256. * @param groupNb is the number of the group to add the slider to
  65257. * @param label is the label for the Slider
  65258. * @param func is the function called when the Slider moves
  65259. * @param unit is a string describing the units used, eg degrees or metres
  65260. * @param min is the minimum value for the Slider
  65261. * @param max is the maximum value for the Slider
  65262. * @param value is the start value for the Slider between min and max
  65263. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65264. */
  65265. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65266. }
  65267. }
  65268. declare module BABYLON.GUI {
  65269. /**
  65270. * Class used to hold a the container for ScrollViewer
  65271. * @hidden
  65272. */
  65273. export class _ScrollViewerWindow extends Container {
  65274. parentClientWidth: number;
  65275. parentClientHeight: number;
  65276. /**
  65277. * Creates a new ScrollViewerWindow
  65278. * @param name of ScrollViewerWindow
  65279. */
  65280. constructor(name?: string);
  65281. protected _getTypeName(): string;
  65282. /** @hidden */
  65283. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65284. protected _postMeasure(): void;
  65285. }
  65286. }
  65287. declare module BABYLON.GUI {
  65288. /**
  65289. * Class used to create slider controls
  65290. */
  65291. export class ScrollBar extends BaseSlider {
  65292. name?: string | undefined;
  65293. private _background;
  65294. private _borderColor;
  65295. private _thumbMeasure;
  65296. /** Gets or sets border color */
  65297. borderColor: string;
  65298. /** Gets or sets background color */
  65299. background: string;
  65300. /**
  65301. * Creates a new Slider
  65302. * @param name defines the control name
  65303. */
  65304. constructor(name?: string | undefined);
  65305. protected _getTypeName(): string;
  65306. protected _getThumbThickness(): number;
  65307. _draw(context: CanvasRenderingContext2D): void;
  65308. private _first;
  65309. private _originX;
  65310. private _originY;
  65311. /** @hidden */
  65312. protected _updateValueFromPointer(x: number, y: number): void;
  65313. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65314. }
  65315. }
  65316. declare module BABYLON.GUI {
  65317. /**
  65318. * Class used to hold a viewer window and sliders in a grid
  65319. */
  65320. export class ScrollViewer extends Rectangle {
  65321. private _grid;
  65322. private _horizontalBarSpace;
  65323. private _verticalBarSpace;
  65324. private _dragSpace;
  65325. private _horizontalBar;
  65326. private _verticalBar;
  65327. private _barColor;
  65328. private _barBackground;
  65329. private _barSize;
  65330. private _endLeft;
  65331. private _endTop;
  65332. private _window;
  65333. private _pointerIsOver;
  65334. private _wheelPrecision;
  65335. private _onPointerObserver;
  65336. private _clientWidth;
  65337. private _clientHeight;
  65338. /**
  65339. * Gets the horizontal scrollbar
  65340. */
  65341. readonly horizontalBar: ScrollBar;
  65342. /**
  65343. * Gets the vertical scrollbar
  65344. */
  65345. readonly verticalBar: ScrollBar;
  65346. /**
  65347. * Adds a new control to the current container
  65348. * @param control defines the control to add
  65349. * @returns the current container
  65350. */
  65351. addControl(control: BABYLON.Nullable<Control>): Container;
  65352. /**
  65353. * Removes a control from the current container
  65354. * @param control defines the control to remove
  65355. * @returns the current container
  65356. */
  65357. removeControl(control: Control): Container;
  65358. /** Gets the list of children */
  65359. readonly children: Control[];
  65360. _flagDescendantsAsMatrixDirty(): void;
  65361. /**
  65362. * Creates a new ScrollViewer
  65363. * @param name of ScrollViewer
  65364. */
  65365. constructor(name?: string);
  65366. /** Reset the scroll viewer window to initial size */
  65367. resetWindow(): void;
  65368. protected _getTypeName(): string;
  65369. private _buildClientSizes;
  65370. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65371. protected _postMeasure(): void;
  65372. /**
  65373. * Gets or sets the mouse wheel precision
  65374. * from 0 to 1 with a default value of 0.05
  65375. * */
  65376. wheelPrecision: number;
  65377. /** Gets or sets the bar color */
  65378. barColor: string;
  65379. /** Gets or sets the size of the bar */
  65380. barSize: number;
  65381. /** Gets or sets the bar background */
  65382. barBackground: string;
  65383. /** @hidden */
  65384. private _updateScroller;
  65385. _link(host: AdvancedDynamicTexture): void;
  65386. /** @hidden */
  65387. private _attachWheel;
  65388. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65389. /** Releases associated resources */
  65390. dispose(): void;
  65391. }
  65392. }
  65393. declare module BABYLON.GUI {
  65394. /** Class used to render a grid */
  65395. export class DisplayGrid extends Control {
  65396. name?: string | undefined;
  65397. private _cellWidth;
  65398. private _cellHeight;
  65399. private _minorLineTickness;
  65400. private _minorLineColor;
  65401. private _majorLineTickness;
  65402. private _majorLineColor;
  65403. private _majorLineFrequency;
  65404. private _background;
  65405. private _displayMajorLines;
  65406. private _displayMinorLines;
  65407. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65408. displayMinorLines: boolean;
  65409. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65410. displayMajorLines: boolean;
  65411. /** Gets or sets background color (Black by default) */
  65412. background: string;
  65413. /** Gets or sets the width of each cell (20 by default) */
  65414. cellWidth: number;
  65415. /** Gets or sets the height of each cell (20 by default) */
  65416. cellHeight: number;
  65417. /** Gets or sets the tickness of minor lines (1 by default) */
  65418. minorLineTickness: number;
  65419. /** Gets or sets the color of minor lines (DarkGray by default) */
  65420. minorLineColor: string;
  65421. /** Gets or sets the tickness of major lines (2 by default) */
  65422. majorLineTickness: number;
  65423. /** Gets or sets the color of major lines (White by default) */
  65424. majorLineColor: string;
  65425. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65426. majorLineFrequency: number;
  65427. /**
  65428. * Creates a new GridDisplayRectangle
  65429. * @param name defines the control name
  65430. */
  65431. constructor(name?: string | undefined);
  65432. _draw(context: CanvasRenderingContext2D): void;
  65433. protected _getTypeName(): string;
  65434. }
  65435. }
  65436. declare module BABYLON.GUI {
  65437. /**
  65438. * Class used to create slider controls based on images
  65439. */
  65440. export class ImageBasedSlider extends BaseSlider {
  65441. name?: string | undefined;
  65442. private _backgroundImage;
  65443. private _thumbImage;
  65444. private _valueBarImage;
  65445. private _tempMeasure;
  65446. displayThumb: boolean;
  65447. /**
  65448. * Gets or sets the image used to render the background
  65449. */
  65450. backgroundImage: Image;
  65451. /**
  65452. * Gets or sets the image used to render the value bar
  65453. */
  65454. valueBarImage: Image;
  65455. /**
  65456. * Gets or sets the image used to render the thumb
  65457. */
  65458. thumbImage: Image;
  65459. /**
  65460. * Creates a new ImageBasedSlider
  65461. * @param name defines the control name
  65462. */
  65463. constructor(name?: string | undefined);
  65464. protected _getTypeName(): string;
  65465. _draw(context: CanvasRenderingContext2D): void;
  65466. }
  65467. }
  65468. declare module BABYLON.GUI {
  65469. /**
  65470. * Forcing an export so that this code will execute
  65471. * @hidden
  65472. */
  65473. const name = "Statics";
  65474. }
  65475. declare module BABYLON.GUI {
  65476. /**
  65477. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65478. */
  65479. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65480. /**
  65481. * Define the instrumented AdvancedDynamicTexture.
  65482. */
  65483. texture: AdvancedDynamicTexture;
  65484. private _captureRenderTime;
  65485. private _renderTime;
  65486. private _captureLayoutTime;
  65487. private _layoutTime;
  65488. private _onBeginRenderObserver;
  65489. private _onEndRenderObserver;
  65490. private _onBeginLayoutObserver;
  65491. private _onEndLayoutObserver;
  65492. /**
  65493. * Gets the perf counter used to capture render time
  65494. */
  65495. readonly renderTimeCounter: BABYLON.PerfCounter;
  65496. /**
  65497. * Gets the perf counter used to capture layout time
  65498. */
  65499. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65500. /**
  65501. * Enable or disable the render time capture
  65502. */
  65503. captureRenderTime: boolean;
  65504. /**
  65505. * Enable or disable the layout time capture
  65506. */
  65507. captureLayoutTime: boolean;
  65508. /**
  65509. * Instantiates a new advanced dynamic texture instrumentation.
  65510. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65511. * @param texture Defines the AdvancedDynamicTexture to instrument
  65512. */
  65513. constructor(
  65514. /**
  65515. * Define the instrumented AdvancedDynamicTexture.
  65516. */
  65517. texture: AdvancedDynamicTexture);
  65518. /**
  65519. * Dispose and release associated resources.
  65520. */
  65521. dispose(): void;
  65522. }
  65523. }
  65524. declare module BABYLON.GUI {
  65525. /**
  65526. * Class used to create containers for controls
  65527. */
  65528. export class Container3D extends Control3D {
  65529. private _blockLayout;
  65530. /**
  65531. * Gets the list of child controls
  65532. */
  65533. protected _children: Control3D[];
  65534. /**
  65535. * Gets the list of child controls
  65536. */
  65537. readonly children: Array<Control3D>;
  65538. /**
  65539. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65540. * This is helpful to optimize layout operation when adding multiple children in a row
  65541. */
  65542. blockLayout: boolean;
  65543. /**
  65544. * Creates a new container
  65545. * @param name defines the container name
  65546. */
  65547. constructor(name?: string);
  65548. /**
  65549. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65550. * @returns the current container
  65551. */
  65552. updateLayout(): Container3D;
  65553. /**
  65554. * Gets a boolean indicating if the given control is in the children of this control
  65555. * @param control defines the control to check
  65556. * @returns true if the control is in the child list
  65557. */
  65558. containsControl(control: Control3D): boolean;
  65559. /**
  65560. * Adds a control to the children of this control
  65561. * @param control defines the control to add
  65562. * @returns the current container
  65563. */
  65564. addControl(control: Control3D): Container3D;
  65565. /**
  65566. * This function will be called everytime a new control is added
  65567. */
  65568. protected _arrangeChildren(): void;
  65569. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65570. /**
  65571. * Removes a control from the children of this control
  65572. * @param control defines the control to remove
  65573. * @returns the current container
  65574. */
  65575. removeControl(control: Control3D): Container3D;
  65576. protected _getTypeName(): string;
  65577. /**
  65578. * Releases all associated resources
  65579. */
  65580. dispose(): void;
  65581. /** Control rotation will remain unchanged */
  65582. static readonly UNSET_ORIENTATION: number;
  65583. /** Control will rotate to make it look at sphere central axis */
  65584. static readonly FACEORIGIN_ORIENTATION: number;
  65585. /** Control will rotate to make it look back at sphere central axis */
  65586. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65587. /** Control will rotate to look at z axis (0, 0, 1) */
  65588. static readonly FACEFORWARD_ORIENTATION: number;
  65589. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65590. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65591. }
  65592. }
  65593. declare module BABYLON.GUI {
  65594. /**
  65595. * Class used to manage 3D user interface
  65596. * @see http://doc.babylonjs.com/how_to/gui3d
  65597. */
  65598. export class GUI3DManager implements BABYLON.IDisposable {
  65599. private _scene;
  65600. private _sceneDisposeObserver;
  65601. private _utilityLayer;
  65602. private _rootContainer;
  65603. private _pointerObserver;
  65604. private _pointerOutObserver;
  65605. /** @hidden */
  65606. _lastPickedControl: Control3D;
  65607. /** @hidden */
  65608. _lastControlOver: {
  65609. [pointerId: number]: Control3D;
  65610. };
  65611. /** @hidden */
  65612. _lastControlDown: {
  65613. [pointerId: number]: Control3D;
  65614. };
  65615. /**
  65616. * BABYLON.Observable raised when the point picked by the pointer events changed
  65617. */
  65618. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65619. /** @hidden */
  65620. _sharedMaterials: {
  65621. [key: string]: BABYLON.Material;
  65622. };
  65623. /** Gets the hosting scene */
  65624. readonly scene: BABYLON.Scene;
  65625. /** Gets associated utility layer */
  65626. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65627. /**
  65628. * Creates a new GUI3DManager
  65629. * @param scene
  65630. */
  65631. constructor(scene?: BABYLON.Scene);
  65632. private _handlePointerOut;
  65633. private _doPicking;
  65634. /**
  65635. * Gets the root container
  65636. */
  65637. readonly rootContainer: Container3D;
  65638. /**
  65639. * Gets a boolean indicating if the given control is in the root child list
  65640. * @param control defines the control to check
  65641. * @returns true if the control is in the root child list
  65642. */
  65643. containsControl(control: Control3D): boolean;
  65644. /**
  65645. * Adds a control to the root child list
  65646. * @param control defines the control to add
  65647. * @returns the current manager
  65648. */
  65649. addControl(control: Control3D): GUI3DManager;
  65650. /**
  65651. * Removes a control from the root child list
  65652. * @param control defines the control to remove
  65653. * @returns the current container
  65654. */
  65655. removeControl(control: Control3D): GUI3DManager;
  65656. /**
  65657. * Releases all associated resources
  65658. */
  65659. dispose(): void;
  65660. }
  65661. }
  65662. declare module BABYLON.GUI {
  65663. /**
  65664. * Class used to transport BABYLON.Vector3 information for pointer events
  65665. */
  65666. export class Vector3WithInfo extends BABYLON.Vector3 {
  65667. /** defines the current mouse button index */
  65668. buttonIndex: number;
  65669. /**
  65670. * Creates a new Vector3WithInfo
  65671. * @param source defines the vector3 data to transport
  65672. * @param buttonIndex defines the current mouse button index
  65673. */
  65674. constructor(source: BABYLON.Vector3,
  65675. /** defines the current mouse button index */
  65676. buttonIndex?: number);
  65677. }
  65678. }
  65679. declare module BABYLON.GUI {
  65680. /**
  65681. * Class used as base class for controls
  65682. */
  65683. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65684. /** Defines the control name */
  65685. name?: string | undefined;
  65686. /** @hidden */
  65687. _host: GUI3DManager;
  65688. private _node;
  65689. private _downCount;
  65690. private _enterCount;
  65691. private _downPointerIds;
  65692. private _isVisible;
  65693. /** Gets or sets the control position in world space */
  65694. position: BABYLON.Vector3;
  65695. /** Gets or sets the control scaling in world space */
  65696. scaling: BABYLON.Vector3;
  65697. /** Callback used to start pointer enter animation */
  65698. pointerEnterAnimation: () => void;
  65699. /** Callback used to start pointer out animation */
  65700. pointerOutAnimation: () => void;
  65701. /** Callback used to start pointer down animation */
  65702. pointerDownAnimation: () => void;
  65703. /** Callback used to start pointer up animation */
  65704. pointerUpAnimation: () => void;
  65705. /**
  65706. * An event triggered when the pointer move over the control
  65707. */
  65708. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65709. /**
  65710. * An event triggered when the pointer move out of the control
  65711. */
  65712. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65713. /**
  65714. * An event triggered when the pointer taps the control
  65715. */
  65716. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65717. /**
  65718. * An event triggered when pointer is up
  65719. */
  65720. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65721. /**
  65722. * An event triggered when a control is clicked on (with a mouse)
  65723. */
  65724. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65725. /**
  65726. * An event triggered when pointer enters the control
  65727. */
  65728. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65729. /**
  65730. * Gets or sets the parent container
  65731. */
  65732. parent: BABYLON.Nullable<Container3D>;
  65733. private _behaviors;
  65734. /**
  65735. * Gets the list of attached behaviors
  65736. * @see http://doc.babylonjs.com/features/behaviour
  65737. */
  65738. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65739. /**
  65740. * Attach a behavior to the control
  65741. * @see http://doc.babylonjs.com/features/behaviour
  65742. * @param behavior defines the behavior to attach
  65743. * @returns the current control
  65744. */
  65745. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65746. /**
  65747. * Remove an attached behavior
  65748. * @see http://doc.babylonjs.com/features/behaviour
  65749. * @param behavior defines the behavior to attach
  65750. * @returns the current control
  65751. */
  65752. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65753. /**
  65754. * Gets an attached behavior by name
  65755. * @param name defines the name of the behavior to look for
  65756. * @see http://doc.babylonjs.com/features/behaviour
  65757. * @returns null if behavior was not found else the requested behavior
  65758. */
  65759. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65760. /** Gets or sets a boolean indicating if the control is visible */
  65761. isVisible: boolean;
  65762. /**
  65763. * Creates a new control
  65764. * @param name defines the control name
  65765. */
  65766. constructor(
  65767. /** Defines the control name */
  65768. name?: string | undefined);
  65769. /**
  65770. * Gets a string representing the class name
  65771. */
  65772. readonly typeName: string;
  65773. /**
  65774. * Get the current class name of the control.
  65775. * @returns current class name
  65776. */
  65777. getClassName(): string;
  65778. protected _getTypeName(): string;
  65779. /**
  65780. * Gets the transform node used by this control
  65781. */
  65782. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65783. /**
  65784. * Gets the mesh used to render this control
  65785. */
  65786. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65787. /**
  65788. * Link the control as child of the given node
  65789. * @param node defines the node to link to. Use null to unlink the control
  65790. * @returns the current control
  65791. */
  65792. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65793. /** @hidden **/
  65794. _prepareNode(scene: BABYLON.Scene): void;
  65795. /**
  65796. * Node creation.
  65797. * Can be overriden by children
  65798. * @param scene defines the scene where the node must be attached
  65799. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65800. */
  65801. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65802. /**
  65803. * Affect a material to the given mesh
  65804. * @param mesh defines the mesh which will represent the control
  65805. */
  65806. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65807. /** @hidden */
  65808. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65809. /** @hidden */
  65810. _onPointerEnter(target: Control3D): boolean;
  65811. /** @hidden */
  65812. _onPointerOut(target: Control3D): void;
  65813. /** @hidden */
  65814. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65815. /** @hidden */
  65816. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65817. /** @hidden */
  65818. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65819. /** @hidden */
  65820. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65821. /** @hidden */
  65822. _disposeNode(): void;
  65823. /**
  65824. * Releases all associated resources
  65825. */
  65826. dispose(): void;
  65827. }
  65828. }
  65829. declare module BABYLON.GUI {
  65830. /**
  65831. * Class used as a root to all buttons
  65832. */
  65833. export class AbstractButton3D extends Control3D {
  65834. /**
  65835. * Creates a new button
  65836. * @param name defines the control name
  65837. */
  65838. constructor(name?: string);
  65839. protected _getTypeName(): string;
  65840. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65841. }
  65842. }
  65843. declare module BABYLON.GUI {
  65844. /**
  65845. * Class used to create a button in 3D
  65846. */
  65847. export class Button3D extends AbstractButton3D {
  65848. /** @hidden */
  65849. protected _currentMaterial: BABYLON.Material;
  65850. private _facadeTexture;
  65851. private _content;
  65852. private _contentResolution;
  65853. private _contentScaleRatio;
  65854. /**
  65855. * Gets or sets the texture resolution used to render content (512 by default)
  65856. */
  65857. contentResolution: BABYLON.int;
  65858. /**
  65859. * Gets or sets the texture scale ratio used to render content (2 by default)
  65860. */
  65861. contentScaleRatio: number;
  65862. protected _disposeFacadeTexture(): void;
  65863. protected _resetContent(): void;
  65864. /**
  65865. * Creates a new button
  65866. * @param name defines the control name
  65867. */
  65868. constructor(name?: string);
  65869. /**
  65870. * Gets or sets the GUI 2D content used to display the button's facade
  65871. */
  65872. content: Control;
  65873. /**
  65874. * Apply the facade texture (created from the content property).
  65875. * This function can be overloaded by child classes
  65876. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65877. */
  65878. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65879. protected _getTypeName(): string;
  65880. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65881. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65882. /**
  65883. * Releases all associated resources
  65884. */
  65885. dispose(): void;
  65886. }
  65887. }
  65888. declare module BABYLON.GUI {
  65889. /**
  65890. * Abstract class used to create a container panel deployed on the surface of a volume
  65891. */
  65892. export abstract class VolumeBasedPanel extends Container3D {
  65893. private _columns;
  65894. private _rows;
  65895. private _rowThenColum;
  65896. private _orientation;
  65897. protected _cellWidth: number;
  65898. protected _cellHeight: number;
  65899. /**
  65900. * Gets or sets the distance between elements
  65901. */
  65902. margin: number;
  65903. /**
  65904. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65905. * | Value | Type | Description |
  65906. * | ----- | ----------------------------------- | ----------- |
  65907. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65908. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65909. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65910. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65911. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65912. */
  65913. orientation: number;
  65914. /**
  65915. * Gets or sets the number of columns requested (10 by default).
  65916. * The panel will automatically compute the number of rows based on number of child controls.
  65917. */
  65918. columns: BABYLON.int;
  65919. /**
  65920. * Gets or sets a the number of rows requested.
  65921. * The panel will automatically compute the number of columns based on number of child controls.
  65922. */
  65923. rows: BABYLON.int;
  65924. /**
  65925. * Creates new VolumeBasedPanel
  65926. */
  65927. constructor();
  65928. protected _arrangeChildren(): void;
  65929. /** Child classes must implement this function to provide correct control positioning */
  65930. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65931. /** Child classes can implement this function to provide additional processing */
  65932. protected _finalProcessing(): void;
  65933. }
  65934. }
  65935. declare module BABYLON.GUI {
  65936. /**
  65937. * Class used to create a container panel deployed on the surface of a cylinder
  65938. */
  65939. export class CylinderPanel extends VolumeBasedPanel {
  65940. private _radius;
  65941. /**
  65942. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65943. */
  65944. radius: BABYLON.float;
  65945. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65946. private _cylindricalMapping;
  65947. }
  65948. }
  65949. declare module BABYLON.GUI {
  65950. /** @hidden */
  65951. export var fluentVertexShader: {
  65952. name: string;
  65953. shader: string;
  65954. };
  65955. }
  65956. declare module BABYLON.GUI {
  65957. /** @hidden */
  65958. export var fluentPixelShader: {
  65959. name: string;
  65960. shader: string;
  65961. };
  65962. }
  65963. declare module BABYLON.GUI {
  65964. /** @hidden */
  65965. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65966. INNERGLOW: boolean;
  65967. BORDER: boolean;
  65968. HOVERLIGHT: boolean;
  65969. TEXTURE: boolean;
  65970. constructor();
  65971. }
  65972. /**
  65973. * Class used to render controls with fluent desgin
  65974. */
  65975. export class FluentMaterial extends BABYLON.PushMaterial {
  65976. /**
  65977. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65978. */
  65979. innerGlowColorIntensity: number;
  65980. /**
  65981. * Gets or sets the inner glow color (white by default)
  65982. */
  65983. innerGlowColor: BABYLON.Color3;
  65984. /**
  65985. * Gets or sets alpha value (default is 1.0)
  65986. */
  65987. alpha: number;
  65988. /**
  65989. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65990. */
  65991. albedoColor: BABYLON.Color3;
  65992. /**
  65993. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65994. */
  65995. renderBorders: boolean;
  65996. /**
  65997. * Gets or sets border width (default is 0.5)
  65998. */
  65999. borderWidth: number;
  66000. /**
  66001. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66002. */
  66003. edgeSmoothingValue: number;
  66004. /**
  66005. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66006. */
  66007. borderMinValue: number;
  66008. /**
  66009. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66010. */
  66011. renderHoverLight: boolean;
  66012. /**
  66013. * Gets or sets the radius used to render the hover light (default is 1.0)
  66014. */
  66015. hoverRadius: number;
  66016. /**
  66017. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66018. */
  66019. hoverColor: BABYLON.Color4;
  66020. /**
  66021. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66022. */
  66023. hoverPosition: BABYLON.Vector3;
  66024. private _albedoTexture;
  66025. /** Gets or sets the texture to use for albedo color */
  66026. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66027. /**
  66028. * Creates a new Fluent material
  66029. * @param name defines the name of the material
  66030. * @param scene defines the hosting scene
  66031. */
  66032. constructor(name: string, scene: BABYLON.Scene);
  66033. needAlphaBlending(): boolean;
  66034. needAlphaTesting(): boolean;
  66035. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66036. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66037. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66038. getActiveTextures(): BABYLON.BaseTexture[];
  66039. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66040. dispose(forceDisposeEffect?: boolean): void;
  66041. clone(name: string): FluentMaterial;
  66042. serialize(): any;
  66043. getClassName(): string;
  66044. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66045. }
  66046. }
  66047. declare module BABYLON.GUI {
  66048. /**
  66049. * Class used to create a holographic button in 3D
  66050. */
  66051. export class HolographicButton extends Button3D {
  66052. private _backPlate;
  66053. private _textPlate;
  66054. private _frontPlate;
  66055. private _text;
  66056. private _imageUrl;
  66057. private _shareMaterials;
  66058. private _frontMaterial;
  66059. private _backMaterial;
  66060. private _plateMaterial;
  66061. private _pickedPointObserver;
  66062. private _tooltipFade;
  66063. private _tooltipTextBlock;
  66064. private _tooltipTexture;
  66065. private _tooltipMesh;
  66066. private _tooltipHoverObserver;
  66067. private _tooltipOutObserver;
  66068. private _disposeTooltip;
  66069. /**
  66070. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66071. */
  66072. tooltipText: BABYLON.Nullable<string>;
  66073. /**
  66074. * Gets or sets text for the button
  66075. */
  66076. text: string;
  66077. /**
  66078. * Gets or sets the image url for the button
  66079. */
  66080. imageUrl: string;
  66081. /**
  66082. * Gets the back material used by this button
  66083. */
  66084. readonly backMaterial: FluentMaterial;
  66085. /**
  66086. * Gets the front material used by this button
  66087. */
  66088. readonly frontMaterial: FluentMaterial;
  66089. /**
  66090. * Gets the plate material used by this button
  66091. */
  66092. readonly plateMaterial: BABYLON.StandardMaterial;
  66093. /**
  66094. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66095. */
  66096. readonly shareMaterials: boolean;
  66097. /**
  66098. * Creates a new button
  66099. * @param name defines the control name
  66100. */
  66101. constructor(name?: string, shareMaterials?: boolean);
  66102. protected _getTypeName(): string;
  66103. private _rebuildContent;
  66104. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66105. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66106. private _createBackMaterial;
  66107. private _createFrontMaterial;
  66108. private _createPlateMaterial;
  66109. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66110. /**
  66111. * Releases all associated resources
  66112. */
  66113. dispose(): void;
  66114. }
  66115. }
  66116. declare module BABYLON.GUI {
  66117. /**
  66118. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66119. */
  66120. export class MeshButton3D extends Button3D {
  66121. /** @hidden */
  66122. protected _currentMesh: BABYLON.Mesh;
  66123. /**
  66124. * Creates a new 3D button based on a mesh
  66125. * @param mesh mesh to become a 3D button
  66126. * @param name defines the control name
  66127. */
  66128. constructor(mesh: BABYLON.Mesh, name?: string);
  66129. protected _getTypeName(): string;
  66130. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66131. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66132. }
  66133. }
  66134. declare module BABYLON.GUI {
  66135. /**
  66136. * Class used to create a container panel deployed on the surface of a plane
  66137. */
  66138. export class PlanePanel extends VolumeBasedPanel {
  66139. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66140. }
  66141. }
  66142. declare module BABYLON.GUI {
  66143. /**
  66144. * Class used to create a container panel where items get randomized planar mapping
  66145. */
  66146. export class ScatterPanel extends VolumeBasedPanel {
  66147. private _iteration;
  66148. /**
  66149. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66150. */
  66151. iteration: BABYLON.float;
  66152. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66153. private _scatterMapping;
  66154. protected _finalProcessing(): void;
  66155. }
  66156. }
  66157. declare module BABYLON.GUI {
  66158. /**
  66159. * Class used to create a container panel deployed on the surface of a sphere
  66160. */
  66161. export class SpherePanel extends VolumeBasedPanel {
  66162. private _radius;
  66163. /**
  66164. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66165. */
  66166. radius: BABYLON.float;
  66167. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66168. private _sphericalMapping;
  66169. }
  66170. }
  66171. declare module BABYLON.GUI {
  66172. /**
  66173. * Class used to create a stack panel in 3D on XY plane
  66174. */
  66175. export class StackPanel3D extends Container3D {
  66176. private _isVertical;
  66177. /**
  66178. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66179. */
  66180. isVertical: boolean;
  66181. /**
  66182. * Gets or sets the distance between elements
  66183. */
  66184. margin: number;
  66185. /**
  66186. * Creates new StackPanel
  66187. * @param isVertical
  66188. */
  66189. constructor(isVertical?: boolean);
  66190. protected _arrangeChildren(): void;
  66191. }
  66192. }
  66193. declare module BABYLON {
  66194. /**
  66195. * Mode that determines the coordinate system to use.
  66196. */
  66197. export enum GLTFLoaderCoordinateSystemMode {
  66198. /**
  66199. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66200. */
  66201. AUTO = 0,
  66202. /**
  66203. * Sets the useRightHandedSystem flag on the scene.
  66204. */
  66205. FORCE_RIGHT_HANDED = 1
  66206. }
  66207. /**
  66208. * Mode that determines what animations will start.
  66209. */
  66210. export enum GLTFLoaderAnimationStartMode {
  66211. /**
  66212. * No animation will start.
  66213. */
  66214. NONE = 0,
  66215. /**
  66216. * The first animation will start.
  66217. */
  66218. FIRST = 1,
  66219. /**
  66220. * All animations will start.
  66221. */
  66222. ALL = 2
  66223. }
  66224. /**
  66225. * Interface that contains the data for the glTF asset.
  66226. */
  66227. export interface IGLTFLoaderData {
  66228. /**
  66229. * Object that represents the glTF JSON.
  66230. */
  66231. json: Object;
  66232. /**
  66233. * The BIN chunk of a binary glTF.
  66234. */
  66235. bin: Nullable<ArrayBufferView>;
  66236. }
  66237. /**
  66238. * Interface for extending the loader.
  66239. */
  66240. export interface IGLTFLoaderExtension {
  66241. /**
  66242. * The name of this extension.
  66243. */
  66244. readonly name: string;
  66245. /**
  66246. * Defines whether this extension is enabled.
  66247. */
  66248. enabled: boolean;
  66249. }
  66250. /**
  66251. * Loader state.
  66252. */
  66253. export enum GLTFLoaderState {
  66254. /**
  66255. * The asset is loading.
  66256. */
  66257. LOADING = 0,
  66258. /**
  66259. * The asset is ready for rendering.
  66260. */
  66261. READY = 1,
  66262. /**
  66263. * The asset is completely loaded.
  66264. */
  66265. COMPLETE = 2
  66266. }
  66267. /** @hidden */
  66268. export interface IGLTFLoader extends IDisposable {
  66269. readonly state: Nullable<GLTFLoaderState>;
  66270. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66271. meshes: AbstractMesh[];
  66272. particleSystems: IParticleSystem[];
  66273. skeletons: Skeleton[];
  66274. animationGroups: AnimationGroup[];
  66275. }>;
  66276. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66277. }
  66278. /**
  66279. * File loader for loading glTF files into a scene.
  66280. */
  66281. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66282. /** @hidden */
  66283. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66284. /** @hidden */
  66285. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66286. /**
  66287. * Raised when the asset has been parsed
  66288. */
  66289. onParsedObservable: Observable<IGLTFLoaderData>;
  66290. private _onParsedObserver;
  66291. /**
  66292. * Raised when the asset has been parsed
  66293. */
  66294. onParsed: (loaderData: IGLTFLoaderData) => void;
  66295. /**
  66296. * 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.
  66297. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66298. * Defaults to true.
  66299. * @hidden
  66300. */
  66301. static IncrementalLoading: boolean;
  66302. /**
  66303. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66304. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66305. * @hidden
  66306. */
  66307. static HomogeneousCoordinates: boolean;
  66308. /**
  66309. * The coordinate system mode. Defaults to AUTO.
  66310. */
  66311. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66312. /**
  66313. * The animation start mode. Defaults to FIRST.
  66314. */
  66315. animationStartMode: GLTFLoaderAnimationStartMode;
  66316. /**
  66317. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66318. */
  66319. compileMaterials: boolean;
  66320. /**
  66321. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66322. */
  66323. useClipPlane: boolean;
  66324. /**
  66325. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66326. */
  66327. compileShadowGenerators: boolean;
  66328. /**
  66329. * Defines if the Alpha blended materials are only applied as coverage.
  66330. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66331. * If true, no extra effects are applied to transparent pixels.
  66332. */
  66333. transparencyAsCoverage: boolean;
  66334. /**
  66335. * Function called before loading a url referenced by the asset.
  66336. */
  66337. preprocessUrlAsync: (url: string) => Promise<string>;
  66338. /**
  66339. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66340. */
  66341. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66342. private _onMeshLoadedObserver;
  66343. /**
  66344. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66345. */
  66346. onMeshLoaded: (mesh: AbstractMesh) => void;
  66347. /**
  66348. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66349. */
  66350. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66351. private _onTextureLoadedObserver;
  66352. /**
  66353. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66354. */
  66355. onTextureLoaded: (texture: BaseTexture) => void;
  66356. /**
  66357. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66358. */
  66359. readonly onMaterialLoadedObservable: Observable<Material>;
  66360. private _onMaterialLoadedObserver;
  66361. /**
  66362. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66363. */
  66364. onMaterialLoaded: (material: Material) => void;
  66365. /**
  66366. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66367. */
  66368. readonly onCameraLoadedObservable: Observable<Camera>;
  66369. private _onCameraLoadedObserver;
  66370. /**
  66371. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66372. */
  66373. onCameraLoaded: (camera: Camera) => void;
  66374. /**
  66375. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66376. * For assets with LODs, raised when all of the LODs are complete.
  66377. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66378. */
  66379. readonly onCompleteObservable: Observable<void>;
  66380. private _onCompleteObserver;
  66381. /**
  66382. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66383. * For assets with LODs, raised when all of the LODs are complete.
  66384. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66385. */
  66386. onComplete: () => void;
  66387. /**
  66388. * Observable raised when an error occurs.
  66389. */
  66390. readonly onErrorObservable: Observable<any>;
  66391. private _onErrorObserver;
  66392. /**
  66393. * Callback raised when an error occurs.
  66394. */
  66395. onError: (reason: any) => void;
  66396. /**
  66397. * Observable raised after the loader is disposed.
  66398. */
  66399. readonly onDisposeObservable: Observable<void>;
  66400. private _onDisposeObserver;
  66401. /**
  66402. * Callback raised after the loader is disposed.
  66403. */
  66404. onDispose: () => void;
  66405. /**
  66406. * Observable raised after a loader extension is created.
  66407. * Set additional options for a loader extension in this event.
  66408. */
  66409. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66410. private _onExtensionLoadedObserver;
  66411. /**
  66412. * Callback raised after a loader extension is created.
  66413. */
  66414. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66415. /**
  66416. * Defines if the loader logging is enabled.
  66417. */
  66418. loggingEnabled: boolean;
  66419. /**
  66420. * Defines if the loader should capture performance counters.
  66421. */
  66422. capturePerformanceCounters: boolean;
  66423. /**
  66424. * Defines if the loader should validate the asset.
  66425. */
  66426. validate: boolean;
  66427. /**
  66428. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66429. */
  66430. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66431. private _onValidatedObserver;
  66432. /**
  66433. * Callback raised after a loader extension is created.
  66434. */
  66435. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66436. private _loader;
  66437. /**
  66438. * Name of the loader ("gltf")
  66439. */
  66440. name: string;
  66441. /**
  66442. * Supported file extensions of the loader (.gltf, .glb)
  66443. */
  66444. extensions: ISceneLoaderPluginExtensions;
  66445. /**
  66446. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66447. */
  66448. dispose(): void;
  66449. /** @hidden */
  66450. _clear(): void;
  66451. /**
  66452. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66453. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66454. * @param scene the scene the meshes should be added to
  66455. * @param data the glTF data to load
  66456. * @param rootUrl root url to load from
  66457. * @param onProgress event that fires when loading progress has occured
  66458. * @param fileName Defines the name of the file to load
  66459. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66460. */
  66461. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66462. meshes: AbstractMesh[];
  66463. particleSystems: IParticleSystem[];
  66464. skeletons: Skeleton[];
  66465. animationGroups: AnimationGroup[];
  66466. }>;
  66467. /**
  66468. * Imports all objects from the loaded glTF data and adds them to the scene
  66469. * @param scene the scene the objects should be added to
  66470. * @param data the glTF data to load
  66471. * @param rootUrl root url to load from
  66472. * @param onProgress event that fires when loading progress has occured
  66473. * @param fileName Defines the name of the file to load
  66474. * @returns a promise which completes when objects have been loaded to the scene
  66475. */
  66476. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66477. /**
  66478. * Load into an asset container.
  66479. * @param scene The scene to load into
  66480. * @param data The data to import
  66481. * @param rootUrl The root url for scene and resources
  66482. * @param onProgress The callback when the load progresses
  66483. * @param fileName Defines the name of the file to load
  66484. * @returns The loaded asset container
  66485. */
  66486. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66487. /**
  66488. * If the data string can be loaded directly.
  66489. * @param data string contianing the file data
  66490. * @returns if the data can be loaded directly
  66491. */
  66492. canDirectLoad(data: string): boolean;
  66493. /**
  66494. * Rewrites a url by combining a root url and response url.
  66495. */
  66496. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66497. /**
  66498. * Instantiates a glTF file loader plugin.
  66499. * @returns the created plugin
  66500. */
  66501. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66502. /**
  66503. * The loader state or null if the loader is not active.
  66504. */
  66505. readonly loaderState: Nullable<GLTFLoaderState>;
  66506. /**
  66507. * Returns a promise that resolves when the asset is completely loaded.
  66508. * @returns a promise that resolves when the asset is completely loaded.
  66509. */
  66510. whenCompleteAsync(): Promise<void>;
  66511. private _parseAsync;
  66512. private _validateAsync;
  66513. private _getLoader;
  66514. private _unpackBinary;
  66515. private _unpackBinaryV1;
  66516. private _unpackBinaryV2;
  66517. private static _parseVersion;
  66518. private static _compareVersion;
  66519. private static _decodeBufferToText;
  66520. private static readonly _logSpaces;
  66521. private _logIndentLevel;
  66522. private _loggingEnabled;
  66523. /** @hidden */
  66524. _log: (message: string) => void;
  66525. /** @hidden */
  66526. _logOpen(message: string): void;
  66527. /** @hidden */
  66528. _logClose(): void;
  66529. private _logEnabled;
  66530. private _logDisabled;
  66531. private _capturePerformanceCounters;
  66532. /** @hidden */
  66533. _startPerformanceCounter: (counterName: string) => void;
  66534. /** @hidden */
  66535. _endPerformanceCounter: (counterName: string) => void;
  66536. private _startPerformanceCounterEnabled;
  66537. private _startPerformanceCounterDisabled;
  66538. private _endPerformanceCounterEnabled;
  66539. private _endPerformanceCounterDisabled;
  66540. }
  66541. }
  66542. declare module BABYLON.GLTF1 {
  66543. /**
  66544. * Enums
  66545. * @hidden
  66546. */
  66547. export enum EComponentType {
  66548. BYTE = 5120,
  66549. UNSIGNED_BYTE = 5121,
  66550. SHORT = 5122,
  66551. UNSIGNED_SHORT = 5123,
  66552. FLOAT = 5126
  66553. }
  66554. /** @hidden */
  66555. export enum EShaderType {
  66556. FRAGMENT = 35632,
  66557. VERTEX = 35633
  66558. }
  66559. /** @hidden */
  66560. export enum EParameterType {
  66561. BYTE = 5120,
  66562. UNSIGNED_BYTE = 5121,
  66563. SHORT = 5122,
  66564. UNSIGNED_SHORT = 5123,
  66565. INT = 5124,
  66566. UNSIGNED_INT = 5125,
  66567. FLOAT = 5126,
  66568. FLOAT_VEC2 = 35664,
  66569. FLOAT_VEC3 = 35665,
  66570. FLOAT_VEC4 = 35666,
  66571. INT_VEC2 = 35667,
  66572. INT_VEC3 = 35668,
  66573. INT_VEC4 = 35669,
  66574. BOOL = 35670,
  66575. BOOL_VEC2 = 35671,
  66576. BOOL_VEC3 = 35672,
  66577. BOOL_VEC4 = 35673,
  66578. FLOAT_MAT2 = 35674,
  66579. FLOAT_MAT3 = 35675,
  66580. FLOAT_MAT4 = 35676,
  66581. SAMPLER_2D = 35678
  66582. }
  66583. /** @hidden */
  66584. export enum ETextureWrapMode {
  66585. CLAMP_TO_EDGE = 33071,
  66586. MIRRORED_REPEAT = 33648,
  66587. REPEAT = 10497
  66588. }
  66589. /** @hidden */
  66590. export enum ETextureFilterType {
  66591. NEAREST = 9728,
  66592. LINEAR = 9728,
  66593. NEAREST_MIPMAP_NEAREST = 9984,
  66594. LINEAR_MIPMAP_NEAREST = 9985,
  66595. NEAREST_MIPMAP_LINEAR = 9986,
  66596. LINEAR_MIPMAP_LINEAR = 9987
  66597. }
  66598. /** @hidden */
  66599. export enum ETextureFormat {
  66600. ALPHA = 6406,
  66601. RGB = 6407,
  66602. RGBA = 6408,
  66603. LUMINANCE = 6409,
  66604. LUMINANCE_ALPHA = 6410
  66605. }
  66606. /** @hidden */
  66607. export enum ECullingType {
  66608. FRONT = 1028,
  66609. BACK = 1029,
  66610. FRONT_AND_BACK = 1032
  66611. }
  66612. /** @hidden */
  66613. export enum EBlendingFunction {
  66614. ZERO = 0,
  66615. ONE = 1,
  66616. SRC_COLOR = 768,
  66617. ONE_MINUS_SRC_COLOR = 769,
  66618. DST_COLOR = 774,
  66619. ONE_MINUS_DST_COLOR = 775,
  66620. SRC_ALPHA = 770,
  66621. ONE_MINUS_SRC_ALPHA = 771,
  66622. DST_ALPHA = 772,
  66623. ONE_MINUS_DST_ALPHA = 773,
  66624. CONSTANT_COLOR = 32769,
  66625. ONE_MINUS_CONSTANT_COLOR = 32770,
  66626. CONSTANT_ALPHA = 32771,
  66627. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66628. SRC_ALPHA_SATURATE = 776
  66629. }
  66630. /** @hidden */
  66631. export interface IGLTFProperty {
  66632. extensions?: {
  66633. [key: string]: any;
  66634. };
  66635. extras?: Object;
  66636. }
  66637. /** @hidden */
  66638. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66639. name?: string;
  66640. }
  66641. /** @hidden */
  66642. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66643. bufferView: string;
  66644. byteOffset: number;
  66645. byteStride: number;
  66646. count: number;
  66647. type: string;
  66648. componentType: EComponentType;
  66649. max?: number[];
  66650. min?: number[];
  66651. name?: string;
  66652. }
  66653. /** @hidden */
  66654. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66655. buffer: string;
  66656. byteOffset: number;
  66657. byteLength: number;
  66658. byteStride: number;
  66659. target?: number;
  66660. }
  66661. /** @hidden */
  66662. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66663. uri: string;
  66664. byteLength?: number;
  66665. type?: string;
  66666. }
  66667. /** @hidden */
  66668. export interface IGLTFShader extends IGLTFChildRootProperty {
  66669. uri: string;
  66670. type: EShaderType;
  66671. }
  66672. /** @hidden */
  66673. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66674. attributes: string[];
  66675. fragmentShader: string;
  66676. vertexShader: string;
  66677. }
  66678. /** @hidden */
  66679. export interface IGLTFTechniqueParameter {
  66680. type: number;
  66681. count?: number;
  66682. semantic?: string;
  66683. node?: string;
  66684. value?: number | boolean | string | Array<any>;
  66685. source?: string;
  66686. babylonValue?: any;
  66687. }
  66688. /** @hidden */
  66689. export interface IGLTFTechniqueCommonProfile {
  66690. lightingModel: string;
  66691. texcoordBindings: Object;
  66692. parameters?: Array<any>;
  66693. }
  66694. /** @hidden */
  66695. export interface IGLTFTechniqueStatesFunctions {
  66696. blendColor?: number[];
  66697. blendEquationSeparate?: number[];
  66698. blendFuncSeparate?: number[];
  66699. colorMask: boolean[];
  66700. cullFace: number[];
  66701. }
  66702. /** @hidden */
  66703. export interface IGLTFTechniqueStates {
  66704. enable: number[];
  66705. functions: IGLTFTechniqueStatesFunctions;
  66706. }
  66707. /** @hidden */
  66708. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66709. parameters: {
  66710. [key: string]: IGLTFTechniqueParameter;
  66711. };
  66712. program: string;
  66713. attributes: {
  66714. [key: string]: string;
  66715. };
  66716. uniforms: {
  66717. [key: string]: string;
  66718. };
  66719. states: IGLTFTechniqueStates;
  66720. }
  66721. /** @hidden */
  66722. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66723. technique?: string;
  66724. values: string[];
  66725. }
  66726. /** @hidden */
  66727. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66728. attributes: {
  66729. [key: string]: string;
  66730. };
  66731. indices: string;
  66732. material: string;
  66733. mode?: number;
  66734. }
  66735. /** @hidden */
  66736. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66737. primitives: IGLTFMeshPrimitive[];
  66738. }
  66739. /** @hidden */
  66740. export interface IGLTFImage extends IGLTFChildRootProperty {
  66741. uri: string;
  66742. }
  66743. /** @hidden */
  66744. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66745. magFilter?: number;
  66746. minFilter?: number;
  66747. wrapS?: number;
  66748. wrapT?: number;
  66749. }
  66750. /** @hidden */
  66751. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66752. sampler: string;
  66753. source: string;
  66754. format?: ETextureFormat;
  66755. internalFormat?: ETextureFormat;
  66756. target?: number;
  66757. type?: number;
  66758. babylonTexture?: Texture;
  66759. }
  66760. /** @hidden */
  66761. export interface IGLTFAmbienLight {
  66762. color?: number[];
  66763. }
  66764. /** @hidden */
  66765. export interface IGLTFDirectionalLight {
  66766. color?: number[];
  66767. }
  66768. /** @hidden */
  66769. export interface IGLTFPointLight {
  66770. color?: number[];
  66771. constantAttenuation?: number;
  66772. linearAttenuation?: number;
  66773. quadraticAttenuation?: number;
  66774. }
  66775. /** @hidden */
  66776. export interface IGLTFSpotLight {
  66777. color?: number[];
  66778. constantAttenuation?: number;
  66779. fallOfAngle?: number;
  66780. fallOffExponent?: number;
  66781. linearAttenuation?: number;
  66782. quadraticAttenuation?: number;
  66783. }
  66784. /** @hidden */
  66785. export interface IGLTFLight extends IGLTFChildRootProperty {
  66786. type: string;
  66787. }
  66788. /** @hidden */
  66789. export interface IGLTFCameraOrthographic {
  66790. xmag: number;
  66791. ymag: number;
  66792. zfar: number;
  66793. znear: number;
  66794. }
  66795. /** @hidden */
  66796. export interface IGLTFCameraPerspective {
  66797. aspectRatio: number;
  66798. yfov: number;
  66799. zfar: number;
  66800. znear: number;
  66801. }
  66802. /** @hidden */
  66803. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66804. type: string;
  66805. }
  66806. /** @hidden */
  66807. export interface IGLTFAnimationChannelTarget {
  66808. id: string;
  66809. path: string;
  66810. }
  66811. /** @hidden */
  66812. export interface IGLTFAnimationChannel {
  66813. sampler: string;
  66814. target: IGLTFAnimationChannelTarget;
  66815. }
  66816. /** @hidden */
  66817. export interface IGLTFAnimationSampler {
  66818. input: string;
  66819. output: string;
  66820. interpolation?: string;
  66821. }
  66822. /** @hidden */
  66823. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66824. channels?: IGLTFAnimationChannel[];
  66825. parameters?: {
  66826. [key: string]: string;
  66827. };
  66828. samplers?: {
  66829. [key: string]: IGLTFAnimationSampler;
  66830. };
  66831. }
  66832. /** @hidden */
  66833. export interface IGLTFNodeInstanceSkin {
  66834. skeletons: string[];
  66835. skin: string;
  66836. meshes: string[];
  66837. }
  66838. /** @hidden */
  66839. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66840. bindShapeMatrix: number[];
  66841. inverseBindMatrices: string;
  66842. jointNames: string[];
  66843. babylonSkeleton?: Skeleton;
  66844. }
  66845. /** @hidden */
  66846. export interface IGLTFNode extends IGLTFChildRootProperty {
  66847. camera?: string;
  66848. children: string[];
  66849. skin?: string;
  66850. jointName?: string;
  66851. light?: string;
  66852. matrix: number[];
  66853. mesh?: string;
  66854. meshes?: string[];
  66855. rotation?: number[];
  66856. scale?: number[];
  66857. translation?: number[];
  66858. babylonNode?: Node;
  66859. }
  66860. /** @hidden */
  66861. export interface IGLTFScene extends IGLTFChildRootProperty {
  66862. nodes: string[];
  66863. }
  66864. /** @hidden */
  66865. export interface IGLTFRuntime {
  66866. extensions: {
  66867. [key: string]: any;
  66868. };
  66869. accessors: {
  66870. [key: string]: IGLTFAccessor;
  66871. };
  66872. buffers: {
  66873. [key: string]: IGLTFBuffer;
  66874. };
  66875. bufferViews: {
  66876. [key: string]: IGLTFBufferView;
  66877. };
  66878. meshes: {
  66879. [key: string]: IGLTFMesh;
  66880. };
  66881. lights: {
  66882. [key: string]: IGLTFLight;
  66883. };
  66884. cameras: {
  66885. [key: string]: IGLTFCamera;
  66886. };
  66887. nodes: {
  66888. [key: string]: IGLTFNode;
  66889. };
  66890. images: {
  66891. [key: string]: IGLTFImage;
  66892. };
  66893. textures: {
  66894. [key: string]: IGLTFTexture;
  66895. };
  66896. shaders: {
  66897. [key: string]: IGLTFShader;
  66898. };
  66899. programs: {
  66900. [key: string]: IGLTFProgram;
  66901. };
  66902. samplers: {
  66903. [key: string]: IGLTFSampler;
  66904. };
  66905. techniques: {
  66906. [key: string]: IGLTFTechnique;
  66907. };
  66908. materials: {
  66909. [key: string]: IGLTFMaterial;
  66910. };
  66911. animations: {
  66912. [key: string]: IGLTFAnimation;
  66913. };
  66914. skins: {
  66915. [key: string]: IGLTFSkins;
  66916. };
  66917. currentScene?: Object;
  66918. scenes: {
  66919. [key: string]: IGLTFScene;
  66920. };
  66921. extensionsUsed: string[];
  66922. extensionsRequired?: string[];
  66923. buffersCount: number;
  66924. shaderscount: number;
  66925. scene: Scene;
  66926. rootUrl: string;
  66927. loadedBufferCount: number;
  66928. loadedBufferViews: {
  66929. [name: string]: ArrayBufferView;
  66930. };
  66931. loadedShaderCount: number;
  66932. importOnlyMeshes: boolean;
  66933. importMeshesNames?: string[];
  66934. dummyNodes: Node[];
  66935. }
  66936. /** @hidden */
  66937. export interface INodeToRoot {
  66938. bone: Bone;
  66939. node: IGLTFNode;
  66940. id: string;
  66941. }
  66942. /** @hidden */
  66943. export interface IJointNode {
  66944. node: IGLTFNode;
  66945. id: string;
  66946. }
  66947. }
  66948. declare module BABYLON.GLTF1 {
  66949. /**
  66950. * Utils functions for GLTF
  66951. * @hidden
  66952. */
  66953. export class GLTFUtils {
  66954. /**
  66955. * Sets the given "parameter" matrix
  66956. * @param scene: the Scene object
  66957. * @param source: the source node where to pick the matrix
  66958. * @param parameter: the GLTF technique parameter
  66959. * @param uniformName: the name of the shader's uniform
  66960. * @param shaderMaterial: the shader material
  66961. */
  66962. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66963. /**
  66964. * Sets the given "parameter" matrix
  66965. * @param shaderMaterial: the shader material
  66966. * @param uniform: the name of the shader's uniform
  66967. * @param value: the value of the uniform
  66968. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66969. */
  66970. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66971. /**
  66972. * Returns the wrap mode of the texture
  66973. * @param mode: the mode value
  66974. */
  66975. static GetWrapMode(mode: number): number;
  66976. /**
  66977. * Returns the byte stride giving an accessor
  66978. * @param accessor: the GLTF accessor objet
  66979. */
  66980. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66981. /**
  66982. * Returns the texture filter mode giving a mode value
  66983. * @param mode: the filter mode value
  66984. */
  66985. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66986. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66987. /**
  66988. * Returns a buffer from its accessor
  66989. * @param gltfRuntime: the GLTF runtime
  66990. * @param accessor: the GLTF accessor
  66991. */
  66992. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66993. /**
  66994. * Decodes a buffer view into a string
  66995. * @param view: the buffer view
  66996. */
  66997. static DecodeBufferToText(view: ArrayBufferView): string;
  66998. /**
  66999. * Returns the default material of gltf. Related to
  67000. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67001. * @param scene: the Babylon.js scene
  67002. */
  67003. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67004. private static _DefaultMaterial;
  67005. }
  67006. }
  67007. declare module BABYLON.GLTF1 {
  67008. /**
  67009. * Implementation of the base glTF spec
  67010. * @hidden
  67011. */
  67012. export class GLTFLoaderBase {
  67013. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67014. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67015. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67016. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67017. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67018. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67019. }
  67020. /**
  67021. * glTF V1 Loader
  67022. * @hidden
  67023. */
  67024. export class GLTFLoader implements IGLTFLoader {
  67025. static Extensions: {
  67026. [name: string]: GLTFLoaderExtension;
  67027. };
  67028. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67029. state: Nullable<GLTFLoaderState>;
  67030. dispose(): void;
  67031. private _importMeshAsync;
  67032. /**
  67033. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67034. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67035. * @param scene the scene the meshes should be added to
  67036. * @param data gltf data containing information of the meshes in a loaded file
  67037. * @param rootUrl root url to load from
  67038. * @param onProgress event that fires when loading progress has occured
  67039. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67040. */
  67041. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67042. meshes: AbstractMesh[];
  67043. particleSystems: IParticleSystem[];
  67044. skeletons: Skeleton[];
  67045. animationGroups: AnimationGroup[];
  67046. }>;
  67047. private _loadAsync;
  67048. /**
  67049. * Imports all objects from a loaded gltf file and adds them to the scene
  67050. * @param scene the scene the objects should be added to
  67051. * @param data gltf data containing information of the meshes in a loaded file
  67052. * @param rootUrl root url to load from
  67053. * @param onProgress event that fires when loading progress has occured
  67054. * @returns a promise which completes when objects have been loaded to the scene
  67055. */
  67056. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67057. private _loadShadersAsync;
  67058. private _loadBuffersAsync;
  67059. private _createNodes;
  67060. }
  67061. /** @hidden */
  67062. export abstract class GLTFLoaderExtension {
  67063. private _name;
  67064. constructor(name: string);
  67065. readonly name: string;
  67066. /**
  67067. * Defines an override for loading the runtime
  67068. * Return true to stop further extensions from loading the runtime
  67069. */
  67070. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67071. /**
  67072. * Defines an onverride for creating gltf runtime
  67073. * Return true to stop further extensions from creating the runtime
  67074. */
  67075. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67076. /**
  67077. * Defines an override for loading buffers
  67078. * Return true to stop further extensions from loading this buffer
  67079. */
  67080. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67081. /**
  67082. * Defines an override for loading texture buffers
  67083. * Return true to stop further extensions from loading this texture data
  67084. */
  67085. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67086. /**
  67087. * Defines an override for creating textures
  67088. * Return true to stop further extensions from loading this texture
  67089. */
  67090. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67091. /**
  67092. * Defines an override for loading shader strings
  67093. * Return true to stop further extensions from loading this shader data
  67094. */
  67095. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67096. /**
  67097. * Defines an override for loading materials
  67098. * Return true to stop further extensions from loading this material
  67099. */
  67100. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67101. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67102. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67103. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67104. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67105. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67106. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67107. private static LoadTextureBufferAsync;
  67108. private static CreateTextureAsync;
  67109. private static ApplyExtensions;
  67110. }
  67111. }
  67112. declare module BABYLON.GLTF1 {
  67113. /** @hidden */
  67114. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67115. private _bin;
  67116. constructor();
  67117. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67118. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67119. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67120. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67121. }
  67122. }
  67123. declare module BABYLON.GLTF1 {
  67124. /** @hidden */
  67125. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67126. constructor();
  67127. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67128. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67129. private _loadTexture;
  67130. }
  67131. }
  67132. declare module BABYLON.GLTF2.Loader {
  67133. /**
  67134. * Loader interface with an index field.
  67135. */
  67136. export interface IArrayItem {
  67137. /**
  67138. * The index of this item in the array.
  67139. */
  67140. index: number;
  67141. }
  67142. /**
  67143. * Loader interface with additional members.
  67144. */
  67145. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67146. /** @hidden */
  67147. _data?: Promise<ArrayBufferView>;
  67148. /** @hidden */
  67149. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67150. }
  67151. /**
  67152. * Loader interface with additional members.
  67153. */
  67154. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67155. }
  67156. /** @hidden */
  67157. export interface _IAnimationSamplerData {
  67158. input: Float32Array;
  67159. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67160. output: Float32Array;
  67161. }
  67162. /**
  67163. * Loader interface with additional members.
  67164. */
  67165. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67166. /** @hidden */
  67167. _data?: Promise<_IAnimationSamplerData>;
  67168. }
  67169. /**
  67170. * Loader interface with additional members.
  67171. */
  67172. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67173. channels: IAnimationChannel[];
  67174. samplers: IAnimationSampler[];
  67175. /** @hidden */
  67176. _babylonAnimationGroup?: AnimationGroup;
  67177. }
  67178. /**
  67179. * Loader interface with additional members.
  67180. */
  67181. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67182. /** @hidden */
  67183. _data?: Promise<ArrayBufferView>;
  67184. }
  67185. /**
  67186. * Loader interface with additional members.
  67187. */
  67188. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67189. /** @hidden */
  67190. _data?: Promise<ArrayBufferView>;
  67191. /** @hidden */
  67192. _babylonBuffer?: Promise<Buffer>;
  67193. }
  67194. /**
  67195. * Loader interface with additional members.
  67196. */
  67197. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67198. }
  67199. /**
  67200. * Loader interface with additional members.
  67201. */
  67202. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67203. /** @hidden */
  67204. _data?: Promise<ArrayBufferView>;
  67205. }
  67206. /**
  67207. * Loader interface with additional members.
  67208. */
  67209. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67210. }
  67211. /**
  67212. * Loader interface with additional members.
  67213. */
  67214. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67215. }
  67216. /**
  67217. * Loader interface with additional members.
  67218. */
  67219. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67220. baseColorTexture?: ITextureInfo;
  67221. metallicRoughnessTexture?: ITextureInfo;
  67222. }
  67223. /**
  67224. * Loader interface with additional members.
  67225. */
  67226. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67227. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67228. normalTexture?: IMaterialNormalTextureInfo;
  67229. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67230. emissiveTexture?: ITextureInfo;
  67231. /** @hidden */
  67232. _data?: {
  67233. [babylonDrawMode: number]: {
  67234. babylonMaterial: Material;
  67235. babylonMeshes: AbstractMesh[];
  67236. promise: Promise<void>;
  67237. };
  67238. };
  67239. }
  67240. /**
  67241. * Loader interface with additional members.
  67242. */
  67243. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67244. primitives: IMeshPrimitive[];
  67245. }
  67246. /**
  67247. * Loader interface with additional members.
  67248. */
  67249. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67250. /** @hidden */
  67251. _instanceData?: {
  67252. babylonSourceMesh: Mesh;
  67253. promise: Promise<any>;
  67254. };
  67255. }
  67256. /**
  67257. * Loader interface with additional members.
  67258. */
  67259. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67260. /**
  67261. * The parent glTF node.
  67262. */
  67263. parent?: INode;
  67264. /** @hidden */
  67265. _babylonTransformNode?: TransformNode;
  67266. /** @hidden */
  67267. _primitiveBabylonMeshes?: AbstractMesh[];
  67268. /** @hidden */
  67269. _babylonBones?: Bone[];
  67270. /** @hidden */
  67271. _numMorphTargets?: number;
  67272. }
  67273. /** @hidden */
  67274. export interface _ISamplerData {
  67275. noMipMaps: boolean;
  67276. samplingMode: number;
  67277. wrapU: number;
  67278. wrapV: number;
  67279. }
  67280. /**
  67281. * Loader interface with additional members.
  67282. */
  67283. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67284. /** @hidden */
  67285. _data?: _ISamplerData;
  67286. }
  67287. /**
  67288. * Loader interface with additional members.
  67289. */
  67290. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67291. }
  67292. /**
  67293. * Loader interface with additional members.
  67294. */
  67295. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67296. /** @hidden */
  67297. _data?: {
  67298. babylonSkeleton: Skeleton;
  67299. promise: Promise<void>;
  67300. };
  67301. }
  67302. /**
  67303. * Loader interface with additional members.
  67304. */
  67305. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67306. }
  67307. /**
  67308. * Loader interface with additional members.
  67309. */
  67310. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67311. }
  67312. /**
  67313. * Loader interface with additional members.
  67314. */
  67315. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67316. accessors?: IAccessor[];
  67317. animations?: IAnimation[];
  67318. buffers?: IBuffer[];
  67319. bufferViews?: IBufferView[];
  67320. cameras?: ICamera[];
  67321. images?: IImage[];
  67322. materials?: IMaterial[];
  67323. meshes?: IMesh[];
  67324. nodes?: INode[];
  67325. samplers?: ISampler[];
  67326. scenes?: IScene[];
  67327. skins?: ISkin[];
  67328. textures?: ITexture[];
  67329. }
  67330. }
  67331. declare module BABYLON.GLTF2 {
  67332. /**
  67333. * Interface for a glTF loader extension.
  67334. */
  67335. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67336. /**
  67337. * Called after the loader state changes to LOADING.
  67338. */
  67339. onLoading?(): void;
  67340. /**
  67341. * Called after the loader state changes to READY.
  67342. */
  67343. onReady?(): void;
  67344. /**
  67345. * Define this method to modify the default behavior when loading scenes.
  67346. * @param context The context when loading the asset
  67347. * @param scene The glTF scene property
  67348. * @returns A promise that resolves when the load is complete or null if not handled
  67349. */
  67350. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67351. /**
  67352. * Define this method to modify the default behavior when loading nodes.
  67353. * @param context The context when loading the asset
  67354. * @param node The glTF node property
  67355. * @param assign A function called synchronously after parsing the glTF properties
  67356. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67357. */
  67358. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67359. /**
  67360. * Define this method to modify the default behavior when loading cameras.
  67361. * @param context The context when loading the asset
  67362. * @param camera The glTF camera property
  67363. * @param assign A function called synchronously after parsing the glTF properties
  67364. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67365. */
  67366. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67367. /**
  67368. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67369. * @param context The context when loading the asset
  67370. * @param primitive The glTF mesh primitive property
  67371. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67372. */
  67373. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67374. /**
  67375. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67376. * @param context The context when loading the asset
  67377. * @param name The mesh name when loading the asset
  67378. * @param node The glTF node when loading the asset
  67379. * @param mesh The glTF mesh when loading the asset
  67380. * @param primitive The glTF mesh primitive property
  67381. * @param assign A function called synchronously after parsing the glTF properties
  67382. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67383. */
  67384. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67385. /**
  67386. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67387. * @param context The context when loading the asset
  67388. * @param material The glTF material property
  67389. * @param assign A function called synchronously after parsing the glTF properties
  67390. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67391. */
  67392. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67393. /**
  67394. * Define this method to modify the default behavior when creating materials.
  67395. * @param context The context when loading the asset
  67396. * @param material The glTF material property
  67397. * @param babylonDrawMode The draw mode for the Babylon material
  67398. * @returns The Babylon material or null if not handled
  67399. */
  67400. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67401. /**
  67402. * Define this method to modify the default behavior when loading material properties.
  67403. * @param context The context when loading the asset
  67404. * @param material The glTF material property
  67405. * @param babylonMaterial The Babylon material
  67406. * @returns A promise that resolves when the load is complete or null if not handled
  67407. */
  67408. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67409. /**
  67410. * Define this method to modify the default behavior when loading texture infos.
  67411. * @param context The context when loading the asset
  67412. * @param textureInfo The glTF texture info property
  67413. * @param assign A function called synchronously after parsing the glTF properties
  67414. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67415. */
  67416. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67417. /**
  67418. * Define this method to modify the default behavior when loading animations.
  67419. * @param context The context when loading the asset
  67420. * @param animation The glTF animation property
  67421. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67422. */
  67423. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67424. /**
  67425. * @hidden Define this method to modify the default behavior when loading skins.
  67426. * @param context The context when loading the asset
  67427. * @param node The glTF node property
  67428. * @param skin The glTF skin property
  67429. * @returns A promise that resolves when the load is complete or null if not handled
  67430. */
  67431. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67432. /**
  67433. * @hidden Define this method to modify the default behavior when loading uris.
  67434. * @param context The context when loading the asset
  67435. * @param property The glTF property associated with the uri
  67436. * @param uri The uri to load
  67437. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67438. */
  67439. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67440. }
  67441. }
  67442. declare module BABYLON.GLTF2 {
  67443. /**
  67444. * Helper class for working with arrays when loading the glTF asset
  67445. */
  67446. export class ArrayItem {
  67447. /**
  67448. * Gets an item from the given array.
  67449. * @param context The context when loading the asset
  67450. * @param array The array to get the item from
  67451. * @param index The index to the array
  67452. * @returns The array item
  67453. */
  67454. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67455. /**
  67456. * Assign an `index` field to each item of the given array.
  67457. * @param array The array of items
  67458. */
  67459. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67460. }
  67461. /**
  67462. * The glTF 2.0 loader
  67463. */
  67464. export class GLTFLoader implements IGLTFLoader {
  67465. /** @hidden */
  67466. _completePromises: Promise<any>[];
  67467. private _disposed;
  67468. private _parent;
  67469. private _state;
  67470. private _extensions;
  67471. private _rootUrl;
  67472. private _fileName;
  67473. private _uniqueRootUrl;
  67474. private _gltf;
  67475. private _babylonScene;
  67476. private _rootBabylonMesh;
  67477. private _defaultBabylonMaterialData;
  67478. private _progressCallback?;
  67479. private _requests;
  67480. private static readonly _DefaultSampler;
  67481. private static _ExtensionNames;
  67482. private static _ExtensionFactories;
  67483. /**
  67484. * Registers a loader extension.
  67485. * @param name The name of the loader extension.
  67486. * @param factory The factory function that creates the loader extension.
  67487. */
  67488. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67489. /**
  67490. * Unregisters a loader extension.
  67491. * @param name The name of the loader extenion.
  67492. * @returns A boolean indicating whether the extension has been unregistered
  67493. */
  67494. static UnregisterExtension(name: string): boolean;
  67495. /**
  67496. * Gets the loader state.
  67497. */
  67498. readonly state: Nullable<GLTFLoaderState>;
  67499. /**
  67500. * The glTF object parsed from the JSON.
  67501. */
  67502. readonly gltf: IGLTF;
  67503. /**
  67504. * The Babylon scene when loading the asset.
  67505. */
  67506. readonly babylonScene: Scene;
  67507. /**
  67508. * The root Babylon mesh when loading the asset.
  67509. */
  67510. readonly rootBabylonMesh: Mesh;
  67511. /** @hidden */
  67512. constructor(parent: GLTFFileLoader);
  67513. /** @hidden */
  67514. dispose(): void;
  67515. /** @hidden */
  67516. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67517. meshes: AbstractMesh[];
  67518. particleSystems: IParticleSystem[];
  67519. skeletons: Skeleton[];
  67520. animationGroups: AnimationGroup[];
  67521. }>;
  67522. /** @hidden */
  67523. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67524. private _loadAsync;
  67525. private _loadData;
  67526. private _setupData;
  67527. private _loadExtensions;
  67528. private _checkExtensions;
  67529. private _setState;
  67530. private _createRootNode;
  67531. /**
  67532. * Loads a glTF scene.
  67533. * @param context The context when loading the asset
  67534. * @param scene The glTF scene property
  67535. * @returns A promise that resolves when the load is complete
  67536. */
  67537. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67538. private _forEachPrimitive;
  67539. private _getMeshes;
  67540. private _getSkeletons;
  67541. private _getAnimationGroups;
  67542. private _startAnimations;
  67543. /**
  67544. * Loads a glTF node.
  67545. * @param context The context when loading the asset
  67546. * @param node The glTF node property
  67547. * @param assign A function called synchronously after parsing the glTF properties
  67548. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67549. */
  67550. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67551. private _loadMeshAsync;
  67552. /**
  67553. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67554. * @param context The context when loading the asset
  67555. * @param name The mesh name when loading the asset
  67556. * @param node The glTF node when loading the asset
  67557. * @param mesh The glTF mesh when loading the asset
  67558. * @param primitive The glTF mesh primitive property
  67559. * @param assign A function called synchronously after parsing the glTF properties
  67560. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67561. */
  67562. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67563. private _loadVertexDataAsync;
  67564. private _createMorphTargets;
  67565. private _loadMorphTargetsAsync;
  67566. private _loadMorphTargetVertexDataAsync;
  67567. private static _LoadTransform;
  67568. private _loadSkinAsync;
  67569. private _loadBones;
  67570. private _loadBone;
  67571. private _loadSkinInverseBindMatricesDataAsync;
  67572. private _updateBoneMatrices;
  67573. private _getNodeMatrix;
  67574. /**
  67575. * Loads a glTF camera.
  67576. * @param context The context when loading the asset
  67577. * @param camera The glTF camera property
  67578. * @param assign A function called synchronously after parsing the glTF properties
  67579. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67580. */
  67581. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67582. private _loadAnimationsAsync;
  67583. /**
  67584. * Loads a glTF animation.
  67585. * @param context The context when loading the asset
  67586. * @param animation The glTF animation property
  67587. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67588. */
  67589. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67590. /**
  67591. * @hidden Loads a glTF animation channel.
  67592. * @param context The context when loading the asset
  67593. * @param animationContext The context of the animation when loading the asset
  67594. * @param animation The glTF animation property
  67595. * @param channel The glTF animation channel property
  67596. * @param babylonAnimationGroup The babylon animation group property
  67597. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67598. * @returns A void promise when the channel load is complete
  67599. */
  67600. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67601. private _loadAnimationSamplerAsync;
  67602. private _loadBufferAsync;
  67603. /**
  67604. * Loads a glTF buffer view.
  67605. * @param context The context when loading the asset
  67606. * @param bufferView The glTF buffer view property
  67607. * @returns A promise that resolves with the loaded data when the load is complete
  67608. */
  67609. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67610. private _loadAccessorAsync;
  67611. private _loadFloatAccessorAsync;
  67612. private _loadIndicesAccessorAsync;
  67613. private _loadVertexBufferViewAsync;
  67614. private _loadVertexAccessorAsync;
  67615. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67616. /** @hidden */
  67617. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67618. private _createDefaultMaterial;
  67619. /**
  67620. * Creates a Babylon material from a glTF material.
  67621. * @param context The context when loading the asset
  67622. * @param material The glTF material property
  67623. * @param babylonDrawMode The draw mode for the Babylon material
  67624. * @returns The Babylon material
  67625. */
  67626. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67627. /**
  67628. * Loads properties from a glTF material into a Babylon material.
  67629. * @param context The context when loading the asset
  67630. * @param material The glTF material property
  67631. * @param babylonMaterial The Babylon material
  67632. * @returns A promise that resolves when the load is complete
  67633. */
  67634. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67635. /**
  67636. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67637. * @param context The context when loading the asset
  67638. * @param material The glTF material property
  67639. * @param babylonMaterial The Babylon material
  67640. * @returns A promise that resolves when the load is complete
  67641. */
  67642. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67643. /**
  67644. * Loads the alpha properties from a glTF material into a Babylon material.
  67645. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67646. * @param context The context when loading the asset
  67647. * @param material The glTF material property
  67648. * @param babylonMaterial The Babylon material
  67649. */
  67650. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67651. /**
  67652. * Loads a glTF texture info.
  67653. * @param context The context when loading the asset
  67654. * @param textureInfo The glTF texture info property
  67655. * @param assign A function called synchronously after parsing the glTF properties
  67656. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67657. */
  67658. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67659. private _loadTextureAsync;
  67660. private _loadSampler;
  67661. /**
  67662. * Loads a glTF image.
  67663. * @param context The context when loading the asset
  67664. * @param image The glTF image property
  67665. * @returns A promise that resolves with the loaded data when the load is complete
  67666. */
  67667. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67668. /**
  67669. * Loads a glTF uri.
  67670. * @param context The context when loading the asset
  67671. * @param property The glTF property associated with the uri
  67672. * @param uri The base64 or relative uri
  67673. * @returns A promise that resolves with the loaded data when the load is complete
  67674. */
  67675. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67676. private _onProgress;
  67677. /**
  67678. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67679. * @param babylonObject the Babylon object with metadata
  67680. * @param pointer the JSON pointer
  67681. */
  67682. static AddPointerMetadata(babylonObject: {
  67683. metadata: any;
  67684. }, pointer: string): void;
  67685. private static _GetTextureWrapMode;
  67686. private static _GetTextureSamplingMode;
  67687. private static _GetTypedArrayConstructor;
  67688. private static _GetTypedArray;
  67689. private static _GetNumComponents;
  67690. private static _ValidateUri;
  67691. private static _GetDrawMode;
  67692. private _compileMaterialsAsync;
  67693. private _compileShadowGeneratorsAsync;
  67694. private _forEachExtensions;
  67695. private _applyExtensions;
  67696. private _extensionsOnLoading;
  67697. private _extensionsOnReady;
  67698. private _extensionsLoadSceneAsync;
  67699. private _extensionsLoadNodeAsync;
  67700. private _extensionsLoadCameraAsync;
  67701. private _extensionsLoadVertexDataAsync;
  67702. private _extensionsLoadMeshPrimitiveAsync;
  67703. private _extensionsLoadMaterialAsync;
  67704. private _extensionsCreateMaterial;
  67705. private _extensionsLoadMaterialPropertiesAsync;
  67706. private _extensionsLoadTextureInfoAsync;
  67707. private _extensionsLoadAnimationAsync;
  67708. private _extensionsLoadSkinAsync;
  67709. private _extensionsLoadUriAsync;
  67710. /**
  67711. * Helper method called by a loader extension to load an glTF extension.
  67712. * @param context The context when loading the asset
  67713. * @param property The glTF property to load the extension from
  67714. * @param extensionName The name of the extension to load
  67715. * @param actionAsync The action to run
  67716. * @returns The promise returned by actionAsync or null if the extension does not exist
  67717. */
  67718. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67719. /**
  67720. * Helper method called by a loader extension to load a glTF extra.
  67721. * @param context The context when loading the asset
  67722. * @param property The glTF property to load the extra from
  67723. * @param extensionName The name of the extension to load
  67724. * @param actionAsync The action to run
  67725. * @returns The promise returned by actionAsync or null if the extra does not exist
  67726. */
  67727. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67728. /**
  67729. * Increments the indentation level and logs a message.
  67730. * @param message The message to log
  67731. */
  67732. logOpen(message: string): void;
  67733. /**
  67734. * Decrements the indentation level.
  67735. */
  67736. logClose(): void;
  67737. /**
  67738. * Logs a message
  67739. * @param message The message to log
  67740. */
  67741. log(message: string): void;
  67742. /**
  67743. * Starts a performance counter.
  67744. * @param counterName The name of the performance counter
  67745. */
  67746. startPerformanceCounter(counterName: string): void;
  67747. /**
  67748. * Ends a performance counter.
  67749. * @param counterName The name of the performance counter
  67750. */
  67751. endPerformanceCounter(counterName: string): void;
  67752. }
  67753. }
  67754. declare module BABYLON.GLTF2.Loader.Extensions {
  67755. /**
  67756. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67757. */
  67758. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67759. /** The name of this extension. */
  67760. readonly name: string;
  67761. /** Defines whether this extension is enabled. */
  67762. enabled: boolean;
  67763. private _loader;
  67764. private _lights?;
  67765. /** @hidden */
  67766. constructor(loader: GLTFLoader);
  67767. /** @hidden */
  67768. dispose(): void;
  67769. /** @hidden */
  67770. onLoading(): void;
  67771. /** @hidden */
  67772. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67773. private _loadLightAsync;
  67774. }
  67775. }
  67776. declare module BABYLON.GLTF2.Loader.Extensions {
  67777. /**
  67778. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67779. */
  67780. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67781. /** The name of this extension. */
  67782. readonly name: string;
  67783. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67784. dracoCompression?: DracoCompression;
  67785. /** Defines whether this extension is enabled. */
  67786. enabled: boolean;
  67787. private _loader;
  67788. /** @hidden */
  67789. constructor(loader: GLTFLoader);
  67790. /** @hidden */
  67791. dispose(): void;
  67792. /** @hidden */
  67793. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67794. }
  67795. }
  67796. declare module BABYLON.GLTF2.Loader.Extensions {
  67797. /**
  67798. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67799. */
  67800. export class KHR_lights implements IGLTFLoaderExtension {
  67801. /** The name of this extension. */
  67802. readonly name: string;
  67803. /** Defines whether this extension is enabled. */
  67804. enabled: boolean;
  67805. private _loader;
  67806. private _lights?;
  67807. /** @hidden */
  67808. constructor(loader: GLTFLoader);
  67809. /** @hidden */
  67810. dispose(): void;
  67811. /** @hidden */
  67812. onLoading(): void;
  67813. /** @hidden */
  67814. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67815. }
  67816. }
  67817. declare module BABYLON.GLTF2.Loader.Extensions {
  67818. /**
  67819. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67820. */
  67821. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67822. /** The name of this extension. */
  67823. readonly name: string;
  67824. /** Defines whether this extension is enabled. */
  67825. enabled: boolean;
  67826. private _loader;
  67827. /** @hidden */
  67828. constructor(loader: GLTFLoader);
  67829. /** @hidden */
  67830. dispose(): void;
  67831. /** @hidden */
  67832. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67833. private _loadSpecularGlossinessPropertiesAsync;
  67834. }
  67835. }
  67836. declare module BABYLON.GLTF2.Loader.Extensions {
  67837. /**
  67838. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67839. */
  67840. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67841. /** The name of this extension. */
  67842. readonly name: string;
  67843. /** Defines whether this extension is enabled. */
  67844. enabled: boolean;
  67845. private _loader;
  67846. /** @hidden */
  67847. constructor(loader: GLTFLoader);
  67848. /** @hidden */
  67849. dispose(): void;
  67850. /** @hidden */
  67851. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67852. private _loadUnlitPropertiesAsync;
  67853. }
  67854. }
  67855. declare module BABYLON.GLTF2.Loader.Extensions {
  67856. /**
  67857. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67858. */
  67859. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67860. /** The name of this extension. */
  67861. readonly name: string;
  67862. /** Defines whether this extension is enabled. */
  67863. enabled: boolean;
  67864. private _loader;
  67865. /** @hidden */
  67866. constructor(loader: GLTFLoader);
  67867. /** @hidden */
  67868. dispose(): void;
  67869. /** @hidden */
  67870. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67871. }
  67872. }
  67873. declare module BABYLON.GLTF2.Loader.Extensions {
  67874. /**
  67875. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67876. */
  67877. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67878. /** The name of this extension. */
  67879. readonly name: string;
  67880. /** Defines whether this extension is enabled. */
  67881. enabled: boolean;
  67882. private _loader;
  67883. private _clips;
  67884. private _emitters;
  67885. /** @hidden */
  67886. constructor(loader: GLTFLoader);
  67887. /** @hidden */
  67888. dispose(): void;
  67889. /** @hidden */
  67890. onLoading(): void;
  67891. /** @hidden */
  67892. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67893. /** @hidden */
  67894. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67895. /** @hidden */
  67896. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67897. private _loadClipAsync;
  67898. private _loadEmitterAsync;
  67899. private _getEventAction;
  67900. private _loadAnimationEventAsync;
  67901. }
  67902. }
  67903. declare module BABYLON.GLTF2.Loader.Extensions {
  67904. /**
  67905. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67906. */
  67907. export class MSFT_lod implements IGLTFLoaderExtension {
  67908. /** The name of this extension. */
  67909. readonly name: string;
  67910. /** Defines whether this extension is enabled. */
  67911. enabled: boolean;
  67912. /**
  67913. * Maximum number of LODs to load, starting from the lowest LOD.
  67914. */
  67915. maxLODsToLoad: number;
  67916. /**
  67917. * Observable raised when all node LODs of one level are loaded.
  67918. * The event data is the index of the loaded LOD starting from zero.
  67919. * Dispose the loader to cancel the loading of the next level of LODs.
  67920. */
  67921. onNodeLODsLoadedObservable: Observable<number>;
  67922. /**
  67923. * Observable raised when all material LODs of one level are loaded.
  67924. * The event data is the index of the loaded LOD starting from zero.
  67925. * Dispose the loader to cancel the loading of the next level of LODs.
  67926. */
  67927. onMaterialLODsLoadedObservable: Observable<number>;
  67928. private _loader;
  67929. private _nodeIndexLOD;
  67930. private _nodeSignalLODs;
  67931. private _nodePromiseLODs;
  67932. private _materialIndexLOD;
  67933. private _materialSignalLODs;
  67934. private _materialPromiseLODs;
  67935. /** @hidden */
  67936. constructor(loader: GLTFLoader);
  67937. /** @hidden */
  67938. dispose(): void;
  67939. /** @hidden */
  67940. onReady(): void;
  67941. /** @hidden */
  67942. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67943. /** @hidden */
  67944. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67945. /** @hidden */
  67946. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67947. /**
  67948. * Gets an array of LOD properties from lowest to highest.
  67949. */
  67950. private _getLODs;
  67951. private _disposeUnusedMaterials;
  67952. }
  67953. }
  67954. declare module BABYLON.GLTF2.Loader.Extensions {
  67955. /** @hidden */
  67956. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67957. readonly name: string;
  67958. enabled: boolean;
  67959. private _loader;
  67960. constructor(loader: GLTFLoader);
  67961. dispose(): void;
  67962. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67963. }
  67964. }
  67965. declare module BABYLON.GLTF2.Loader.Extensions {
  67966. /** @hidden */
  67967. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67968. readonly name: string;
  67969. enabled: boolean;
  67970. private _loader;
  67971. constructor(loader: GLTFLoader);
  67972. dispose(): void;
  67973. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67974. }
  67975. }
  67976. declare module BABYLON.GLTF2.Loader.Extensions {
  67977. /**
  67978. * Store glTF extras (if present) in BJS objects' metadata
  67979. */
  67980. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67981. /** The name of this extension. */
  67982. readonly name: string;
  67983. /** Defines whether this extension is enabled. */
  67984. enabled: boolean;
  67985. private _loader;
  67986. private _assignExtras;
  67987. /** @hidden */
  67988. constructor(loader: GLTFLoader);
  67989. /** @hidden */
  67990. dispose(): void;
  67991. /** @hidden */
  67992. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67993. /** @hidden */
  67994. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67995. /** @hidden */
  67996. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67997. }
  67998. }
  67999. declare module BABYLON {
  68000. /**
  68001. * Class reading and parsing the MTL file bundled with the obj file.
  68002. */
  68003. export class MTLFileLoader {
  68004. /**
  68005. * All material loaded from the mtl will be set here
  68006. */
  68007. materials: StandardMaterial[];
  68008. /**
  68009. * This function will read the mtl file and create each material described inside
  68010. * This function could be improve by adding :
  68011. * -some component missing (Ni, Tf...)
  68012. * -including the specific options available
  68013. *
  68014. * @param scene defines the scene the material will be created in
  68015. * @param data defines the mtl data to parse
  68016. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68017. */
  68018. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68019. /**
  68020. * Gets the texture for the material.
  68021. *
  68022. * If the material is imported from input file,
  68023. * We sanitize the url to ensure it takes the textre from aside the material.
  68024. *
  68025. * @param rootUrl The root url to load from
  68026. * @param value The value stored in the mtl
  68027. * @return The Texture
  68028. */
  68029. private static _getTexture;
  68030. }
  68031. /**
  68032. * Options for loading OBJ/MTL files
  68033. */
  68034. type MeshLoadOptions = {
  68035. /**
  68036. * Defines if UVs are optimized by default during load.
  68037. */
  68038. OptimizeWithUV: boolean;
  68039. /**
  68040. * Defines custom scaling of UV coordinates of loaded meshes.
  68041. */
  68042. UVScaling: Vector2;
  68043. /**
  68044. * Invert model on y-axis (does a model scaling inversion)
  68045. */
  68046. InvertY: boolean;
  68047. /**
  68048. * Invert Y-Axis of referenced textures on load
  68049. */
  68050. InvertTextureY: boolean;
  68051. /**
  68052. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68053. */
  68054. ImportVertexColors: boolean;
  68055. /**
  68056. * Compute the normals for the model, even if normals are present in the file.
  68057. */
  68058. ComputeNormals: boolean;
  68059. /**
  68060. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68061. */
  68062. SkipMaterials: boolean;
  68063. /**
  68064. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68065. */
  68066. MaterialLoadingFailsSilently: boolean;
  68067. };
  68068. /**
  68069. * OBJ file type loader.
  68070. * This is a babylon scene loader plugin.
  68071. */
  68072. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68073. /**
  68074. * Defines if UVs are optimized by default during load.
  68075. */
  68076. static OPTIMIZE_WITH_UV: boolean;
  68077. /**
  68078. * Invert model on y-axis (does a model scaling inversion)
  68079. */
  68080. static INVERT_Y: boolean;
  68081. /**
  68082. * Invert Y-Axis of referenced textures on load
  68083. */
  68084. static INVERT_TEXTURE_Y: boolean;
  68085. /**
  68086. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68087. */
  68088. static IMPORT_VERTEX_COLORS: boolean;
  68089. /**
  68090. * Compute the normals for the model, even if normals are present in the file.
  68091. */
  68092. static COMPUTE_NORMALS: boolean;
  68093. /**
  68094. * Defines custom scaling of UV coordinates of loaded meshes.
  68095. */
  68096. static UV_SCALING: Vector2;
  68097. /**
  68098. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68099. */
  68100. static SKIP_MATERIALS: boolean;
  68101. /**
  68102. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68103. *
  68104. * Defaults to true for backwards compatibility.
  68105. */
  68106. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68107. /**
  68108. * Defines the name of the plugin.
  68109. */
  68110. name: string;
  68111. /**
  68112. * Defines the extension the plugin is able to load.
  68113. */
  68114. extensions: string;
  68115. /** @hidden */
  68116. obj: RegExp;
  68117. /** @hidden */
  68118. group: RegExp;
  68119. /** @hidden */
  68120. mtllib: RegExp;
  68121. /** @hidden */
  68122. usemtl: RegExp;
  68123. /** @hidden */
  68124. smooth: RegExp;
  68125. /** @hidden */
  68126. vertexPattern: RegExp;
  68127. /** @hidden */
  68128. normalPattern: RegExp;
  68129. /** @hidden */
  68130. uvPattern: RegExp;
  68131. /** @hidden */
  68132. facePattern1: RegExp;
  68133. /** @hidden */
  68134. facePattern2: RegExp;
  68135. /** @hidden */
  68136. facePattern3: RegExp;
  68137. /** @hidden */
  68138. facePattern4: RegExp;
  68139. /** @hidden */
  68140. facePattern5: RegExp;
  68141. private _meshLoadOptions;
  68142. /**
  68143. * Creates loader for .OBJ files
  68144. *
  68145. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68146. */
  68147. constructor(meshLoadOptions?: MeshLoadOptions);
  68148. private static readonly currentMeshLoadOptions;
  68149. /**
  68150. * Calls synchronously the MTL file attached to this obj.
  68151. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68152. * Without this function materials are not displayed in the first frame (but displayed after).
  68153. * In consequence it is impossible to get material information in your HTML file
  68154. *
  68155. * @param url The URL of the MTL file
  68156. * @param rootUrl
  68157. * @param onSuccess Callback function to be called when the MTL file is loaded
  68158. * @private
  68159. */
  68160. private _loadMTL;
  68161. /**
  68162. * Instantiates a OBJ file loader plugin.
  68163. * @returns the created plugin
  68164. */
  68165. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68166. /**
  68167. * If the data string can be loaded directly.
  68168. *
  68169. * @param data string containing the file data
  68170. * @returns if the data can be loaded directly
  68171. */
  68172. canDirectLoad(data: string): boolean;
  68173. /**
  68174. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68175. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68176. * @param scene the scene the meshes should be added to
  68177. * @param data the OBJ data to load
  68178. * @param rootUrl root url to load from
  68179. * @param onProgress event that fires when loading progress has occured
  68180. * @param fileName Defines the name of the file to load
  68181. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68182. */
  68183. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68184. meshes: AbstractMesh[];
  68185. particleSystems: IParticleSystem[];
  68186. skeletons: Skeleton[];
  68187. animationGroups: AnimationGroup[];
  68188. }>;
  68189. /**
  68190. * Imports all objects from the loaded OBJ data and adds them to the scene
  68191. * @param scene the scene the objects should be added to
  68192. * @param data the OBJ data to load
  68193. * @param rootUrl root url to load from
  68194. * @param onProgress event that fires when loading progress has occured
  68195. * @param fileName Defines the name of the file to load
  68196. * @returns a promise which completes when objects have been loaded to the scene
  68197. */
  68198. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68199. /**
  68200. * Load into an asset container.
  68201. * @param scene The scene to load into
  68202. * @param data The data to import
  68203. * @param rootUrl The root url for scene and resources
  68204. * @param onProgress The callback when the load progresses
  68205. * @param fileName Defines the name of the file to load
  68206. * @returns The loaded asset container
  68207. */
  68208. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68209. /**
  68210. * Read the OBJ file and create an Array of meshes.
  68211. * Each mesh contains all information given by the OBJ and the MTL file.
  68212. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68213. *
  68214. * @param meshesNames
  68215. * @param scene Scene The scene where are displayed the data
  68216. * @param data String The content of the obj file
  68217. * @param rootUrl String The path to the folder
  68218. * @returns Array<AbstractMesh>
  68219. * @private
  68220. */
  68221. private _parseSolid;
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /**
  68226. * STL file type loader.
  68227. * This is a babylon scene loader plugin.
  68228. */
  68229. export class STLFileLoader implements ISceneLoaderPlugin {
  68230. /** @hidden */
  68231. solidPattern: RegExp;
  68232. /** @hidden */
  68233. facetsPattern: RegExp;
  68234. /** @hidden */
  68235. normalPattern: RegExp;
  68236. /** @hidden */
  68237. vertexPattern: RegExp;
  68238. /**
  68239. * Defines the name of the plugin.
  68240. */
  68241. name: string;
  68242. /**
  68243. * Defines the extensions the stl loader is able to load.
  68244. * force data to come in as an ArrayBuffer
  68245. * we'll convert to string if it looks like it's an ASCII .stl
  68246. */
  68247. extensions: ISceneLoaderPluginExtensions;
  68248. /**
  68249. * Import meshes into a scene.
  68250. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68251. * @param scene The scene to import into
  68252. * @param data The data to import
  68253. * @param rootUrl The root url for scene and resources
  68254. * @param meshes The meshes array to import into
  68255. * @param particleSystems The particle systems array to import into
  68256. * @param skeletons The skeletons array to import into
  68257. * @param onError The callback when import fails
  68258. * @returns True if successful or false otherwise
  68259. */
  68260. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68261. /**
  68262. * Load into a scene.
  68263. * @param scene The scene to load into
  68264. * @param data The data to import
  68265. * @param rootUrl The root url for scene and resources
  68266. * @param onError The callback when import fails
  68267. * @returns true if successful or false otherwise
  68268. */
  68269. load(scene: Scene, data: any, rootUrl: string): boolean;
  68270. /**
  68271. * Load into an asset container.
  68272. * @param scene The scene to load into
  68273. * @param data The data to import
  68274. * @param rootUrl The root url for scene and resources
  68275. * @param onError The callback when import fails
  68276. * @returns The loaded asset container
  68277. */
  68278. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68279. private _isBinary;
  68280. private _parseBinary;
  68281. private _parseASCII;
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. /**
  68286. * Class for generating OBJ data from a Babylon scene.
  68287. */
  68288. export class OBJExport {
  68289. /**
  68290. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68291. * @param mesh defines the list of meshes to serialize
  68292. * @param materials defines if materials should be exported
  68293. * @param matlibname defines the name of the associated mtl file
  68294. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68295. * @returns the OBJ content
  68296. */
  68297. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68298. /**
  68299. * Exports the material(s) of a mesh in .MTL file format (text)
  68300. * @param mesh defines the mesh to extract the material from
  68301. * @returns the mtl content
  68302. */
  68303. static MTL(mesh: Mesh): string;
  68304. }
  68305. }
  68306. declare module BABYLON {
  68307. /** @hidden */
  68308. export var __IGLTFExporterExtension: number;
  68309. /**
  68310. * Interface for extending the exporter
  68311. * @hidden
  68312. */
  68313. export interface IGLTFExporterExtension {
  68314. /**
  68315. * The name of this extension
  68316. */
  68317. readonly name: string;
  68318. /**
  68319. * Defines whether this extension is enabled
  68320. */
  68321. enabled: boolean;
  68322. /**
  68323. * Defines whether this extension is required
  68324. */
  68325. required: boolean;
  68326. }
  68327. }
  68328. declare module BABYLON.GLTF2.Exporter {
  68329. /** @hidden */
  68330. export var __IGLTFExporterExtensionV2: number;
  68331. /**
  68332. * Interface for a glTF exporter extension
  68333. * @hidden
  68334. */
  68335. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68336. /**
  68337. * Define this method to modify the default behavior before exporting a texture
  68338. * @param context The context when loading the asset
  68339. * @param babylonTexture The glTF texture info property
  68340. * @param mimeType The mime-type of the generated image
  68341. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68342. */
  68343. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68344. /**
  68345. * Define this method to modify the default behavior when exporting texture info
  68346. * @param context The context when loading the asset
  68347. * @param meshPrimitive glTF mesh primitive
  68348. * @param babylonSubMesh Babylon submesh
  68349. * @param binaryWriter glTF serializer binary writer instance
  68350. * @returns nullable IMeshPrimitive promise
  68351. */
  68352. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68353. /**
  68354. * Define this method to modify the default behavior when exporting a node
  68355. * @param context The context when exporting the node
  68356. * @param node glTF node
  68357. * @param babylonNode BabylonJS node
  68358. * @returns nullable INode promise
  68359. */
  68360. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68361. /**
  68362. * Called after the exporter state changes to EXPORTING
  68363. */
  68364. onExporting?(): void;
  68365. }
  68366. }
  68367. declare module BABYLON.GLTF2.Exporter {
  68368. /**
  68369. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68370. * @hidden
  68371. */
  68372. export class _GLTFMaterialExporter {
  68373. /**
  68374. * Represents the dielectric specular values for R, G and B
  68375. */
  68376. private static readonly _DielectricSpecular;
  68377. /**
  68378. * Allows the maximum specular power to be defined for material calculations
  68379. */
  68380. private static readonly _MaxSpecularPower;
  68381. /**
  68382. * Mapping to store textures
  68383. */
  68384. private _textureMap;
  68385. /**
  68386. * Numeric tolerance value
  68387. */
  68388. private static readonly _Epsilon;
  68389. /**
  68390. * Reference to the glTF Exporter
  68391. */
  68392. private _exporter;
  68393. constructor(exporter: _Exporter);
  68394. /**
  68395. * Specifies if two colors are approximately equal in value
  68396. * @param color1 first color to compare to
  68397. * @param color2 second color to compare to
  68398. * @param epsilon threshold value
  68399. */
  68400. private static FuzzyEquals;
  68401. /**
  68402. * Gets the materials from a Babylon scene and converts them to glTF materials
  68403. * @param scene babylonjs scene
  68404. * @param mimeType texture mime type
  68405. * @param images array of images
  68406. * @param textures array of textures
  68407. * @param materials array of materials
  68408. * @param imageData mapping of texture names to base64 textures
  68409. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68410. */
  68411. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68412. /**
  68413. * Makes a copy of the glTF material without the texture parameters
  68414. * @param originalMaterial original glTF material
  68415. * @returns glTF material without texture parameters
  68416. */
  68417. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68418. /**
  68419. * Specifies if the material has any texture parameters present
  68420. * @param material glTF Material
  68421. * @returns boolean specifying if texture parameters are present
  68422. */
  68423. _hasTexturesPresent(material: IMaterial): boolean;
  68424. /**
  68425. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68426. * @param babylonStandardMaterial
  68427. * @returns glTF Metallic Roughness Material representation
  68428. */
  68429. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68430. /**
  68431. * Computes the metallic factor
  68432. * @param diffuse diffused value
  68433. * @param specular specular value
  68434. * @param oneMinusSpecularStrength one minus the specular strength
  68435. * @returns metallic value
  68436. */
  68437. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68438. /**
  68439. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68440. * @param glTFMaterial glTF material
  68441. * @param babylonMaterial Babylon material
  68442. */
  68443. private static _SetAlphaMode;
  68444. /**
  68445. * Converts a Babylon Standard Material to a glTF Material
  68446. * @param babylonStandardMaterial BJS Standard Material
  68447. * @param mimeType mime type to use for the textures
  68448. * @param images array of glTF image interfaces
  68449. * @param textures array of glTF texture interfaces
  68450. * @param materials array of glTF material interfaces
  68451. * @param imageData map of image file name to data
  68452. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68453. */
  68454. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68455. /**
  68456. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68457. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68458. * @param mimeType mime type to use for the textures
  68459. * @param images array of glTF image interfaces
  68460. * @param textures array of glTF texture interfaces
  68461. * @param materials array of glTF material interfaces
  68462. * @param imageData map of image file name to data
  68463. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68464. */
  68465. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68466. /**
  68467. * Converts an image typed array buffer to a base64 image
  68468. * @param buffer typed array buffer
  68469. * @param width width of the image
  68470. * @param height height of the image
  68471. * @param mimeType mimetype of the image
  68472. * @returns base64 image string
  68473. */
  68474. private _createBase64FromCanvasAsync;
  68475. /**
  68476. * Generates a white texture based on the specified width and height
  68477. * @param width width of the texture in pixels
  68478. * @param height height of the texture in pixels
  68479. * @param scene babylonjs scene
  68480. * @returns white texture
  68481. */
  68482. private _createWhiteTexture;
  68483. /**
  68484. * 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
  68485. * @param texture1 first texture to resize
  68486. * @param texture2 second texture to resize
  68487. * @param scene babylonjs scene
  68488. * @returns resized textures or null
  68489. */
  68490. private _resizeTexturesToSameDimensions;
  68491. /**
  68492. * Converts an array of pixels to a Float32Array
  68493. * Throws an error if the pixel format is not supported
  68494. * @param pixels - array buffer containing pixel values
  68495. * @returns Float32 of pixels
  68496. */
  68497. private _convertPixelArrayToFloat32;
  68498. /**
  68499. * Convert Specular Glossiness Textures to Metallic Roughness
  68500. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68501. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68502. * @param diffuseTexture texture used to store diffuse information
  68503. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68504. * @param factors specular glossiness material factors
  68505. * @param mimeType the mime type to use for the texture
  68506. * @returns pbr metallic roughness interface or null
  68507. */
  68508. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68509. /**
  68510. * Converts specular glossiness material properties to metallic roughness
  68511. * @param specularGlossiness interface with specular glossiness material properties
  68512. * @returns interface with metallic roughness material properties
  68513. */
  68514. private _convertSpecularGlossinessToMetallicRoughness;
  68515. /**
  68516. * Calculates the surface reflectance, independent of lighting conditions
  68517. * @param color Color source to calculate brightness from
  68518. * @returns number representing the perceived brightness, or zero if color is undefined
  68519. */
  68520. private _getPerceivedBrightness;
  68521. /**
  68522. * Returns the maximum color component value
  68523. * @param color
  68524. * @returns maximum color component value, or zero if color is null or undefined
  68525. */
  68526. private _getMaxComponent;
  68527. /**
  68528. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68529. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68530. * @param mimeType mime type to use for the textures
  68531. * @param images array of glTF image interfaces
  68532. * @param textures array of glTF texture interfaces
  68533. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68534. * @param imageData map of image file name to data
  68535. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68536. * @returns glTF PBR Metallic Roughness factors
  68537. */
  68538. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68539. private _getGLTFTextureSampler;
  68540. private _getGLTFTextureWrapMode;
  68541. private _getGLTFTextureWrapModesSampler;
  68542. /**
  68543. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68544. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68545. * @param mimeType mime type to use for the textures
  68546. * @param images array of glTF image interfaces
  68547. * @param textures array of glTF texture interfaces
  68548. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68549. * @param imageData map of image file name to data
  68550. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68551. * @returns glTF PBR Metallic Roughness factors
  68552. */
  68553. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68554. /**
  68555. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68556. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68557. * @param mimeType mime type to use for the textures
  68558. * @param images array of glTF image interfaces
  68559. * @param textures array of glTF texture interfaces
  68560. * @param materials array of glTF material interfaces
  68561. * @param imageData map of image file name to data
  68562. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68563. */
  68564. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68565. private setMetallicRoughnessPbrMaterial;
  68566. private getPixelsFromTexture;
  68567. /**
  68568. * Extracts a texture from a Babylon texture into file data and glTF data
  68569. * @param babylonTexture Babylon texture to extract
  68570. * @param mimeType Mime Type of the babylonTexture
  68571. * @return glTF texture info, or null if the texture format is not supported
  68572. */
  68573. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68574. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68575. /**
  68576. * Builds a texture from base64 string
  68577. * @param base64Texture base64 texture string
  68578. * @param baseTextureName Name to use for the texture
  68579. * @param mimeType image mime type for the texture
  68580. * @param images array of images
  68581. * @param textures array of textures
  68582. * @param imageData map of image data
  68583. * @returns glTF texture info, or null if the texture format is not supported
  68584. */
  68585. private _getTextureInfoFromBase64;
  68586. }
  68587. }
  68588. declare module BABYLON {
  68589. /**
  68590. * Class for holding and downloading glTF file data
  68591. */
  68592. export class GLTFData {
  68593. /**
  68594. * Object which contains the file name as the key and its data as the value
  68595. */
  68596. glTFFiles: {
  68597. [fileName: string]: string | Blob;
  68598. };
  68599. /**
  68600. * Initializes the glTF file object
  68601. */
  68602. constructor();
  68603. /**
  68604. * Downloads the glTF data as files based on their names and data
  68605. */
  68606. downloadFiles(): void;
  68607. }
  68608. }
  68609. declare module BABYLON {
  68610. /**
  68611. * Holds a collection of exporter options and parameters
  68612. */
  68613. export interface IExportOptions {
  68614. /**
  68615. * Function which indicates whether a babylon node should be exported or not
  68616. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68617. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68618. */
  68619. shouldExportNode?(node: Node): boolean;
  68620. /**
  68621. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68622. * @param metadata source metadata to read from
  68623. * @returns the data to store to glTF node extras
  68624. */
  68625. metadataSelector?(metadata: any): any;
  68626. /**
  68627. * The sample rate to bake animation curves
  68628. */
  68629. animationSampleRate?: number;
  68630. /**
  68631. * Begin serialization without waiting for the scene to be ready
  68632. */
  68633. exportWithoutWaitingForScene?: boolean;
  68634. }
  68635. /**
  68636. * Class for generating glTF data from a Babylon scene.
  68637. */
  68638. export class GLTF2Export {
  68639. /**
  68640. * Exports the geometry of the scene to .gltf file format asynchronously
  68641. * @param scene Babylon scene with scene hierarchy information
  68642. * @param filePrefix File prefix to use when generating the glTF file
  68643. * @param options Exporter options
  68644. * @returns Returns an object with a .gltf file and associates texture names
  68645. * as keys and their data and paths as values
  68646. */
  68647. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68648. private static _PreExportAsync;
  68649. private static _PostExportAsync;
  68650. /**
  68651. * Exports the geometry of the scene to .glb file format asychronously
  68652. * @param scene Babylon scene with scene hierarchy information
  68653. * @param filePrefix File prefix to use when generating glb file
  68654. * @param options Exporter options
  68655. * @returns Returns an object with a .glb filename as key and data as value
  68656. */
  68657. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68658. }
  68659. }
  68660. declare module BABYLON.GLTF2.Exporter {
  68661. /**
  68662. * @hidden
  68663. */
  68664. export class _GLTFUtilities {
  68665. /**
  68666. * Creates a buffer view based on the supplied arguments
  68667. * @param bufferIndex index value of the specified buffer
  68668. * @param byteOffset byte offset value
  68669. * @param byteLength byte length of the bufferView
  68670. * @param byteStride byte distance between conequential elements
  68671. * @param name name of the buffer view
  68672. * @returns bufferView for glTF
  68673. */
  68674. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68675. /**
  68676. * Creates an accessor based on the supplied arguments
  68677. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68678. * @param name The name of the accessor
  68679. * @param type The type of the accessor
  68680. * @param componentType The datatype of components in the attribute
  68681. * @param count The number of attributes referenced by this accessor
  68682. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68683. * @param min Minimum value of each component in this attribute
  68684. * @param max Maximum value of each component in this attribute
  68685. * @returns accessor for glTF
  68686. */
  68687. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68688. /**
  68689. * Calculates the minimum and maximum values of an array of position floats
  68690. * @param positions Positions array of a mesh
  68691. * @param vertexStart Starting vertex offset to calculate min and max values
  68692. * @param vertexCount Number of vertices to check for min and max values
  68693. * @returns min number array and max number array
  68694. */
  68695. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68696. min: number[];
  68697. max: number[];
  68698. };
  68699. /**
  68700. * Converts a new right-handed Vector3
  68701. * @param vector vector3 array
  68702. * @returns right-handed Vector3
  68703. */
  68704. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68705. /**
  68706. * Converts a Vector3 to right-handed
  68707. * @param vector Vector3 to convert to right-handed
  68708. */
  68709. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68710. /**
  68711. * Converts a three element number array to right-handed
  68712. * @param vector number array to convert to right-handed
  68713. */
  68714. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68715. /**
  68716. * Converts a new right-handed Vector3
  68717. * @param vector vector3 array
  68718. * @returns right-handed Vector3
  68719. */
  68720. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68721. /**
  68722. * Converts a Vector3 to right-handed
  68723. * @param vector Vector3 to convert to right-handed
  68724. */
  68725. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68726. /**
  68727. * Converts a three element number array to right-handed
  68728. * @param vector number array to convert to right-handed
  68729. */
  68730. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68731. /**
  68732. * Converts a Vector4 to right-handed
  68733. * @param vector Vector4 to convert to right-handed
  68734. */
  68735. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68736. /**
  68737. * Converts a Vector4 to right-handed
  68738. * @param vector Vector4 to convert to right-handed
  68739. */
  68740. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68741. /**
  68742. * Converts a Quaternion to right-handed
  68743. * @param quaternion Source quaternion to convert to right-handed
  68744. */
  68745. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68746. /**
  68747. * Converts a Quaternion to right-handed
  68748. * @param quaternion Source quaternion to convert to right-handed
  68749. */
  68750. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68751. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68752. }
  68753. }
  68754. declare module BABYLON.GLTF2.Exporter {
  68755. /**
  68756. * Converts Babylon Scene into glTF 2.0.
  68757. * @hidden
  68758. */
  68759. export class _Exporter {
  68760. /**
  68761. * Stores the glTF to export
  68762. */
  68763. _glTF: IGLTF;
  68764. /**
  68765. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68766. */
  68767. _bufferViews: IBufferView[];
  68768. /**
  68769. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68770. */
  68771. _accessors: IAccessor[];
  68772. /**
  68773. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68774. */
  68775. private _nodes;
  68776. /**
  68777. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68778. */
  68779. private _scenes;
  68780. /**
  68781. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68782. */
  68783. private _meshes;
  68784. /**
  68785. * Stores all the generated material information, which represents the appearance of each primitive
  68786. */
  68787. _materials: IMaterial[];
  68788. _materialMap: {
  68789. [materialID: number]: number;
  68790. };
  68791. /**
  68792. * Stores all the generated texture information, which is referenced by glTF materials
  68793. */
  68794. _textures: ITexture[];
  68795. /**
  68796. * Stores all the generated image information, which is referenced by glTF textures
  68797. */
  68798. _images: IImage[];
  68799. /**
  68800. * Stores all the texture samplers
  68801. */
  68802. _samplers: ISampler[];
  68803. /**
  68804. * Stores all the generated animation samplers, which is referenced by glTF animations
  68805. */
  68806. /**
  68807. * Stores the animations for glTF models
  68808. */
  68809. private _animations;
  68810. /**
  68811. * Stores the total amount of bytes stored in the glTF buffer
  68812. */
  68813. private _totalByteLength;
  68814. /**
  68815. * Stores a reference to the Babylon scene containing the source geometry and material information
  68816. */
  68817. _babylonScene: Scene;
  68818. /**
  68819. * Stores a map of the image data, where the key is the file name and the value
  68820. * is the image data
  68821. */
  68822. _imageData: {
  68823. [fileName: string]: {
  68824. data: Uint8Array;
  68825. mimeType: ImageMimeType;
  68826. };
  68827. };
  68828. /**
  68829. * Stores a map of the unique id of a node to its index in the node array
  68830. */
  68831. private _nodeMap;
  68832. /**
  68833. * Specifies if the Babylon scene should be converted to right-handed on export
  68834. */
  68835. _convertToRightHandedSystem: boolean;
  68836. /**
  68837. * Baked animation sample rate
  68838. */
  68839. private _animationSampleRate;
  68840. private _options;
  68841. private _localEngine;
  68842. _glTFMaterialExporter: _GLTFMaterialExporter;
  68843. private _extensions;
  68844. private static _ExtensionNames;
  68845. private static _ExtensionFactories;
  68846. private _applyExtensions;
  68847. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68848. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68849. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68850. private _forEachExtensions;
  68851. private _extensionsOnExporting;
  68852. /**
  68853. * Load glTF serializer extensions
  68854. */
  68855. private _loadExtensions;
  68856. /**
  68857. * Creates a glTF Exporter instance, which can accept optional exporter options
  68858. * @param babylonScene Babylon scene object
  68859. * @param options Options to modify the behavior of the exporter
  68860. */
  68861. constructor(babylonScene: Scene, options?: IExportOptions);
  68862. /**
  68863. * Registers a glTF exporter extension
  68864. * @param name Name of the extension to export
  68865. * @param factory The factory function that creates the exporter extension
  68866. */
  68867. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68868. /**
  68869. * Un-registers an exporter extension
  68870. * @param name The name fo the exporter extension
  68871. * @returns A boolean indicating whether the extension has been un-registered
  68872. */
  68873. static UnregisterExtension(name: string): boolean;
  68874. /**
  68875. * Lazy load a local engine with premultiplied alpha set to false
  68876. */
  68877. _getLocalEngine(): Engine;
  68878. private reorderIndicesBasedOnPrimitiveMode;
  68879. /**
  68880. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68881. * clock-wise during export to glTF
  68882. * @param submesh BabylonJS submesh
  68883. * @param primitiveMode Primitive mode of the mesh
  68884. * @param sideOrientation the winding order of the submesh
  68885. * @param vertexBufferKind The type of vertex attribute
  68886. * @param meshAttributeArray The vertex attribute data
  68887. * @param byteOffset The offset to the binary data
  68888. * @param binaryWriter The binary data for the glTF file
  68889. */
  68890. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68891. /**
  68892. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68893. * clock-wise during export to glTF
  68894. * @param submesh BabylonJS submesh
  68895. * @param primitiveMode Primitive mode of the mesh
  68896. * @param sideOrientation the winding order of the submesh
  68897. * @param vertexBufferKind The type of vertex attribute
  68898. * @param meshAttributeArray The vertex attribute data
  68899. * @param byteOffset The offset to the binary data
  68900. * @param binaryWriter The binary data for the glTF file
  68901. */
  68902. private reorderTriangleFillMode;
  68903. /**
  68904. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68905. * clock-wise during export to glTF
  68906. * @param submesh BabylonJS submesh
  68907. * @param primitiveMode Primitive mode of the mesh
  68908. * @param sideOrientation the winding order of the submesh
  68909. * @param vertexBufferKind The type of vertex attribute
  68910. * @param meshAttributeArray The vertex attribute data
  68911. * @param byteOffset The offset to the binary data
  68912. * @param binaryWriter The binary data for the glTF file
  68913. */
  68914. private reorderTriangleStripDrawMode;
  68915. /**
  68916. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68917. * clock-wise during export to glTF
  68918. * @param submesh BabylonJS submesh
  68919. * @param primitiveMode Primitive mode of the mesh
  68920. * @param sideOrientation the winding order of the submesh
  68921. * @param vertexBufferKind The type of vertex attribute
  68922. * @param meshAttributeArray The vertex attribute data
  68923. * @param byteOffset The offset to the binary data
  68924. * @param binaryWriter The binary data for the glTF file
  68925. */
  68926. private reorderTriangleFanMode;
  68927. /**
  68928. * Writes the vertex attribute data to binary
  68929. * @param vertices The vertices to write to the binary writer
  68930. * @param byteOffset The offset into the binary writer to overwrite binary data
  68931. * @param vertexAttributeKind The vertex attribute type
  68932. * @param meshAttributeArray The vertex attribute data
  68933. * @param binaryWriter The writer containing the binary data
  68934. */
  68935. private writeVertexAttributeData;
  68936. /**
  68937. * Writes mesh attribute data to a data buffer
  68938. * Returns the bytelength of the data
  68939. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68940. * @param meshAttributeArray Array containing the attribute data
  68941. * @param binaryWriter The buffer to write the binary data to
  68942. * @param indices Used to specify the order of the vertex data
  68943. */
  68944. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68945. /**
  68946. * Generates glTF json data
  68947. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68948. * @param glTFPrefix Text to use when prefixing a glTF file
  68949. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68950. * @returns json data as string
  68951. */
  68952. private generateJSON;
  68953. /**
  68954. * Generates data for .gltf and .bin files based on the glTF prefix string
  68955. * @param glTFPrefix Text to use when prefixing a glTF file
  68956. * @returns GLTFData with glTF file data
  68957. */
  68958. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68959. /**
  68960. * Creates a binary buffer for glTF
  68961. * @returns array buffer for binary data
  68962. */
  68963. private _generateBinaryAsync;
  68964. /**
  68965. * Pads the number to a multiple of 4
  68966. * @param num number to pad
  68967. * @returns padded number
  68968. */
  68969. private _getPadding;
  68970. /**
  68971. * Generates a glb file from the json and binary data
  68972. * Returns an object with the glb file name as the key and data as the value
  68973. * @param glTFPrefix
  68974. * @returns object with glb filename as key and data as value
  68975. */
  68976. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68977. /**
  68978. * Sets the TRS for each node
  68979. * @param node glTF Node for storing the transformation data
  68980. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68981. */
  68982. private setNodeTransformation;
  68983. private getVertexBufferFromMesh;
  68984. /**
  68985. * Creates a bufferview based on the vertices type for the Babylon mesh
  68986. * @param kind Indicates the type of vertices data
  68987. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68988. * @param binaryWriter The buffer to write the bufferview data to
  68989. */
  68990. private createBufferViewKind;
  68991. /**
  68992. * The primitive mode of the Babylon mesh
  68993. * @param babylonMesh The BabylonJS mesh
  68994. */
  68995. private getMeshPrimitiveMode;
  68996. /**
  68997. * Sets the primitive mode of the glTF mesh primitive
  68998. * @param meshPrimitive glTF mesh primitive
  68999. * @param primitiveMode The primitive mode
  69000. */
  69001. private setPrimitiveMode;
  69002. /**
  69003. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69004. * @param meshPrimitive glTF mesh primitive
  69005. * @param attributeKind vertex attribute
  69006. * @returns boolean specifying if uv coordinates are present
  69007. */
  69008. private setAttributeKind;
  69009. /**
  69010. * Sets data for the primitive attributes of each submesh
  69011. * @param mesh glTF Mesh object to store the primitive attribute information
  69012. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69013. * @param binaryWriter Buffer to write the attribute data to
  69014. */
  69015. private setPrimitiveAttributesAsync;
  69016. /**
  69017. * Creates a glTF scene based on the array of meshes
  69018. * Returns the the total byte offset
  69019. * @param babylonScene Babylon scene to get the mesh data from
  69020. * @param binaryWriter Buffer to write binary data to
  69021. */
  69022. private createSceneAsync;
  69023. /**
  69024. * Creates a mapping of Node unique id to node index and handles animations
  69025. * @param babylonScene Babylon Scene
  69026. * @param nodes Babylon transform nodes
  69027. * @param binaryWriter Buffer to write binary data to
  69028. * @returns Node mapping of unique id to index
  69029. */
  69030. private createNodeMapAndAnimationsAsync;
  69031. /**
  69032. * Creates a glTF node from a Babylon mesh
  69033. * @param babylonMesh Source Babylon mesh
  69034. * @param binaryWriter Buffer for storing geometry data
  69035. * @returns glTF node
  69036. */
  69037. private createNodeAsync;
  69038. }
  69039. /**
  69040. * @hidden
  69041. *
  69042. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69043. */
  69044. export class _BinaryWriter {
  69045. /**
  69046. * Array buffer which stores all binary data
  69047. */
  69048. private _arrayBuffer;
  69049. /**
  69050. * View of the array buffer
  69051. */
  69052. private _dataView;
  69053. /**
  69054. * byte offset of data in array buffer
  69055. */
  69056. private _byteOffset;
  69057. /**
  69058. * Initialize binary writer with an initial byte length
  69059. * @param byteLength Initial byte length of the array buffer
  69060. */
  69061. constructor(byteLength: number);
  69062. /**
  69063. * Resize the array buffer to the specified byte length
  69064. * @param byteLength
  69065. */
  69066. private resizeBuffer;
  69067. /**
  69068. * Get an array buffer with the length of the byte offset
  69069. * @returns ArrayBuffer resized to the byte offset
  69070. */
  69071. getArrayBuffer(): ArrayBuffer;
  69072. /**
  69073. * Get the byte offset of the array buffer
  69074. * @returns byte offset
  69075. */
  69076. getByteOffset(): number;
  69077. /**
  69078. * Stores an UInt8 in the array buffer
  69079. * @param entry
  69080. * @param byteOffset If defined, specifies where to set the value as an offset.
  69081. */
  69082. setUInt8(entry: number, byteOffset?: number): void;
  69083. /**
  69084. * Gets an UInt32 in the array buffer
  69085. * @param entry
  69086. * @param byteOffset If defined, specifies where to set the value as an offset.
  69087. */
  69088. getUInt32(byteOffset: number): number;
  69089. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69090. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69091. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69092. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69093. /**
  69094. * Stores a Float32 in the array buffer
  69095. * @param entry
  69096. */
  69097. setFloat32(entry: number, byteOffset?: number): void;
  69098. /**
  69099. * Stores an UInt32 in the array buffer
  69100. * @param entry
  69101. * @param byteOffset If defined, specifies where to set the value as an offset.
  69102. */
  69103. setUInt32(entry: number, byteOffset?: number): void;
  69104. }
  69105. }
  69106. declare module BABYLON.GLTF2.Exporter {
  69107. /**
  69108. * @hidden
  69109. * Interface to store animation data.
  69110. */
  69111. export interface _IAnimationData {
  69112. /**
  69113. * Keyframe data.
  69114. */
  69115. inputs: number[];
  69116. /**
  69117. * Value data.
  69118. */
  69119. outputs: number[][];
  69120. /**
  69121. * Animation interpolation data.
  69122. */
  69123. samplerInterpolation: AnimationSamplerInterpolation;
  69124. /**
  69125. * Minimum keyframe value.
  69126. */
  69127. inputsMin: number;
  69128. /**
  69129. * Maximum keyframe value.
  69130. */
  69131. inputsMax: number;
  69132. }
  69133. /**
  69134. * @hidden
  69135. */
  69136. export interface _IAnimationInfo {
  69137. /**
  69138. * The target channel for the animation
  69139. */
  69140. animationChannelTargetPath: AnimationChannelTargetPath;
  69141. /**
  69142. * The glTF accessor type for the data.
  69143. */
  69144. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69145. /**
  69146. * Specifies if quaternions should be used.
  69147. */
  69148. useQuaternion: boolean;
  69149. }
  69150. /**
  69151. * @hidden
  69152. * Utility class for generating glTF animation data from BabylonJS.
  69153. */
  69154. export class _GLTFAnimation {
  69155. /**
  69156. * @ignore
  69157. *
  69158. * Creates glTF channel animation from BabylonJS animation.
  69159. * @param babylonTransformNode - BabylonJS mesh.
  69160. * @param animation - animation.
  69161. * @param animationChannelTargetPath - The target animation channel.
  69162. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69163. * @param useQuaternion - Specifies if quaternions are used.
  69164. * @returns nullable IAnimationData
  69165. */
  69166. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69167. private static _DeduceAnimationInfo;
  69168. /**
  69169. * @ignore
  69170. * Create node animations from the transform node animations
  69171. * @param babylonNode
  69172. * @param runtimeGLTFAnimation
  69173. * @param idleGLTFAnimations
  69174. * @param nodeMap
  69175. * @param nodes
  69176. * @param binaryWriter
  69177. * @param bufferViews
  69178. * @param accessors
  69179. * @param convertToRightHandedSystem
  69180. */
  69181. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69182. [key: number]: number;
  69183. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69184. /**
  69185. * @ignore
  69186. * Create node animations from the animation groups
  69187. * @param babylonScene
  69188. * @param glTFAnimations
  69189. * @param nodeMap
  69190. * @param nodes
  69191. * @param binaryWriter
  69192. * @param bufferViews
  69193. * @param accessors
  69194. * @param convertToRightHandedSystem
  69195. */
  69196. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69197. [key: number]: number;
  69198. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69199. private static AddAnimation;
  69200. /**
  69201. * Create a baked animation
  69202. * @param babylonTransformNode BabylonJS mesh
  69203. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69204. * @param animationChannelTargetPath animation target channel
  69205. * @param minFrame minimum animation frame
  69206. * @param maxFrame maximum animation frame
  69207. * @param fps frames per second of the animation
  69208. * @param inputs input key frames of the animation
  69209. * @param outputs output key frame data of the animation
  69210. * @param convertToRightHandedSystem converts the values to right-handed
  69211. * @param useQuaternion specifies if quaternions should be used
  69212. */
  69213. private static _CreateBakedAnimation;
  69214. private static _ConvertFactorToVector3OrQuaternion;
  69215. private static _SetInterpolatedValue;
  69216. /**
  69217. * Creates linear animation from the animation key frames
  69218. * @param babylonTransformNode BabylonJS mesh
  69219. * @param animation BabylonJS animation
  69220. * @param animationChannelTargetPath The target animation channel
  69221. * @param frameDelta The difference between the last and first frame of the animation
  69222. * @param inputs Array to store the key frame times
  69223. * @param outputs Array to store the key frame data
  69224. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69225. * @param useQuaternion Specifies if quaternions are used in the animation
  69226. */
  69227. private static _CreateLinearOrStepAnimation;
  69228. /**
  69229. * Creates cubic spline animation from the animation key frames
  69230. * @param babylonTransformNode BabylonJS mesh
  69231. * @param animation BabylonJS animation
  69232. * @param animationChannelTargetPath The target animation channel
  69233. * @param frameDelta The difference between the last and first frame of the animation
  69234. * @param inputs Array to store the key frame times
  69235. * @param outputs Array to store the key frame data
  69236. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69237. * @param useQuaternion Specifies if quaternions are used in the animation
  69238. */
  69239. private static _CreateCubicSplineAnimation;
  69240. private static _GetBasePositionRotationOrScale;
  69241. /**
  69242. * Adds a key frame value
  69243. * @param keyFrame
  69244. * @param animation
  69245. * @param outputs
  69246. * @param animationChannelTargetPath
  69247. * @param basePositionRotationOrScale
  69248. * @param convertToRightHandedSystem
  69249. * @param useQuaternion
  69250. */
  69251. private static _AddKeyframeValue;
  69252. /**
  69253. * Determine the interpolation based on the key frames
  69254. * @param keyFrames
  69255. * @param animationChannelTargetPath
  69256. * @param useQuaternion
  69257. */
  69258. private static _DeduceInterpolation;
  69259. /**
  69260. * Adds an input tangent or output tangent to the output data
  69261. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69262. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69263. * @param outputs The animation data by keyframe
  69264. * @param animationChannelTargetPath The target animation channel
  69265. * @param interpolation The interpolation type
  69266. * @param keyFrame The key frame with the animation data
  69267. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69268. * @param useQuaternion Specifies if quaternions are used
  69269. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69270. */
  69271. private static AddSplineTangent;
  69272. /**
  69273. * Get the minimum and maximum key frames' frame values
  69274. * @param keyFrames animation key frames
  69275. * @returns the minimum and maximum key frame value
  69276. */
  69277. private static calculateMinMaxKeyFrames;
  69278. }
  69279. }
  69280. declare module BABYLON.GLTF2.Exporter {
  69281. /** @hidden */
  69282. export var textureTransformPixelShader: {
  69283. name: string;
  69284. shader: string;
  69285. };
  69286. }
  69287. declare module BABYLON.GLTF2.Exporter.Extensions {
  69288. /**
  69289. * @hidden
  69290. */
  69291. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69292. /** Name of this extension */
  69293. readonly name: string;
  69294. /** Defines whether this extension is enabled */
  69295. enabled: boolean;
  69296. /** Defines whether this extension is required */
  69297. required: boolean;
  69298. /** Reference to the glTF exporter */
  69299. private _exporter;
  69300. constructor(exporter: _Exporter);
  69301. dispose(): void;
  69302. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69303. /**
  69304. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69305. * @param babylonTexture
  69306. * @param offset
  69307. * @param rotation
  69308. * @param scale
  69309. * @param scene
  69310. */
  69311. private _textureTransformTextureAsync;
  69312. }
  69313. }
  69314. declare module BABYLON.GLTF2.Exporter.Extensions {
  69315. /**
  69316. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69317. */
  69318. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69319. /** The name of this extension. */
  69320. readonly name: string;
  69321. /** Defines whether this extension is enabled. */
  69322. enabled: boolean;
  69323. /** Defines whether this extension is required */
  69324. required: boolean;
  69325. /** Reference to the glTF exporter */
  69326. private _exporter;
  69327. private _lights;
  69328. /** @hidden */
  69329. constructor(exporter: _Exporter);
  69330. /** @hidden */
  69331. dispose(): void;
  69332. /** @hidden */
  69333. onExporting(): void;
  69334. /**
  69335. * Define this method to modify the default behavior when exporting a node
  69336. * @param context The context when exporting the node
  69337. * @param node glTF node
  69338. * @param babylonNode BabylonJS node
  69339. * @returns nullable INode promise
  69340. */
  69341. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * Class for generating STL data from a Babylon scene.
  69347. */
  69348. export class STLExport {
  69349. /**
  69350. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69351. * @param meshes list defines the mesh to serialize
  69352. * @param download triggers the automatic download of the file.
  69353. * @param fileName changes the downloads fileName.
  69354. * @param binary changes the STL to a binary type.
  69355. * @param isLittleEndian toggle for binary type exporter.
  69356. * @returns the STL as UTF8 string
  69357. */
  69358. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69359. }
  69360. }
  69361. /**
  69362. * @ignoreChildren
  69363. * @ignore
  69364. */
  69365. declare module "babylonjs-gltf2interface" {
  69366. export = BABYLON.GLTF2;
  69367. }
  69368. /**
  69369. * Module for glTF 2.0 Interface
  69370. * @ignoreChildren
  69371. * @ignore
  69372. */
  69373. declare module BABYLON.GLTF2 {
  69374. /**
  69375. * The datatype of the components in the attribute
  69376. */
  69377. const enum AccessorComponentType {
  69378. /**
  69379. * Byte
  69380. */
  69381. BYTE = 5120,
  69382. /**
  69383. * Unsigned Byte
  69384. */
  69385. UNSIGNED_BYTE = 5121,
  69386. /**
  69387. * Short
  69388. */
  69389. SHORT = 5122,
  69390. /**
  69391. * Unsigned Short
  69392. */
  69393. UNSIGNED_SHORT = 5123,
  69394. /**
  69395. * Unsigned Int
  69396. */
  69397. UNSIGNED_INT = 5125,
  69398. /**
  69399. * Float
  69400. */
  69401. FLOAT = 5126,
  69402. }
  69403. /**
  69404. * Specifies if the attirbute is a scalar, vector, or matrix
  69405. */
  69406. const enum AccessorType {
  69407. /**
  69408. * Scalar
  69409. */
  69410. SCALAR = "SCALAR",
  69411. /**
  69412. * Vector2
  69413. */
  69414. VEC2 = "VEC2",
  69415. /**
  69416. * Vector3
  69417. */
  69418. VEC3 = "VEC3",
  69419. /**
  69420. * Vector4
  69421. */
  69422. VEC4 = "VEC4",
  69423. /**
  69424. * Matrix2x2
  69425. */
  69426. MAT2 = "MAT2",
  69427. /**
  69428. * Matrix3x3
  69429. */
  69430. MAT3 = "MAT3",
  69431. /**
  69432. * Matrix4x4
  69433. */
  69434. MAT4 = "MAT4",
  69435. }
  69436. /**
  69437. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69438. */
  69439. const enum AnimationChannelTargetPath {
  69440. /**
  69441. * Translation
  69442. */
  69443. TRANSLATION = "translation",
  69444. /**
  69445. * Rotation
  69446. */
  69447. ROTATION = "rotation",
  69448. /**
  69449. * Scale
  69450. */
  69451. SCALE = "scale",
  69452. /**
  69453. * Weights
  69454. */
  69455. WEIGHTS = "weights",
  69456. }
  69457. /**
  69458. * Interpolation algorithm
  69459. */
  69460. const enum AnimationSamplerInterpolation {
  69461. /**
  69462. * The animated values are linearly interpolated between keyframes
  69463. */
  69464. LINEAR = "LINEAR",
  69465. /**
  69466. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69467. */
  69468. STEP = "STEP",
  69469. /**
  69470. * The animation's interpolation is computed using a cubic spline with specified tangents
  69471. */
  69472. CUBICSPLINE = "CUBICSPLINE",
  69473. }
  69474. /**
  69475. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69476. */
  69477. const enum CameraType {
  69478. /**
  69479. * A perspective camera containing properties to create a perspective projection matrix
  69480. */
  69481. PERSPECTIVE = "perspective",
  69482. /**
  69483. * An orthographic camera containing properties to create an orthographic projection matrix
  69484. */
  69485. ORTHOGRAPHIC = "orthographic",
  69486. }
  69487. /**
  69488. * The mime-type of the image
  69489. */
  69490. const enum ImageMimeType {
  69491. /**
  69492. * JPEG Mime-type
  69493. */
  69494. JPEG = "image/jpeg",
  69495. /**
  69496. * PNG Mime-type
  69497. */
  69498. PNG = "image/png",
  69499. }
  69500. /**
  69501. * The alpha rendering mode of the material
  69502. */
  69503. const enum MaterialAlphaMode {
  69504. /**
  69505. * The alpha value is ignored and the rendered output is fully opaque
  69506. */
  69507. OPAQUE = "OPAQUE",
  69508. /**
  69509. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69510. */
  69511. MASK = "MASK",
  69512. /**
  69513. * 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)
  69514. */
  69515. BLEND = "BLEND",
  69516. }
  69517. /**
  69518. * The type of the primitives to render
  69519. */
  69520. const enum MeshPrimitiveMode {
  69521. /**
  69522. * Points
  69523. */
  69524. POINTS = 0,
  69525. /**
  69526. * Lines
  69527. */
  69528. LINES = 1,
  69529. /**
  69530. * Line Loop
  69531. */
  69532. LINE_LOOP = 2,
  69533. /**
  69534. * Line Strip
  69535. */
  69536. LINE_STRIP = 3,
  69537. /**
  69538. * Triangles
  69539. */
  69540. TRIANGLES = 4,
  69541. /**
  69542. * Triangle Strip
  69543. */
  69544. TRIANGLE_STRIP = 5,
  69545. /**
  69546. * Triangle Fan
  69547. */
  69548. TRIANGLE_FAN = 6,
  69549. }
  69550. /**
  69551. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69552. */
  69553. const enum TextureMagFilter {
  69554. /**
  69555. * Nearest
  69556. */
  69557. NEAREST = 9728,
  69558. /**
  69559. * Linear
  69560. */
  69561. LINEAR = 9729,
  69562. }
  69563. /**
  69564. * Minification filter. All valid values correspond to WebGL enums
  69565. */
  69566. const enum TextureMinFilter {
  69567. /**
  69568. * Nearest
  69569. */
  69570. NEAREST = 9728,
  69571. /**
  69572. * Linear
  69573. */
  69574. LINEAR = 9729,
  69575. /**
  69576. * Nearest Mip-Map Nearest
  69577. */
  69578. NEAREST_MIPMAP_NEAREST = 9984,
  69579. /**
  69580. * Linear Mipmap Nearest
  69581. */
  69582. LINEAR_MIPMAP_NEAREST = 9985,
  69583. /**
  69584. * Nearest Mipmap Linear
  69585. */
  69586. NEAREST_MIPMAP_LINEAR = 9986,
  69587. /**
  69588. * Linear Mipmap Linear
  69589. */
  69590. LINEAR_MIPMAP_LINEAR = 9987,
  69591. }
  69592. /**
  69593. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69594. */
  69595. const enum TextureWrapMode {
  69596. /**
  69597. * Clamp to Edge
  69598. */
  69599. CLAMP_TO_EDGE = 33071,
  69600. /**
  69601. * Mirrored Repeat
  69602. */
  69603. MIRRORED_REPEAT = 33648,
  69604. /**
  69605. * Repeat
  69606. */
  69607. REPEAT = 10497,
  69608. }
  69609. /**
  69610. * glTF Property
  69611. */
  69612. interface IProperty {
  69613. /**
  69614. * Dictionary object with extension-specific objects
  69615. */
  69616. extensions?: {
  69617. [key: string]: any;
  69618. };
  69619. /**
  69620. * Application-Specific data
  69621. */
  69622. extras?: any;
  69623. }
  69624. /**
  69625. * glTF Child of Root Property
  69626. */
  69627. interface IChildRootProperty extends IProperty {
  69628. /**
  69629. * The user-defined name of this object
  69630. */
  69631. name?: string;
  69632. }
  69633. /**
  69634. * Indices of those attributes that deviate from their initialization value
  69635. */
  69636. interface IAccessorSparseIndices extends IProperty {
  69637. /**
  69638. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69639. */
  69640. bufferView: number;
  69641. /**
  69642. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69643. */
  69644. byteOffset?: number;
  69645. /**
  69646. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69647. */
  69648. componentType: AccessorComponentType;
  69649. }
  69650. /**
  69651. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69652. */
  69653. interface IAccessorSparseValues extends IProperty {
  69654. /**
  69655. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69656. */
  69657. bufferView: number;
  69658. /**
  69659. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69660. */
  69661. byteOffset?: number;
  69662. }
  69663. /**
  69664. * Sparse storage of attributes that deviate from their initialization value
  69665. */
  69666. interface IAccessorSparse extends IProperty {
  69667. /**
  69668. * The number of attributes encoded in this sparse accessor
  69669. */
  69670. count: number;
  69671. /**
  69672. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69673. */
  69674. indices: IAccessorSparseIndices;
  69675. /**
  69676. * 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
  69677. */
  69678. values: IAccessorSparseValues;
  69679. }
  69680. /**
  69681. * 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
  69682. */
  69683. interface IAccessor extends IChildRootProperty {
  69684. /**
  69685. * The index of the bufferview
  69686. */
  69687. bufferView?: number;
  69688. /**
  69689. * The offset relative to the start of the bufferView in bytes
  69690. */
  69691. byteOffset?: number;
  69692. /**
  69693. * The datatype of components in the attribute
  69694. */
  69695. componentType: AccessorComponentType;
  69696. /**
  69697. * Specifies whether integer data values should be normalized
  69698. */
  69699. normalized?: boolean;
  69700. /**
  69701. * The number of attributes referenced by this accessor
  69702. */
  69703. count: number;
  69704. /**
  69705. * Specifies if the attribute is a scalar, vector, or matrix
  69706. */
  69707. type: AccessorType;
  69708. /**
  69709. * Maximum value of each component in this attribute
  69710. */
  69711. max?: number[];
  69712. /**
  69713. * Minimum value of each component in this attribute
  69714. */
  69715. min?: number[];
  69716. /**
  69717. * Sparse storage of attributes that deviate from their initialization value
  69718. */
  69719. sparse?: IAccessorSparse;
  69720. }
  69721. /**
  69722. * Targets an animation's sampler at a node's property
  69723. */
  69724. interface IAnimationChannel extends IProperty {
  69725. /**
  69726. * The index of a sampler in this animation used to compute the value for the target
  69727. */
  69728. sampler: number;
  69729. /**
  69730. * The index of the node and TRS property to target
  69731. */
  69732. target: IAnimationChannelTarget;
  69733. }
  69734. /**
  69735. * The index of the node and TRS property that an animation channel targets
  69736. */
  69737. interface IAnimationChannelTarget extends IProperty {
  69738. /**
  69739. * The index of the node to target
  69740. */
  69741. node: number;
  69742. /**
  69743. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69744. */
  69745. path: AnimationChannelTargetPath;
  69746. }
  69747. /**
  69748. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69749. */
  69750. interface IAnimationSampler extends IProperty {
  69751. /**
  69752. * The index of an accessor containing keyframe input values, e.g., time
  69753. */
  69754. input: number;
  69755. /**
  69756. * Interpolation algorithm
  69757. */
  69758. interpolation?: AnimationSamplerInterpolation;
  69759. /**
  69760. * The index of an accessor, containing keyframe output values
  69761. */
  69762. output: number;
  69763. }
  69764. /**
  69765. * A keyframe animation
  69766. */
  69767. interface IAnimation extends IChildRootProperty {
  69768. /**
  69769. * An array of channels, each of which targets an animation's sampler at a node's property
  69770. */
  69771. channels: IAnimationChannel[];
  69772. /**
  69773. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69774. */
  69775. samplers: IAnimationSampler[];
  69776. }
  69777. /**
  69778. * Metadata about the glTF asset
  69779. */
  69780. interface IAsset extends IChildRootProperty {
  69781. /**
  69782. * A copyright message suitable for display to credit the content creator
  69783. */
  69784. copyright?: string;
  69785. /**
  69786. * Tool that generated this glTF model. Useful for debugging
  69787. */
  69788. generator?: string;
  69789. /**
  69790. * The glTF version that this asset targets
  69791. */
  69792. version: string;
  69793. /**
  69794. * The minimum glTF version that this asset targets
  69795. */
  69796. minVersion?: string;
  69797. }
  69798. /**
  69799. * A buffer points to binary geometry, animation, or skins
  69800. */
  69801. interface IBuffer extends IChildRootProperty {
  69802. /**
  69803. * 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
  69804. */
  69805. uri?: string;
  69806. /**
  69807. * The length of the buffer in bytes
  69808. */
  69809. byteLength: number;
  69810. }
  69811. /**
  69812. * A view into a buffer generally representing a subset of the buffer
  69813. */
  69814. interface IBufferView extends IChildRootProperty {
  69815. /**
  69816. * The index of the buffer
  69817. */
  69818. buffer: number;
  69819. /**
  69820. * The offset into the buffer in bytes
  69821. */
  69822. byteOffset?: number;
  69823. /**
  69824. * The lenth of the bufferView in bytes
  69825. */
  69826. byteLength: number;
  69827. /**
  69828. * The stride, in bytes
  69829. */
  69830. byteStride?: number;
  69831. }
  69832. /**
  69833. * An orthographic camera containing properties to create an orthographic projection matrix
  69834. */
  69835. interface ICameraOrthographic extends IProperty {
  69836. /**
  69837. * The floating-point horizontal magnification of the view. Must not be zero
  69838. */
  69839. xmag: number;
  69840. /**
  69841. * The floating-point vertical magnification of the view. Must not be zero
  69842. */
  69843. ymag: number;
  69844. /**
  69845. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69846. */
  69847. zfar: number;
  69848. /**
  69849. * The floating-point distance to the near clipping plane
  69850. */
  69851. znear: number;
  69852. }
  69853. /**
  69854. * A perspective camera containing properties to create a perspective projection matrix
  69855. */
  69856. interface ICameraPerspective extends IProperty {
  69857. /**
  69858. * The floating-point aspect ratio of the field of view
  69859. */
  69860. aspectRatio?: number;
  69861. /**
  69862. * The floating-point vertical field of view in radians
  69863. */
  69864. yfov: number;
  69865. /**
  69866. * The floating-point distance to the far clipping plane
  69867. */
  69868. zfar?: number;
  69869. /**
  69870. * The floating-point distance to the near clipping plane
  69871. */
  69872. znear: number;
  69873. }
  69874. /**
  69875. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69876. */
  69877. interface ICamera extends IChildRootProperty {
  69878. /**
  69879. * An orthographic camera containing properties to create an orthographic projection matrix
  69880. */
  69881. orthographic?: ICameraOrthographic;
  69882. /**
  69883. * A perspective camera containing properties to create a perspective projection matrix
  69884. */
  69885. perspective?: ICameraPerspective;
  69886. /**
  69887. * Specifies if the camera uses a perspective or orthographic projection
  69888. */
  69889. type: CameraType;
  69890. }
  69891. /**
  69892. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69893. */
  69894. interface IImage extends IChildRootProperty {
  69895. /**
  69896. * 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
  69897. */
  69898. uri?: string;
  69899. /**
  69900. * The image's MIME type
  69901. */
  69902. mimeType?: ImageMimeType;
  69903. /**
  69904. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69905. */
  69906. bufferView?: number;
  69907. }
  69908. /**
  69909. * Material Normal Texture Info
  69910. */
  69911. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69912. /**
  69913. * The scalar multiplier applied to each normal vector of the normal texture
  69914. */
  69915. scale?: number;
  69916. }
  69917. /**
  69918. * Material Occlusion Texture Info
  69919. */
  69920. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69921. /**
  69922. * A scalar multiplier controlling the amount of occlusion applied
  69923. */
  69924. strength?: number;
  69925. }
  69926. /**
  69927. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69928. */
  69929. interface IMaterialPbrMetallicRoughness {
  69930. /**
  69931. * The material's base color factor
  69932. */
  69933. baseColorFactor?: number[];
  69934. /**
  69935. * The base color texture
  69936. */
  69937. baseColorTexture?: ITextureInfo;
  69938. /**
  69939. * The metalness of the material
  69940. */
  69941. metallicFactor?: number;
  69942. /**
  69943. * The roughness of the material
  69944. */
  69945. roughnessFactor?: number;
  69946. /**
  69947. * The metallic-roughness texture
  69948. */
  69949. metallicRoughnessTexture?: ITextureInfo;
  69950. }
  69951. /**
  69952. * The material appearance of a primitive
  69953. */
  69954. interface IMaterial extends IChildRootProperty {
  69955. /**
  69956. * 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
  69957. */
  69958. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69959. /**
  69960. * The normal map texture
  69961. */
  69962. normalTexture?: IMaterialNormalTextureInfo;
  69963. /**
  69964. * The occlusion map texture
  69965. */
  69966. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69967. /**
  69968. * The emissive map texture
  69969. */
  69970. emissiveTexture?: ITextureInfo;
  69971. /**
  69972. * 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
  69973. */
  69974. emissiveFactor?: number[];
  69975. /**
  69976. * The alpha rendering mode of the material
  69977. */
  69978. alphaMode?: MaterialAlphaMode;
  69979. /**
  69980. * The alpha cutoff value of the material
  69981. */
  69982. alphaCutoff?: number;
  69983. /**
  69984. * Specifies whether the material is double sided
  69985. */
  69986. doubleSided?: boolean;
  69987. }
  69988. /**
  69989. * Geometry to be rendered with the given material
  69990. */
  69991. interface IMeshPrimitive extends IProperty {
  69992. /**
  69993. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69994. */
  69995. attributes: {
  69996. [name: string]: number;
  69997. };
  69998. /**
  69999. * The index of the accessor that contains the indices
  70000. */
  70001. indices?: number;
  70002. /**
  70003. * The index of the material to apply to this primitive when rendering
  70004. */
  70005. material?: number;
  70006. /**
  70007. * The type of primitives to render. All valid values correspond to WebGL enums
  70008. */
  70009. mode?: MeshPrimitiveMode;
  70010. /**
  70011. * 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
  70012. */
  70013. targets?: {
  70014. [name: string]: number;
  70015. }[];
  70016. }
  70017. /**
  70018. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70019. */
  70020. interface IMesh extends IChildRootProperty {
  70021. /**
  70022. * An array of primitives, each defining geometry to be rendered with a material
  70023. */
  70024. primitives: IMeshPrimitive[];
  70025. /**
  70026. * Array of weights to be applied to the Morph Targets
  70027. */
  70028. weights?: number[];
  70029. }
  70030. /**
  70031. * A node in the node hierarchy
  70032. */
  70033. interface INode extends IChildRootProperty {
  70034. /**
  70035. * The index of the camera referenced by this node
  70036. */
  70037. camera?: number;
  70038. /**
  70039. * The indices of this node's children
  70040. */
  70041. children?: number[];
  70042. /**
  70043. * The index of the skin referenced by this node
  70044. */
  70045. skin?: number;
  70046. /**
  70047. * A floating-point 4x4 transformation matrix stored in column-major order
  70048. */
  70049. matrix?: number[];
  70050. /**
  70051. * The index of the mesh in this node
  70052. */
  70053. mesh?: number;
  70054. /**
  70055. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70056. */
  70057. rotation?: number[];
  70058. /**
  70059. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70060. */
  70061. scale?: number[];
  70062. /**
  70063. * The node's translation along the x, y, and z axes
  70064. */
  70065. translation?: number[];
  70066. /**
  70067. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70068. */
  70069. weights?: number[];
  70070. }
  70071. /**
  70072. * Texture sampler properties for filtering and wrapping modes
  70073. */
  70074. interface ISampler extends IChildRootProperty {
  70075. /**
  70076. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70077. */
  70078. magFilter?: TextureMagFilter;
  70079. /**
  70080. * Minification filter. All valid values correspond to WebGL enums
  70081. */
  70082. minFilter?: TextureMinFilter;
  70083. /**
  70084. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70085. */
  70086. wrapS?: TextureWrapMode;
  70087. /**
  70088. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70089. */
  70090. wrapT?: TextureWrapMode;
  70091. }
  70092. /**
  70093. * The root nodes of a scene
  70094. */
  70095. interface IScene extends IChildRootProperty {
  70096. /**
  70097. * The indices of each root node
  70098. */
  70099. nodes: number[];
  70100. }
  70101. /**
  70102. * Joints and matrices defining a skin
  70103. */
  70104. interface ISkin extends IChildRootProperty {
  70105. /**
  70106. * 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
  70107. */
  70108. inverseBindMatrices?: number;
  70109. /**
  70110. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70111. */
  70112. skeleton?: number;
  70113. /**
  70114. * 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)
  70115. */
  70116. joints: number[];
  70117. }
  70118. /**
  70119. * A texture and its sampler
  70120. */
  70121. interface ITexture extends IChildRootProperty {
  70122. /**
  70123. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70124. */
  70125. sampler?: number;
  70126. /**
  70127. * The index of the image used by this texture
  70128. */
  70129. source: number;
  70130. }
  70131. /**
  70132. * Reference to a texture
  70133. */
  70134. interface ITextureInfo extends IProperty {
  70135. /**
  70136. * The index of the texture
  70137. */
  70138. index: number;
  70139. /**
  70140. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70141. */
  70142. texCoord?: number;
  70143. }
  70144. /**
  70145. * The root object for a glTF asset
  70146. */
  70147. interface IGLTF extends IProperty {
  70148. /**
  70149. * An array of accessors. An accessor is a typed view into a bufferView
  70150. */
  70151. accessors?: IAccessor[];
  70152. /**
  70153. * An array of keyframe animations
  70154. */
  70155. animations?: IAnimation[];
  70156. /**
  70157. * Metadata about the glTF asset
  70158. */
  70159. asset: IAsset;
  70160. /**
  70161. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70162. */
  70163. buffers?: IBuffer[];
  70164. /**
  70165. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70166. */
  70167. bufferViews?: IBufferView[];
  70168. /**
  70169. * An array of cameras
  70170. */
  70171. cameras?: ICamera[];
  70172. /**
  70173. * Names of glTF extensions used somewhere in this asset
  70174. */
  70175. extensionsUsed?: string[];
  70176. /**
  70177. * Names of glTF extensions required to properly load this asset
  70178. */
  70179. extensionsRequired?: string[];
  70180. /**
  70181. * An array of images. An image defines data used to create a texture
  70182. */
  70183. images?: IImage[];
  70184. /**
  70185. * An array of materials. A material defines the appearance of a primitive
  70186. */
  70187. materials?: IMaterial[];
  70188. /**
  70189. * An array of meshes. A mesh is a set of primitives to be rendered
  70190. */
  70191. meshes?: IMesh[];
  70192. /**
  70193. * An array of nodes
  70194. */
  70195. nodes?: INode[];
  70196. /**
  70197. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70198. */
  70199. samplers?: ISampler[];
  70200. /**
  70201. * The index of the default scene
  70202. */
  70203. scene?: number;
  70204. /**
  70205. * An array of scenes
  70206. */
  70207. scenes?: IScene[];
  70208. /**
  70209. * An array of skins. A skin is defined by joints and matrices
  70210. */
  70211. skins?: ISkin[];
  70212. /**
  70213. * An array of textures
  70214. */
  70215. textures?: ITexture[];
  70216. }
  70217. /**
  70218. * The glTF validation results
  70219. */
  70220. interface IGLTFValidationResults {
  70221. info: {
  70222. generator: string;
  70223. hasAnimations: boolean;
  70224. hasDefaultScene: boolean;
  70225. hasMaterials: boolean;
  70226. hasMorphTargets: boolean;
  70227. hasSkins: boolean;
  70228. hasTextures: boolean;
  70229. maxAttributesUsed: number;
  70230. primitivesCount: number
  70231. };
  70232. issues: {
  70233. messages: Array<string>;
  70234. numErrors: number;
  70235. numHints: number;
  70236. numInfos: number;
  70237. numWarnings: number;
  70238. truncated: boolean
  70239. };
  70240. mimeType: string;
  70241. uri: string;
  70242. validatedAt: string;
  70243. validatorVersion: string;
  70244. }
  70245. /**
  70246. * The glTF validation options
  70247. */
  70248. interface IGLTFValidationOptions {
  70249. uri?: string;
  70250. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70251. validateAccessorData?: boolean;
  70252. maxIssues?: number;
  70253. ignoredIssues?: Array<string>;
  70254. severityOverrides?: Object;
  70255. }
  70256. /**
  70257. * The glTF validator object
  70258. */
  70259. interface IGLTFValidator {
  70260. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70261. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70262. }
  70263. }
  70264. declare module BABYLON {
  70265. /** @hidden */
  70266. export var cellPixelShader: {
  70267. name: string;
  70268. shader: string;
  70269. };
  70270. }
  70271. declare module BABYLON {
  70272. /** @hidden */
  70273. export var cellVertexShader: {
  70274. name: string;
  70275. shader: string;
  70276. };
  70277. }
  70278. declare module BABYLON {
  70279. export class CellMaterial extends BABYLON.PushMaterial {
  70280. private _diffuseTexture;
  70281. diffuseTexture: BABYLON.BaseTexture;
  70282. diffuseColor: BABYLON.Color3;
  70283. _computeHighLevel: boolean;
  70284. computeHighLevel: boolean;
  70285. private _disableLighting;
  70286. disableLighting: boolean;
  70287. private _maxSimultaneousLights;
  70288. maxSimultaneousLights: number;
  70289. private _renderId;
  70290. constructor(name: string, scene: BABYLON.Scene);
  70291. needAlphaBlending(): boolean;
  70292. needAlphaTesting(): boolean;
  70293. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70294. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70295. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70296. getAnimatables(): BABYLON.IAnimatable[];
  70297. getActiveTextures(): BABYLON.BaseTexture[];
  70298. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70299. dispose(forceDisposeEffect?: boolean): void;
  70300. getClassName(): string;
  70301. clone(name: string): CellMaterial;
  70302. serialize(): any;
  70303. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70304. }
  70305. }
  70306. declare module BABYLON {
  70307. export class CustomShaderStructure {
  70308. FragmentStore: string;
  70309. VertexStore: string;
  70310. constructor();
  70311. }
  70312. export class ShaderSpecialParts {
  70313. constructor();
  70314. Fragment_Begin: string;
  70315. Fragment_Definitions: string;
  70316. Fragment_MainBegin: string;
  70317. Fragment_Custom_Diffuse: string;
  70318. Fragment_Before_Lights: string;
  70319. Fragment_Before_Fog: string;
  70320. Fragment_Custom_Alpha: string;
  70321. Fragment_Before_FragColor: string;
  70322. Vertex_Begin: string;
  70323. Vertex_Definitions: string;
  70324. Vertex_MainBegin: string;
  70325. Vertex_Before_PositionUpdated: string;
  70326. Vertex_Before_NormalUpdated: string;
  70327. Vertex_MainEnd: string;
  70328. }
  70329. export class CustomMaterial extends BABYLON.StandardMaterial {
  70330. static ShaderIndexer: number;
  70331. CustomParts: ShaderSpecialParts;
  70332. _isCreatedShader: boolean;
  70333. _createdShaderName: string;
  70334. _customUniform: string[];
  70335. _newUniforms: string[];
  70336. _newUniformInstances: any[];
  70337. _newSamplerInstances: BABYLON.Texture[];
  70338. FragmentShader: string;
  70339. VertexShader: string;
  70340. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70341. ReviewUniform(name: string, arr: string[]): string[];
  70342. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70343. constructor(name: string, scene: BABYLON.Scene);
  70344. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70345. Fragment_Begin(shaderPart: string): CustomMaterial;
  70346. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70347. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70348. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70349. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70350. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70351. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70352. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70353. Vertex_Begin(shaderPart: string): CustomMaterial;
  70354. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70355. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70356. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70357. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70358. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. export class ShaderAlebdoParts {
  70363. constructor();
  70364. Fragment_Begin: string;
  70365. Fragment_Definitions: string;
  70366. Fragment_MainBegin: string;
  70367. Fragment_Custom_Albedo: string;
  70368. Fragment_Before_Lights: string;
  70369. Fragment_Custom_MetallicRoughness: string;
  70370. Fragment_Custom_MicroSurface: string;
  70371. Fragment_Before_Fog: string;
  70372. Fragment_Custom_Alpha: string;
  70373. Fragment_Before_FragColor: string;
  70374. Vertex_Begin: string;
  70375. Vertex_Definitions: string;
  70376. Vertex_MainBegin: string;
  70377. Vertex_Before_PositionUpdated: string;
  70378. Vertex_Before_NormalUpdated: string;
  70379. Vertex_MainEnd: string;
  70380. }
  70381. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70382. static ShaderIndexer: number;
  70383. CustomParts: ShaderAlebdoParts;
  70384. _isCreatedShader: boolean;
  70385. _createdShaderName: string;
  70386. _customUniform: string[];
  70387. _newUniforms: string[];
  70388. _newUniformInstances: any[];
  70389. _newSamplerInstances: BABYLON.Texture[];
  70390. FragmentShader: string;
  70391. VertexShader: string;
  70392. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70393. ReviewUniform(name: string, arr: string[]): string[];
  70394. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70395. constructor(name: string, scene: BABYLON.Scene);
  70396. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70397. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70398. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70399. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70400. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70401. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70402. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70403. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70404. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70405. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70406. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70407. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70408. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70409. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70410. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70411. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70412. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70413. }
  70414. }
  70415. declare module BABYLON {
  70416. /** @hidden */
  70417. export var firePixelShader: {
  70418. name: string;
  70419. shader: string;
  70420. };
  70421. }
  70422. declare module BABYLON {
  70423. /** @hidden */
  70424. export var fireVertexShader: {
  70425. name: string;
  70426. shader: string;
  70427. };
  70428. }
  70429. declare module BABYLON {
  70430. export class FireMaterial extends BABYLON.PushMaterial {
  70431. private _diffuseTexture;
  70432. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70433. private _distortionTexture;
  70434. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70435. private _opacityTexture;
  70436. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70437. diffuseColor: BABYLON.Color3;
  70438. speed: number;
  70439. private _scaledDiffuse;
  70440. private _renderId;
  70441. private _lastTime;
  70442. constructor(name: string, scene: BABYLON.Scene);
  70443. needAlphaBlending(): boolean;
  70444. needAlphaTesting(): boolean;
  70445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70446. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70447. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70448. getAnimatables(): BABYLON.IAnimatable[];
  70449. getActiveTextures(): BABYLON.BaseTexture[];
  70450. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70451. getClassName(): string;
  70452. dispose(forceDisposeEffect?: boolean): void;
  70453. clone(name: string): FireMaterial;
  70454. serialize(): any;
  70455. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70456. }
  70457. }
  70458. declare module BABYLON {
  70459. /** @hidden */
  70460. export var furPixelShader: {
  70461. name: string;
  70462. shader: string;
  70463. };
  70464. }
  70465. declare module BABYLON {
  70466. /** @hidden */
  70467. export var furVertexShader: {
  70468. name: string;
  70469. shader: string;
  70470. };
  70471. }
  70472. declare module BABYLON {
  70473. export class FurMaterial extends BABYLON.PushMaterial {
  70474. private _diffuseTexture;
  70475. diffuseTexture: BABYLON.BaseTexture;
  70476. private _heightTexture;
  70477. heightTexture: BABYLON.BaseTexture;
  70478. diffuseColor: BABYLON.Color3;
  70479. furLength: number;
  70480. furAngle: number;
  70481. furColor: BABYLON.Color3;
  70482. furOffset: number;
  70483. furSpacing: number;
  70484. furGravity: BABYLON.Vector3;
  70485. furSpeed: number;
  70486. furDensity: number;
  70487. furOcclusion: number;
  70488. furTexture: BABYLON.DynamicTexture;
  70489. private _disableLighting;
  70490. disableLighting: boolean;
  70491. private _maxSimultaneousLights;
  70492. maxSimultaneousLights: number;
  70493. highLevelFur: boolean;
  70494. _meshes: BABYLON.AbstractMesh[];
  70495. private _renderId;
  70496. private _furTime;
  70497. constructor(name: string, scene: BABYLON.Scene);
  70498. furTime: number;
  70499. needAlphaBlending(): boolean;
  70500. needAlphaTesting(): boolean;
  70501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70502. updateFur(): void;
  70503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70505. getAnimatables(): BABYLON.IAnimatable[];
  70506. getActiveTextures(): BABYLON.BaseTexture[];
  70507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70508. dispose(forceDisposeEffect?: boolean): void;
  70509. clone(name: string): FurMaterial;
  70510. serialize(): any;
  70511. getClassName(): string;
  70512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70513. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70514. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70515. }
  70516. }
  70517. declare module BABYLON {
  70518. /** @hidden */
  70519. export var gradientPixelShader: {
  70520. name: string;
  70521. shader: string;
  70522. };
  70523. }
  70524. declare module BABYLON {
  70525. /** @hidden */
  70526. export var gradientVertexShader: {
  70527. name: string;
  70528. shader: string;
  70529. };
  70530. }
  70531. declare module BABYLON {
  70532. export class GradientMaterial extends BABYLON.PushMaterial {
  70533. private _maxSimultaneousLights;
  70534. maxSimultaneousLights: number;
  70535. topColor: BABYLON.Color3;
  70536. topColorAlpha: number;
  70537. bottomColor: BABYLON.Color3;
  70538. bottomColorAlpha: number;
  70539. offset: number;
  70540. scale: number;
  70541. smoothness: number;
  70542. private _disableLighting;
  70543. disableLighting: boolean;
  70544. private _renderId;
  70545. constructor(name: string, scene: BABYLON.Scene);
  70546. needAlphaBlending(): boolean;
  70547. needAlphaTesting(): boolean;
  70548. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70549. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70550. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70551. getAnimatables(): BABYLON.IAnimatable[];
  70552. dispose(forceDisposeEffect?: boolean): void;
  70553. clone(name: string): GradientMaterial;
  70554. serialize(): any;
  70555. getClassName(): string;
  70556. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70557. }
  70558. }
  70559. declare module BABYLON {
  70560. /** @hidden */
  70561. export var gridPixelShader: {
  70562. name: string;
  70563. shader: string;
  70564. };
  70565. }
  70566. declare module BABYLON {
  70567. /** @hidden */
  70568. export var gridVertexShader: {
  70569. name: string;
  70570. shader: string;
  70571. };
  70572. }
  70573. declare module BABYLON {
  70574. /**
  70575. * The grid materials allows you to wrap any shape with a grid.
  70576. * Colors are customizable.
  70577. */
  70578. export class GridMaterial extends BABYLON.PushMaterial {
  70579. /**
  70580. * Main color of the grid (e.g. between lines)
  70581. */
  70582. mainColor: BABYLON.Color3;
  70583. /**
  70584. * Color of the grid lines.
  70585. */
  70586. lineColor: BABYLON.Color3;
  70587. /**
  70588. * The scale of the grid compared to unit.
  70589. */
  70590. gridRatio: number;
  70591. /**
  70592. * Allows setting an offset for the grid lines.
  70593. */
  70594. gridOffset: BABYLON.Vector3;
  70595. /**
  70596. * The frequency of thicker lines.
  70597. */
  70598. majorUnitFrequency: number;
  70599. /**
  70600. * The visibility of minor units in the grid.
  70601. */
  70602. minorUnitVisibility: number;
  70603. /**
  70604. * The grid opacity outside of the lines.
  70605. */
  70606. opacity: number;
  70607. /**
  70608. * Determine RBG output is premultiplied by alpha value.
  70609. */
  70610. preMultiplyAlpha: boolean;
  70611. private _opacityTexture;
  70612. opacityTexture: BABYLON.BaseTexture;
  70613. private _gridControl;
  70614. private _renderId;
  70615. /**
  70616. * constructor
  70617. * @param name The name given to the material in order to identify it afterwards.
  70618. * @param scene The scene the material is used in.
  70619. */
  70620. constructor(name: string, scene: BABYLON.Scene);
  70621. /**
  70622. * Returns wehter or not the grid requires alpha blending.
  70623. */
  70624. needAlphaBlending(): boolean;
  70625. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70626. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70627. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70628. /**
  70629. * Dispose the material and its associated resources.
  70630. * @param forceDisposeEffect will also dispose the used effect when true
  70631. */
  70632. dispose(forceDisposeEffect?: boolean): void;
  70633. clone(name: string): GridMaterial;
  70634. serialize(): any;
  70635. getClassName(): string;
  70636. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70637. }
  70638. }
  70639. declare module BABYLON {
  70640. /** @hidden */
  70641. export var lavaPixelShader: {
  70642. name: string;
  70643. shader: string;
  70644. };
  70645. }
  70646. declare module BABYLON {
  70647. /** @hidden */
  70648. export var lavaVertexShader: {
  70649. name: string;
  70650. shader: string;
  70651. };
  70652. }
  70653. declare module BABYLON {
  70654. export class LavaMaterial extends BABYLON.PushMaterial {
  70655. private _diffuseTexture;
  70656. diffuseTexture: BABYLON.BaseTexture;
  70657. noiseTexture: BABYLON.BaseTexture;
  70658. fogColor: BABYLON.Color3;
  70659. speed: number;
  70660. movingSpeed: number;
  70661. lowFrequencySpeed: number;
  70662. fogDensity: number;
  70663. private _lastTime;
  70664. diffuseColor: BABYLON.Color3;
  70665. private _disableLighting;
  70666. disableLighting: boolean;
  70667. private _unlit;
  70668. unlit: boolean;
  70669. private _maxSimultaneousLights;
  70670. maxSimultaneousLights: number;
  70671. private _scaledDiffuse;
  70672. private _renderId;
  70673. constructor(name: string, scene: BABYLON.Scene);
  70674. needAlphaBlending(): boolean;
  70675. needAlphaTesting(): boolean;
  70676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70677. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70678. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70679. getAnimatables(): BABYLON.IAnimatable[];
  70680. getActiveTextures(): BABYLON.BaseTexture[];
  70681. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70682. dispose(forceDisposeEffect?: boolean): void;
  70683. clone(name: string): LavaMaterial;
  70684. serialize(): any;
  70685. getClassName(): string;
  70686. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70687. }
  70688. }
  70689. declare module BABYLON {
  70690. /** @hidden */
  70691. export var mixPixelShader: {
  70692. name: string;
  70693. shader: string;
  70694. };
  70695. }
  70696. declare module BABYLON {
  70697. /** @hidden */
  70698. export var mixVertexShader: {
  70699. name: string;
  70700. shader: string;
  70701. };
  70702. }
  70703. declare module BABYLON {
  70704. export class MixMaterial extends BABYLON.PushMaterial {
  70705. /**
  70706. * Mix textures
  70707. */
  70708. private _mixTexture1;
  70709. mixTexture1: BABYLON.BaseTexture;
  70710. private _mixTexture2;
  70711. mixTexture2: BABYLON.BaseTexture;
  70712. /**
  70713. * Diffuse textures
  70714. */
  70715. private _diffuseTexture1;
  70716. diffuseTexture1: BABYLON.Texture;
  70717. private _diffuseTexture2;
  70718. diffuseTexture2: BABYLON.Texture;
  70719. private _diffuseTexture3;
  70720. diffuseTexture3: BABYLON.Texture;
  70721. private _diffuseTexture4;
  70722. diffuseTexture4: BABYLON.Texture;
  70723. private _diffuseTexture5;
  70724. diffuseTexture5: BABYLON.Texture;
  70725. private _diffuseTexture6;
  70726. diffuseTexture6: BABYLON.Texture;
  70727. private _diffuseTexture7;
  70728. diffuseTexture7: BABYLON.Texture;
  70729. private _diffuseTexture8;
  70730. diffuseTexture8: BABYLON.Texture;
  70731. /**
  70732. * Uniforms
  70733. */
  70734. diffuseColor: BABYLON.Color3;
  70735. specularColor: BABYLON.Color3;
  70736. specularPower: number;
  70737. private _disableLighting;
  70738. disableLighting: boolean;
  70739. private _maxSimultaneousLights;
  70740. maxSimultaneousLights: number;
  70741. private _renderId;
  70742. constructor(name: string, scene: BABYLON.Scene);
  70743. needAlphaBlending(): boolean;
  70744. needAlphaTesting(): boolean;
  70745. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70748. getAnimatables(): BABYLON.IAnimatable[];
  70749. getActiveTextures(): BABYLON.BaseTexture[];
  70750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70751. dispose(forceDisposeEffect?: boolean): void;
  70752. clone(name: string): MixMaterial;
  70753. serialize(): any;
  70754. getClassName(): string;
  70755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70756. }
  70757. }
  70758. declare module BABYLON {
  70759. /** @hidden */
  70760. export var normalPixelShader: {
  70761. name: string;
  70762. shader: string;
  70763. };
  70764. }
  70765. declare module BABYLON {
  70766. /** @hidden */
  70767. export var normalVertexShader: {
  70768. name: string;
  70769. shader: string;
  70770. };
  70771. }
  70772. declare module BABYLON {
  70773. export class NormalMaterial extends BABYLON.PushMaterial {
  70774. private _diffuseTexture;
  70775. diffuseTexture: BABYLON.BaseTexture;
  70776. diffuseColor: BABYLON.Color3;
  70777. private _disableLighting;
  70778. disableLighting: boolean;
  70779. private _maxSimultaneousLights;
  70780. maxSimultaneousLights: number;
  70781. private _renderId;
  70782. constructor(name: string, scene: BABYLON.Scene);
  70783. needAlphaBlending(): boolean;
  70784. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70785. needAlphaTesting(): boolean;
  70786. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70787. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70788. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70789. getAnimatables(): BABYLON.IAnimatable[];
  70790. getActiveTextures(): BABYLON.BaseTexture[];
  70791. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70792. dispose(forceDisposeEffect?: boolean): void;
  70793. clone(name: string): NormalMaterial;
  70794. serialize(): any;
  70795. getClassName(): string;
  70796. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70797. }
  70798. }
  70799. declare module BABYLON {
  70800. /** @hidden */
  70801. export var shadowOnlyPixelShader: {
  70802. name: string;
  70803. shader: string;
  70804. };
  70805. }
  70806. declare module BABYLON {
  70807. /** @hidden */
  70808. export var shadowOnlyVertexShader: {
  70809. name: string;
  70810. shader: string;
  70811. };
  70812. }
  70813. declare module BABYLON {
  70814. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70815. private _renderId;
  70816. private _activeLight;
  70817. constructor(name: string, scene: BABYLON.Scene);
  70818. shadowColor: BABYLON.Color3;
  70819. needAlphaBlending(): boolean;
  70820. needAlphaTesting(): boolean;
  70821. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70822. activeLight: BABYLON.IShadowLight;
  70823. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70824. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70825. clone(name: string): ShadowOnlyMaterial;
  70826. serialize(): any;
  70827. getClassName(): string;
  70828. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70829. }
  70830. }
  70831. declare module BABYLON {
  70832. /** @hidden */
  70833. export var simplePixelShader: {
  70834. name: string;
  70835. shader: string;
  70836. };
  70837. }
  70838. declare module BABYLON {
  70839. /** @hidden */
  70840. export var simpleVertexShader: {
  70841. name: string;
  70842. shader: string;
  70843. };
  70844. }
  70845. declare module BABYLON {
  70846. export class SimpleMaterial extends BABYLON.PushMaterial {
  70847. private _diffuseTexture;
  70848. diffuseTexture: BABYLON.BaseTexture;
  70849. diffuseColor: BABYLON.Color3;
  70850. private _disableLighting;
  70851. disableLighting: boolean;
  70852. private _maxSimultaneousLights;
  70853. maxSimultaneousLights: number;
  70854. private _renderId;
  70855. constructor(name: string, scene: BABYLON.Scene);
  70856. needAlphaBlending(): boolean;
  70857. needAlphaTesting(): boolean;
  70858. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70859. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70860. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70861. getAnimatables(): BABYLON.IAnimatable[];
  70862. getActiveTextures(): BABYLON.BaseTexture[];
  70863. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70864. dispose(forceDisposeEffect?: boolean): void;
  70865. clone(name: string): SimpleMaterial;
  70866. serialize(): any;
  70867. getClassName(): string;
  70868. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70869. }
  70870. }
  70871. declare module BABYLON {
  70872. /** @hidden */
  70873. export var skyPixelShader: {
  70874. name: string;
  70875. shader: string;
  70876. };
  70877. }
  70878. declare module BABYLON {
  70879. /** @hidden */
  70880. export var skyVertexShader: {
  70881. name: string;
  70882. shader: string;
  70883. };
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70888. * @see https://doc.babylonjs.com/extensions/sky
  70889. */
  70890. export class SkyMaterial extends BABYLON.PushMaterial {
  70891. /**
  70892. * Defines the overall luminance of sky in interval ]0, 1[.
  70893. */
  70894. luminance: number;
  70895. /**
  70896. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70897. */
  70898. turbidity: number;
  70899. /**
  70900. * Defines the sky appearance (light intensity).
  70901. */
  70902. rayleigh: number;
  70903. /**
  70904. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70905. */
  70906. mieCoefficient: number;
  70907. /**
  70908. * Defines the amount of haze particles following the Mie scattering theory.
  70909. */
  70910. mieDirectionalG: number;
  70911. /**
  70912. * Defines the distance of the sun according to the active scene camera.
  70913. */
  70914. distance: number;
  70915. /**
  70916. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70917. * "inclined".
  70918. */
  70919. inclination: number;
  70920. /**
  70921. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70922. * an object direction and a reference direction.
  70923. */
  70924. azimuth: number;
  70925. /**
  70926. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70927. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70928. */
  70929. sunPosition: BABYLON.Vector3;
  70930. /**
  70931. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70932. * .sunPosition property.
  70933. */
  70934. useSunPosition: boolean;
  70935. /**
  70936. * Defines an offset vector used to get a horizon offset.
  70937. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70938. */
  70939. cameraOffset: BABYLON.Vector3;
  70940. private _cameraPosition;
  70941. private _renderId;
  70942. /**
  70943. * Instantiates a new sky material.
  70944. * This material allows to create dynamic and texture free
  70945. * effects for skyboxes by taking care of the atmosphere state.
  70946. * @see https://doc.babylonjs.com/extensions/sky
  70947. * @param name Define the name of the material in the scene
  70948. * @param scene Define the scene the material belong to
  70949. */
  70950. constructor(name: string, scene: BABYLON.Scene);
  70951. /**
  70952. * Specifies if the material will require alpha blending
  70953. * @returns a boolean specifying if alpha blending is needed
  70954. */
  70955. needAlphaBlending(): boolean;
  70956. /**
  70957. * Specifies if this material should be rendered in alpha test mode
  70958. * @returns false as the sky material doesn't need alpha testing.
  70959. */
  70960. needAlphaTesting(): boolean;
  70961. /**
  70962. * Get the texture used for alpha test purpose.
  70963. * @returns null as the sky material has no texture.
  70964. */
  70965. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70966. /**
  70967. * Get if the submesh is ready to be used and all its information available.
  70968. * Child classes can use it to update shaders
  70969. * @param mesh defines the mesh to check
  70970. * @param subMesh defines which submesh to check
  70971. * @param useInstances specifies that instances should be used
  70972. * @returns a boolean indicating that the submesh is ready or not
  70973. */
  70974. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70975. /**
  70976. * Binds the submesh to this material by preparing the effect and shader to draw
  70977. * @param world defines the world transformation matrix
  70978. * @param mesh defines the mesh containing the submesh
  70979. * @param subMesh defines the submesh to bind the material to
  70980. */
  70981. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70982. /**
  70983. * Get the list of animatables in the material.
  70984. * @returns the list of animatables object used in the material
  70985. */
  70986. getAnimatables(): BABYLON.IAnimatable[];
  70987. /**
  70988. * Disposes the material
  70989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70990. */
  70991. dispose(forceDisposeEffect?: boolean): void;
  70992. /**
  70993. * Makes a duplicate of the material, and gives it a new name
  70994. * @param name defines the new name for the duplicated material
  70995. * @returns the cloned material
  70996. */
  70997. clone(name: string): SkyMaterial;
  70998. /**
  70999. * Serializes this material in a JSON representation
  71000. * @returns the serialized material object
  71001. */
  71002. serialize(): any;
  71003. /**
  71004. * Gets the current class name of the material e.g. "SkyMaterial"
  71005. * Mainly use in serialization.
  71006. * @returns the class name
  71007. */
  71008. getClassName(): string;
  71009. /**
  71010. * Creates a sky material from parsed material data
  71011. * @param source defines the JSON representation of the material
  71012. * @param scene defines the hosting scene
  71013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71014. * @returns a new sky material
  71015. */
  71016. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71017. }
  71018. }
  71019. declare module BABYLON {
  71020. /** @hidden */
  71021. export var terrainPixelShader: {
  71022. name: string;
  71023. shader: string;
  71024. };
  71025. }
  71026. declare module BABYLON {
  71027. /** @hidden */
  71028. export var terrainVertexShader: {
  71029. name: string;
  71030. shader: string;
  71031. };
  71032. }
  71033. declare module BABYLON {
  71034. export class TerrainMaterial extends BABYLON.PushMaterial {
  71035. private _mixTexture;
  71036. mixTexture: BABYLON.BaseTexture;
  71037. private _diffuseTexture1;
  71038. diffuseTexture1: BABYLON.Texture;
  71039. private _diffuseTexture2;
  71040. diffuseTexture2: BABYLON.Texture;
  71041. private _diffuseTexture3;
  71042. diffuseTexture3: BABYLON.Texture;
  71043. private _bumpTexture1;
  71044. bumpTexture1: BABYLON.Texture;
  71045. private _bumpTexture2;
  71046. bumpTexture2: BABYLON.Texture;
  71047. private _bumpTexture3;
  71048. bumpTexture3: BABYLON.Texture;
  71049. diffuseColor: BABYLON.Color3;
  71050. specularColor: BABYLON.Color3;
  71051. specularPower: number;
  71052. private _disableLighting;
  71053. disableLighting: boolean;
  71054. private _maxSimultaneousLights;
  71055. maxSimultaneousLights: number;
  71056. private _renderId;
  71057. constructor(name: string, scene: BABYLON.Scene);
  71058. needAlphaBlending(): boolean;
  71059. needAlphaTesting(): boolean;
  71060. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71061. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71062. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71063. getAnimatables(): BABYLON.IAnimatable[];
  71064. getActiveTextures(): BABYLON.BaseTexture[];
  71065. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71066. dispose(forceDisposeEffect?: boolean): void;
  71067. clone(name: string): TerrainMaterial;
  71068. serialize(): any;
  71069. getClassName(): string;
  71070. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71071. }
  71072. }
  71073. declare module BABYLON {
  71074. /** @hidden */
  71075. export var triplanarPixelShader: {
  71076. name: string;
  71077. shader: string;
  71078. };
  71079. }
  71080. declare module BABYLON {
  71081. /** @hidden */
  71082. export var triplanarVertexShader: {
  71083. name: string;
  71084. shader: string;
  71085. };
  71086. }
  71087. declare module BABYLON {
  71088. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71089. mixTexture: BABYLON.BaseTexture;
  71090. private _diffuseTextureX;
  71091. diffuseTextureX: BABYLON.BaseTexture;
  71092. private _diffuseTextureY;
  71093. diffuseTextureY: BABYLON.BaseTexture;
  71094. private _diffuseTextureZ;
  71095. diffuseTextureZ: BABYLON.BaseTexture;
  71096. private _normalTextureX;
  71097. normalTextureX: BABYLON.BaseTexture;
  71098. private _normalTextureY;
  71099. normalTextureY: BABYLON.BaseTexture;
  71100. private _normalTextureZ;
  71101. normalTextureZ: BABYLON.BaseTexture;
  71102. tileSize: number;
  71103. diffuseColor: BABYLON.Color3;
  71104. specularColor: BABYLON.Color3;
  71105. specularPower: number;
  71106. private _disableLighting;
  71107. disableLighting: boolean;
  71108. private _maxSimultaneousLights;
  71109. maxSimultaneousLights: number;
  71110. private _renderId;
  71111. constructor(name: string, scene: BABYLON.Scene);
  71112. needAlphaBlending(): boolean;
  71113. needAlphaTesting(): boolean;
  71114. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71115. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71116. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71117. getAnimatables(): BABYLON.IAnimatable[];
  71118. getActiveTextures(): BABYLON.BaseTexture[];
  71119. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71120. dispose(forceDisposeEffect?: boolean): void;
  71121. clone(name: string): TriPlanarMaterial;
  71122. serialize(): any;
  71123. getClassName(): string;
  71124. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71125. }
  71126. }
  71127. declare module BABYLON {
  71128. /** @hidden */
  71129. export var waterPixelShader: {
  71130. name: string;
  71131. shader: string;
  71132. };
  71133. }
  71134. declare module BABYLON {
  71135. /** @hidden */
  71136. export var waterVertexShader: {
  71137. name: string;
  71138. shader: string;
  71139. };
  71140. }
  71141. declare module BABYLON {
  71142. export class WaterMaterial extends BABYLON.PushMaterial {
  71143. renderTargetSize: BABYLON.Vector2;
  71144. private _bumpTexture;
  71145. bumpTexture: BABYLON.BaseTexture;
  71146. diffuseColor: BABYLON.Color3;
  71147. specularColor: BABYLON.Color3;
  71148. specularPower: number;
  71149. private _disableLighting;
  71150. disableLighting: boolean;
  71151. private _maxSimultaneousLights;
  71152. maxSimultaneousLights: number;
  71153. /**
  71154. * @param {number}: Represents the wind force
  71155. */
  71156. windForce: number;
  71157. /**
  71158. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71159. */
  71160. windDirection: BABYLON.Vector2;
  71161. /**
  71162. * @param {number}: Wave height, represents the height of the waves
  71163. */
  71164. waveHeight: number;
  71165. /**
  71166. * @param {number}: Bump height, represents the bump height related to the bump map
  71167. */
  71168. bumpHeight: number;
  71169. /**
  71170. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71171. */
  71172. private _bumpSuperimpose;
  71173. bumpSuperimpose: boolean;
  71174. /**
  71175. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71176. */
  71177. private _fresnelSeparate;
  71178. fresnelSeparate: boolean;
  71179. /**
  71180. * @param {boolean}: bump Waves modify the reflection.
  71181. */
  71182. private _bumpAffectsReflection;
  71183. bumpAffectsReflection: boolean;
  71184. /**
  71185. * @param {number}: The water color blended with the refraction (near)
  71186. */
  71187. waterColor: BABYLON.Color3;
  71188. /**
  71189. * @param {number}: The blend factor related to the water color
  71190. */
  71191. colorBlendFactor: number;
  71192. /**
  71193. * @param {number}: The water color blended with the reflection (far)
  71194. */
  71195. waterColor2: BABYLON.Color3;
  71196. /**
  71197. * @param {number}: The blend factor related to the water color (reflection, far)
  71198. */
  71199. colorBlendFactor2: number;
  71200. /**
  71201. * @param {number}: Represents the maximum length of a wave
  71202. */
  71203. waveLength: number;
  71204. /**
  71205. * @param {number}: Defines the waves speed
  71206. */
  71207. waveSpeed: number;
  71208. /**
  71209. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71210. * will avoid calculating useless pixels in the pixel shader of the water material.
  71211. */
  71212. disableClipPlane: boolean;
  71213. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71214. private _mesh;
  71215. private _refractionRTT;
  71216. private _reflectionRTT;
  71217. private _reflectionTransform;
  71218. private _lastTime;
  71219. private _lastDeltaTime;
  71220. private _renderId;
  71221. private _useLogarithmicDepth;
  71222. private _waitingRenderList;
  71223. private _imageProcessingConfiguration;
  71224. private _imageProcessingObserver;
  71225. /**
  71226. * Gets a boolean indicating that current material needs to register RTT
  71227. */
  71228. readonly hasRenderTargetTextures: boolean;
  71229. /**
  71230. * Constructor
  71231. */
  71232. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71233. useLogarithmicDepth: boolean;
  71234. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71235. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71236. addToRenderList(node: any): void;
  71237. enableRenderTargets(enable: boolean): void;
  71238. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71239. readonly renderTargetsEnabled: boolean;
  71240. needAlphaBlending(): boolean;
  71241. needAlphaTesting(): boolean;
  71242. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71243. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71244. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71245. private _createRenderTargets;
  71246. getAnimatables(): BABYLON.IAnimatable[];
  71247. getActiveTextures(): BABYLON.BaseTexture[];
  71248. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71249. dispose(forceDisposeEffect?: boolean): void;
  71250. clone(name: string): WaterMaterial;
  71251. serialize(): any;
  71252. getClassName(): string;
  71253. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71254. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var asciiartPixelShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /**
  71266. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71267. *
  71268. * It basically takes care rendering the font front the given font size to a texture.
  71269. * This is used later on in the postprocess.
  71270. */
  71271. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71272. private _font;
  71273. private _text;
  71274. private _charSize;
  71275. /**
  71276. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71277. */
  71278. readonly charSize: number;
  71279. /**
  71280. * Create a new instance of the Ascii Art FontTexture class
  71281. * @param name the name of the texture
  71282. * @param font the font to use, use the W3C CSS notation
  71283. * @param text the caracter set to use in the rendering.
  71284. * @param scene the scene that owns the texture
  71285. */
  71286. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71287. /**
  71288. * Gets the max char width of a font.
  71289. * @param font the font to use, use the W3C CSS notation
  71290. * @return the max char width
  71291. */
  71292. private getFontWidth;
  71293. /**
  71294. * Gets the max char height of a font.
  71295. * @param font the font to use, use the W3C CSS notation
  71296. * @return the max char height
  71297. */
  71298. private getFontHeight;
  71299. /**
  71300. * Clones the current AsciiArtTexture.
  71301. * @return the clone of the texture.
  71302. */
  71303. clone(): AsciiArtFontTexture;
  71304. /**
  71305. * Parses a json object representing the texture and returns an instance of it.
  71306. * @param source the source JSON representation
  71307. * @param scene the scene to create the texture for
  71308. * @return the parsed texture
  71309. */
  71310. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71311. }
  71312. /**
  71313. * Option available in the Ascii Art Post Process.
  71314. */
  71315. export interface IAsciiArtPostProcessOptions {
  71316. /**
  71317. * The font to use following the w3c font definition.
  71318. */
  71319. font?: string;
  71320. /**
  71321. * The character set to use in the postprocess.
  71322. */
  71323. characterSet?: string;
  71324. /**
  71325. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71326. * This number is defined between 0 and 1;
  71327. */
  71328. mixToTile?: number;
  71329. /**
  71330. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71331. * This number is defined between 0 and 1;
  71332. */
  71333. mixToNormal?: number;
  71334. }
  71335. /**
  71336. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71337. *
  71338. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71339. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71340. */
  71341. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71342. /**
  71343. * The font texture used to render the char in the post process.
  71344. */
  71345. private _asciiArtFontTexture;
  71346. /**
  71347. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71348. * This number is defined between 0 and 1;
  71349. */
  71350. mixToTile: number;
  71351. /**
  71352. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71353. * This number is defined between 0 and 1;
  71354. */
  71355. mixToNormal: number;
  71356. /**
  71357. * Instantiates a new Ascii Art Post Process.
  71358. * @param name the name to give to the postprocess
  71359. * @camera the camera to apply the post process to.
  71360. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71361. */
  71362. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71363. }
  71364. }
  71365. declare module BABYLON {
  71366. /** @hidden */
  71367. export var digitalrainPixelShader: {
  71368. name: string;
  71369. shader: string;
  71370. };
  71371. }
  71372. declare module BABYLON {
  71373. /**
  71374. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71375. *
  71376. * It basically takes care rendering the font front the given font size to a texture.
  71377. * This is used later on in the postprocess.
  71378. */
  71379. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71380. private _font;
  71381. private _text;
  71382. private _charSize;
  71383. /**
  71384. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71385. */
  71386. readonly charSize: number;
  71387. /**
  71388. * Create a new instance of the Digital Rain FontTexture class
  71389. * @param name the name of the texture
  71390. * @param font the font to use, use the W3C CSS notation
  71391. * @param text the caracter set to use in the rendering.
  71392. * @param scene the scene that owns the texture
  71393. */
  71394. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71395. /**
  71396. * Gets the max char width of a font.
  71397. * @param font the font to use, use the W3C CSS notation
  71398. * @return the max char width
  71399. */
  71400. private getFontWidth;
  71401. /**
  71402. * Gets the max char height of a font.
  71403. * @param font the font to use, use the W3C CSS notation
  71404. * @return the max char height
  71405. */
  71406. private getFontHeight;
  71407. /**
  71408. * Clones the current DigitalRainFontTexture.
  71409. * @return the clone of the texture.
  71410. */
  71411. clone(): DigitalRainFontTexture;
  71412. /**
  71413. * Parses a json object representing the texture and returns an instance of it.
  71414. * @param source the source JSON representation
  71415. * @param scene the scene to create the texture for
  71416. * @return the parsed texture
  71417. */
  71418. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71419. }
  71420. /**
  71421. * Option available in the Digital Rain Post Process.
  71422. */
  71423. export interface IDigitalRainPostProcessOptions {
  71424. /**
  71425. * The font to use following the w3c font definition.
  71426. */
  71427. font?: string;
  71428. /**
  71429. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71430. * This number is defined between 0 and 1;
  71431. */
  71432. mixToTile?: number;
  71433. /**
  71434. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71435. * This number is defined between 0 and 1;
  71436. */
  71437. mixToNormal?: number;
  71438. }
  71439. /**
  71440. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71441. *
  71442. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71443. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71444. */
  71445. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71446. /**
  71447. * The font texture used to render the char in the post process.
  71448. */
  71449. private _digitalRainFontTexture;
  71450. /**
  71451. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71452. * This number is defined between 0 and 1;
  71453. */
  71454. mixToTile: number;
  71455. /**
  71456. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71457. * This number is defined between 0 and 1;
  71458. */
  71459. mixToNormal: number;
  71460. /**
  71461. * Instantiates a new Digital Rain Post Process.
  71462. * @param name the name to give to the postprocess
  71463. * @camera the camera to apply the post process to.
  71464. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71465. */
  71466. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71467. }
  71468. }
  71469. declare module BABYLON {
  71470. /** @hidden */
  71471. export var oceanPostProcessPixelShader: {
  71472. name: string;
  71473. shader: string;
  71474. };
  71475. }
  71476. declare module BABYLON {
  71477. /**
  71478. * Option available in the Ocean Post Process.
  71479. */
  71480. export interface IOceanPostProcessOptions {
  71481. /**
  71482. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71483. */
  71484. reflectionSize?: number | {
  71485. width: number;
  71486. height: number;
  71487. } | {
  71488. ratio: number;
  71489. };
  71490. /**
  71491. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71492. */
  71493. refractionSize?: number | {
  71494. width: number;
  71495. height: number;
  71496. } | {
  71497. ratio: number;
  71498. };
  71499. }
  71500. /**
  71501. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71502. *
  71503. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71504. * Example usage:
  71505. * var pp = new OceanPostProcess("myOcean", camera);
  71506. * pp.reflectionEnabled = true;
  71507. * pp.refractionEnabled = true;
  71508. */
  71509. export class OceanPostProcess extends BABYLON.PostProcess {
  71510. /**
  71511. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71512. */
  71513. /**
  71514. * Sets weither or not the real-time reflection is enabled on the ocean.
  71515. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71516. */
  71517. reflectionEnabled: boolean;
  71518. /**
  71519. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71520. */
  71521. /**
  71522. * Sets weither or not the real-time refraction is enabled on the ocean.
  71523. * Is set to true, the refraction render target texture will be used as refraction texture.
  71524. */
  71525. refractionEnabled: boolean;
  71526. /**
  71527. * Gets wether or not the post-processes is supported by the running hardware.
  71528. * This requires draw buffer supports.
  71529. */
  71530. readonly isSupported: boolean;
  71531. /**
  71532. * This is the reflection mirror texture used to display reflections on the ocean.
  71533. * By default, render list is empty.
  71534. */
  71535. reflectionTexture: BABYLON.MirrorTexture;
  71536. /**
  71537. * This is the refraction render target texture used to display refraction on the ocean.
  71538. * By default, render list is empty.
  71539. */
  71540. refractionTexture: BABYLON.RenderTargetTexture;
  71541. private _time;
  71542. private _cameraRotation;
  71543. private _cameraViewMatrix;
  71544. private _reflectionEnabled;
  71545. private _refractionEnabled;
  71546. private _geometryRenderer;
  71547. /**
  71548. * Instantiates a new Ocean Post Process.
  71549. * @param name the name to give to the postprocess.
  71550. * @camera the camera to apply the post process to.
  71551. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71552. */
  71553. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71554. /**
  71555. * Returns the appropriate defines according to the current configuration.
  71556. */
  71557. private _getDefines;
  71558. /**
  71559. * Computes the current camera rotation as the shader requires a camera rotation.
  71560. */
  71561. private _computeCameraRotation;
  71562. }
  71563. }
  71564. declare module BABYLON {
  71565. /** @hidden */
  71566. export var brickProceduralTexturePixelShader: {
  71567. name: string;
  71568. shader: string;
  71569. };
  71570. }
  71571. declare module BABYLON {
  71572. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71573. private _numberOfBricksHeight;
  71574. private _numberOfBricksWidth;
  71575. private _jointColor;
  71576. private _brickColor;
  71577. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71578. updateShaderUniforms(): void;
  71579. numberOfBricksHeight: number;
  71580. numberOfBricksWidth: number;
  71581. jointColor: BABYLON.Color3;
  71582. brickColor: BABYLON.Color3;
  71583. /**
  71584. * Serializes this brick procedural texture
  71585. * @returns a serialized brick procedural texture object
  71586. */
  71587. serialize(): any;
  71588. /**
  71589. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71590. * @param parsedTexture defines parsed texture data
  71591. * @param scene defines the current scene
  71592. * @param rootUrl defines the root URL containing brick procedural texture information
  71593. * @returns a parsed Brick Procedural BABYLON.Texture
  71594. */
  71595. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71596. }
  71597. }
  71598. declare module BABYLON {
  71599. /** @hidden */
  71600. export var cloudProceduralTexturePixelShader: {
  71601. name: string;
  71602. shader: string;
  71603. };
  71604. }
  71605. declare module BABYLON {
  71606. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71607. private _skyColor;
  71608. private _cloudColor;
  71609. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71610. updateShaderUniforms(): void;
  71611. skyColor: BABYLON.Color4;
  71612. cloudColor: BABYLON.Color4;
  71613. /**
  71614. * Serializes this cloud procedural texture
  71615. * @returns a serialized cloud procedural texture object
  71616. */
  71617. serialize(): any;
  71618. /**
  71619. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71620. * @param parsedTexture defines parsed texture data
  71621. * @param scene defines the current scene
  71622. * @param rootUrl defines the root URL containing cloud procedural texture information
  71623. * @returns a parsed Cloud Procedural BABYLON.Texture
  71624. */
  71625. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71626. }
  71627. }
  71628. declare module BABYLON {
  71629. /** @hidden */
  71630. export var fireProceduralTexturePixelShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module BABYLON {
  71636. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71637. private _time;
  71638. private _speed;
  71639. private _autoGenerateTime;
  71640. private _fireColors;
  71641. private _alphaThreshold;
  71642. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71643. updateShaderUniforms(): void;
  71644. render(useCameraPostProcess?: boolean): void;
  71645. static readonly PurpleFireColors: BABYLON.Color3[];
  71646. static readonly GreenFireColors: BABYLON.Color3[];
  71647. static readonly RedFireColors: BABYLON.Color3[];
  71648. static readonly BlueFireColors: BABYLON.Color3[];
  71649. autoGenerateTime: boolean;
  71650. fireColors: BABYLON.Color3[];
  71651. time: number;
  71652. speed: BABYLON.Vector2;
  71653. alphaThreshold: number;
  71654. /**
  71655. * Serializes this fire procedural texture
  71656. * @returns a serialized fire procedural texture object
  71657. */
  71658. serialize(): any;
  71659. /**
  71660. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71661. * @param parsedTexture defines parsed texture data
  71662. * @param scene defines the current scene
  71663. * @param rootUrl defines the root URL containing fire procedural texture information
  71664. * @returns a parsed Fire Procedural BABYLON.Texture
  71665. */
  71666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. /** @hidden */
  71671. export var grassProceduralTexturePixelShader: {
  71672. name: string;
  71673. shader: string;
  71674. };
  71675. }
  71676. declare module BABYLON {
  71677. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71678. private _grassColors;
  71679. private _groundColor;
  71680. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71681. updateShaderUniforms(): void;
  71682. grassColors: BABYLON.Color3[];
  71683. groundColor: BABYLON.Color3;
  71684. /**
  71685. * Serializes this grass procedural texture
  71686. * @returns a serialized grass procedural texture object
  71687. */
  71688. serialize(): any;
  71689. /**
  71690. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71691. * @param parsedTexture defines parsed texture data
  71692. * @param scene defines the current scene
  71693. * @param rootUrl defines the root URL containing grass procedural texture information
  71694. * @returns a parsed Grass Procedural BABYLON.Texture
  71695. */
  71696. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71697. }
  71698. }
  71699. declare module BABYLON {
  71700. /** @hidden */
  71701. export var marbleProceduralTexturePixelShader: {
  71702. name: string;
  71703. shader: string;
  71704. };
  71705. }
  71706. declare module BABYLON {
  71707. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71708. private _numberOfTilesHeight;
  71709. private _numberOfTilesWidth;
  71710. private _amplitude;
  71711. private _jointColor;
  71712. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71713. updateShaderUniforms(): void;
  71714. numberOfTilesHeight: number;
  71715. amplitude: number;
  71716. numberOfTilesWidth: number;
  71717. jointColor: BABYLON.Color3;
  71718. /**
  71719. * Serializes this marble procedural texture
  71720. * @returns a serialized marble procedural texture object
  71721. */
  71722. serialize(): any;
  71723. /**
  71724. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71725. * @param parsedTexture defines parsed texture data
  71726. * @param scene defines the current scene
  71727. * @param rootUrl defines the root URL containing marble procedural texture information
  71728. * @returns a parsed Marble Procedural BABYLON.Texture
  71729. */
  71730. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71731. }
  71732. }
  71733. declare module BABYLON {
  71734. /** @hidden */
  71735. export var normalMapProceduralTexturePixelShader: {
  71736. name: string;
  71737. shader: string;
  71738. };
  71739. }
  71740. declare module BABYLON {
  71741. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71742. private _baseTexture;
  71743. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71744. updateShaderUniforms(): void;
  71745. render(useCameraPostProcess?: boolean): void;
  71746. resize(size: any, generateMipMaps: any): void;
  71747. baseTexture: BABYLON.Texture;
  71748. /**
  71749. * Serializes this normal map procedural texture
  71750. * @returns a serialized normal map procedural texture object
  71751. */
  71752. serialize(): any;
  71753. /**
  71754. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71755. * @param parsedTexture defines parsed texture data
  71756. * @param scene defines the current scene
  71757. * @param rootUrl defines the root URL containing normal map procedural texture information
  71758. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71759. */
  71760. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71761. }
  71762. }
  71763. declare module BABYLON {
  71764. /** @hidden */
  71765. export var perlinNoiseProceduralTexturePixelShader: {
  71766. name: string;
  71767. shader: string;
  71768. };
  71769. }
  71770. declare module BABYLON {
  71771. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71772. time: number;
  71773. timeScale: number;
  71774. translationSpeed: number;
  71775. private _currentTranslation;
  71776. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71777. updateShaderUniforms(): void;
  71778. render(useCameraPostProcess?: boolean): void;
  71779. resize(size: any, generateMipMaps: any): void;
  71780. /**
  71781. * Serializes this perlin noise procedural texture
  71782. * @returns a serialized perlin noise procedural texture object
  71783. */
  71784. serialize(): any;
  71785. /**
  71786. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71787. * @param parsedTexture defines parsed texture data
  71788. * @param scene defines the current scene
  71789. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71790. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71791. */
  71792. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71793. }
  71794. }
  71795. declare module BABYLON {
  71796. /** @hidden */
  71797. export var roadProceduralTexturePixelShader: {
  71798. name: string;
  71799. shader: string;
  71800. };
  71801. }
  71802. declare module BABYLON {
  71803. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71804. private _roadColor;
  71805. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71806. updateShaderUniforms(): void;
  71807. roadColor: BABYLON.Color3;
  71808. /**
  71809. * Serializes this road procedural texture
  71810. * @returns a serialized road procedural texture object
  71811. */
  71812. serialize(): any;
  71813. /**
  71814. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71815. * @param parsedTexture defines parsed texture data
  71816. * @param scene defines the current scene
  71817. * @param rootUrl defines the root URL containing road procedural texture information
  71818. * @returns a parsed Road Procedural BABYLON.Texture
  71819. */
  71820. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /** @hidden */
  71825. export var starfieldProceduralTexturePixelShader: {
  71826. name: string;
  71827. shader: string;
  71828. };
  71829. }
  71830. declare module BABYLON {
  71831. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71832. private _time;
  71833. private _alpha;
  71834. private _beta;
  71835. private _zoom;
  71836. private _formuparam;
  71837. private _stepsize;
  71838. private _tile;
  71839. private _brightness;
  71840. private _darkmatter;
  71841. private _distfading;
  71842. private _saturation;
  71843. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71844. updateShaderUniforms(): void;
  71845. time: number;
  71846. alpha: number;
  71847. beta: number;
  71848. formuparam: number;
  71849. stepsize: number;
  71850. zoom: number;
  71851. tile: number;
  71852. brightness: number;
  71853. darkmatter: number;
  71854. distfading: number;
  71855. saturation: number;
  71856. /**
  71857. * Serializes this starfield procedural texture
  71858. * @returns a serialized starfield procedural texture object
  71859. */
  71860. serialize(): any;
  71861. /**
  71862. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71863. * @param parsedTexture defines parsed texture data
  71864. * @param scene defines the current scene
  71865. * @param rootUrl defines the root URL containing startfield procedural texture information
  71866. * @returns a parsed Starfield Procedural BABYLON.Texture
  71867. */
  71868. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71869. }
  71870. }
  71871. declare module BABYLON {
  71872. /** @hidden */
  71873. export var woodProceduralTexturePixelShader: {
  71874. name: string;
  71875. shader: string;
  71876. };
  71877. }
  71878. declare module BABYLON {
  71879. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71880. private _ampScale;
  71881. private _woodColor;
  71882. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71883. updateShaderUniforms(): void;
  71884. ampScale: number;
  71885. woodColor: BABYLON.Color3;
  71886. /**
  71887. * Serializes this wood procedural texture
  71888. * @returns a serialized wood procedural texture object
  71889. */
  71890. serialize(): any;
  71891. /**
  71892. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71893. * @param parsedTexture defines parsed texture data
  71894. * @param scene defines the current scene
  71895. * @param rootUrl defines the root URL containing wood procedural texture information
  71896. * @returns a parsed Wood Procedural BABYLON.Texture
  71897. */
  71898. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71899. }
  71900. }