documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990
  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. */
  36756. attach(ownerNode: AbstractMesh): void;
  36757. /**
  36758. * Force relase the drag action by code.
  36759. */
  36760. releaseDrag(): void;
  36761. private _startDragRay;
  36762. private _lastPointerRay;
  36763. /**
  36764. * Simulates the start of a pointer drag event on the behavior
  36765. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36766. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36767. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36768. */
  36769. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36770. private _startDrag;
  36771. private _dragDelta;
  36772. private _moveDrag;
  36773. private _pickWithRayOnDragPlane;
  36774. private _pointA;
  36775. private _pointB;
  36776. private _pointC;
  36777. private _lineA;
  36778. private _lineB;
  36779. private _localAxis;
  36780. private _lookAt;
  36781. private _updateDragPlanePosition;
  36782. /**
  36783. * Detaches the behavior from the mesh
  36784. */
  36785. detach(): void;
  36786. }
  36787. }
  36788. declare module BABYLON {
  36789. /**
  36790. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36791. */
  36792. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36793. private _dragBehaviorA;
  36794. private _dragBehaviorB;
  36795. private _startDistance;
  36796. private _initialScale;
  36797. private _targetScale;
  36798. private _ownerNode;
  36799. private _sceneRenderObserver;
  36800. /**
  36801. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36802. */
  36803. constructor();
  36804. /**
  36805. * The name of the behavior
  36806. */
  36807. readonly name: string;
  36808. /**
  36809. * Initializes the behavior
  36810. */
  36811. init(): void;
  36812. private _getCurrentDistance;
  36813. /**
  36814. * Attaches the scale behavior the passed in mesh
  36815. * @param ownerNode The mesh that will be scaled around once attached
  36816. */
  36817. attach(ownerNode: Mesh): void;
  36818. /**
  36819. * Detaches the behavior from the mesh
  36820. */
  36821. detach(): void;
  36822. }
  36823. }
  36824. declare module BABYLON {
  36825. /**
  36826. * 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
  36827. */
  36828. export class SixDofDragBehavior implements Behavior<Mesh> {
  36829. private static _virtualScene;
  36830. private _ownerNode;
  36831. private _sceneRenderObserver;
  36832. private _scene;
  36833. private _targetPosition;
  36834. private _virtualOriginMesh;
  36835. private _virtualDragMesh;
  36836. private _pointerObserver;
  36837. private _moving;
  36838. private _startingOrientation;
  36839. /**
  36840. * 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)
  36841. */
  36842. private zDragFactor;
  36843. /**
  36844. * If the object should rotate to face the drag origin
  36845. */
  36846. rotateDraggedObject: boolean;
  36847. /**
  36848. * If the behavior is currently in a dragging state
  36849. */
  36850. dragging: boolean;
  36851. /**
  36852. * 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)
  36853. */
  36854. dragDeltaRatio: number;
  36855. /**
  36856. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36857. */
  36858. currentDraggingPointerID: number;
  36859. /**
  36860. * If camera controls should be detached during the drag
  36861. */
  36862. detachCameraControls: boolean;
  36863. /**
  36864. * Fires each time a drag starts
  36865. */
  36866. onDragStartObservable: Observable<{}>;
  36867. /**
  36868. * Fires each time a drag ends (eg. mouse release after drag)
  36869. */
  36870. onDragEndObservable: Observable<{}>;
  36871. /**
  36872. * 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
  36873. */
  36874. constructor();
  36875. /**
  36876. * The name of the behavior
  36877. */
  36878. readonly name: string;
  36879. /**
  36880. * Initializes the behavior
  36881. */
  36882. init(): void;
  36883. /**
  36884. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36885. */
  36886. private readonly _pointerCamera;
  36887. /**
  36888. * Attaches the scale behavior the passed in mesh
  36889. * @param ownerNode The mesh that will be scaled around once attached
  36890. */
  36891. attach(ownerNode: Mesh): void;
  36892. /**
  36893. * Detaches the behavior from the mesh
  36894. */
  36895. detach(): void;
  36896. }
  36897. }
  36898. declare module BABYLON {
  36899. /**
  36900. * Class used to apply inverse kinematics to bones
  36901. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36902. */
  36903. export class BoneIKController {
  36904. private static _tmpVecs;
  36905. private static _tmpQuat;
  36906. private static _tmpMats;
  36907. /**
  36908. * Gets or sets the target mesh
  36909. */
  36910. targetMesh: AbstractMesh;
  36911. /** Gets or sets the mesh used as pole */
  36912. poleTargetMesh: AbstractMesh;
  36913. /**
  36914. * Gets or sets the bone used as pole
  36915. */
  36916. poleTargetBone: Nullable<Bone>;
  36917. /**
  36918. * Gets or sets the target position
  36919. */
  36920. targetPosition: Vector3;
  36921. /**
  36922. * Gets or sets the pole target position
  36923. */
  36924. poleTargetPosition: Vector3;
  36925. /**
  36926. * Gets or sets the pole target local offset
  36927. */
  36928. poleTargetLocalOffset: Vector3;
  36929. /**
  36930. * Gets or sets the pole angle
  36931. */
  36932. poleAngle: number;
  36933. /**
  36934. * Gets or sets the mesh associated with the controller
  36935. */
  36936. mesh: AbstractMesh;
  36937. /**
  36938. * 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)
  36939. */
  36940. slerpAmount: number;
  36941. private _bone1Quat;
  36942. private _bone1Mat;
  36943. private _bone2Ang;
  36944. private _bone1;
  36945. private _bone2;
  36946. private _bone1Length;
  36947. private _bone2Length;
  36948. private _maxAngle;
  36949. private _maxReach;
  36950. private _rightHandedSystem;
  36951. private _bendAxis;
  36952. private _slerping;
  36953. private _adjustRoll;
  36954. /**
  36955. * Gets or sets maximum allowed angle
  36956. */
  36957. maxAngle: number;
  36958. /**
  36959. * Creates a new BoneIKController
  36960. * @param mesh defines the mesh to control
  36961. * @param bone defines the bone to control
  36962. * @param options defines options to set up the controller
  36963. */
  36964. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36965. targetMesh?: AbstractMesh;
  36966. poleTargetMesh?: AbstractMesh;
  36967. poleTargetBone?: Bone;
  36968. poleTargetLocalOffset?: Vector3;
  36969. poleAngle?: number;
  36970. bendAxis?: Vector3;
  36971. maxAngle?: number;
  36972. slerpAmount?: number;
  36973. });
  36974. private _setMaxAngle;
  36975. /**
  36976. * Force the controller to update the bones
  36977. */
  36978. update(): void;
  36979. }
  36980. }
  36981. declare module BABYLON {
  36982. /**
  36983. * Class used to make a bone look toward a point in space
  36984. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36985. */
  36986. export class BoneLookController {
  36987. private static _tmpVecs;
  36988. private static _tmpQuat;
  36989. private static _tmpMats;
  36990. /**
  36991. * The target Vector3 that the bone will look at
  36992. */
  36993. target: Vector3;
  36994. /**
  36995. * The mesh that the bone is attached to
  36996. */
  36997. mesh: AbstractMesh;
  36998. /**
  36999. * The bone that will be looking to the target
  37000. */
  37001. bone: Bone;
  37002. /**
  37003. * The up axis of the coordinate system that is used when the bone is rotated
  37004. */
  37005. upAxis: Vector3;
  37006. /**
  37007. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37008. */
  37009. upAxisSpace: Space;
  37010. /**
  37011. * Used to make an adjustment to the yaw of the bone
  37012. */
  37013. adjustYaw: number;
  37014. /**
  37015. * Used to make an adjustment to the pitch of the bone
  37016. */
  37017. adjustPitch: number;
  37018. /**
  37019. * Used to make an adjustment to the roll of the bone
  37020. */
  37021. adjustRoll: number;
  37022. /**
  37023. * 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)
  37024. */
  37025. slerpAmount: number;
  37026. private _minYaw;
  37027. private _maxYaw;
  37028. private _minPitch;
  37029. private _maxPitch;
  37030. private _minYawSin;
  37031. private _minYawCos;
  37032. private _maxYawSin;
  37033. private _maxYawCos;
  37034. private _midYawConstraint;
  37035. private _minPitchTan;
  37036. private _maxPitchTan;
  37037. private _boneQuat;
  37038. private _slerping;
  37039. private _transformYawPitch;
  37040. private _transformYawPitchInv;
  37041. private _firstFrameSkipped;
  37042. private _yawRange;
  37043. private _fowardAxis;
  37044. /**
  37045. * Gets or sets the minimum yaw angle that the bone can look to
  37046. */
  37047. minYaw: number;
  37048. /**
  37049. * Gets or sets the maximum yaw angle that the bone can look to
  37050. */
  37051. maxYaw: number;
  37052. /**
  37053. * Gets or sets the minimum pitch angle that the bone can look to
  37054. */
  37055. minPitch: number;
  37056. /**
  37057. * Gets or sets the maximum pitch angle that the bone can look to
  37058. */
  37059. maxPitch: number;
  37060. /**
  37061. * Create a BoneLookController
  37062. * @param mesh the mesh that the bone belongs to
  37063. * @param bone the bone that will be looking to the target
  37064. * @param target the target Vector3 to look at
  37065. * @param options optional settings:
  37066. * * maxYaw: the maximum angle the bone will yaw to
  37067. * * minYaw: the minimum angle the bone will yaw to
  37068. * * maxPitch: the maximum angle the bone will pitch to
  37069. * * minPitch: the minimum angle the bone will yaw to
  37070. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37071. * * upAxis: the up axis of the coordinate system
  37072. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37073. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37074. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37075. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37076. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37077. * * adjustRoll: used to make an adjustment to the roll of the bone
  37078. **/
  37079. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37080. maxYaw?: number;
  37081. minYaw?: number;
  37082. maxPitch?: number;
  37083. minPitch?: number;
  37084. slerpAmount?: number;
  37085. upAxis?: Vector3;
  37086. upAxisSpace?: Space;
  37087. yawAxis?: Vector3;
  37088. pitchAxis?: Vector3;
  37089. adjustYaw?: number;
  37090. adjustPitch?: number;
  37091. adjustRoll?: number;
  37092. });
  37093. /**
  37094. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37095. */
  37096. update(): void;
  37097. private _getAngleDiff;
  37098. private _getAngleBetween;
  37099. private _isAngleBetween;
  37100. }
  37101. }
  37102. declare module BABYLON {
  37103. /**
  37104. * Manage the gamepad inputs to control an arc rotate camera.
  37105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37106. */
  37107. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37108. /**
  37109. * Defines the camera the input is attached to.
  37110. */
  37111. camera: ArcRotateCamera;
  37112. /**
  37113. * Defines the gamepad the input is gathering event from.
  37114. */
  37115. gamepad: Nullable<Gamepad>;
  37116. /**
  37117. * Defines the gamepad rotation sensiblity.
  37118. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37119. */
  37120. gamepadRotationSensibility: number;
  37121. /**
  37122. * Defines the gamepad move sensiblity.
  37123. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37124. */
  37125. gamepadMoveSensibility: number;
  37126. private _onGamepadConnectedObserver;
  37127. private _onGamepadDisconnectedObserver;
  37128. /**
  37129. * Attach the input controls to a specific dom element to get the input from.
  37130. * @param element Defines the element the controls should be listened from
  37131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37132. */
  37133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37134. /**
  37135. * Detach the current controls from the specified dom element.
  37136. * @param element Defines the element to stop listening the inputs from
  37137. */
  37138. detachControl(element: Nullable<HTMLElement>): void;
  37139. /**
  37140. * Update the current camera state depending on the inputs that have been used this frame.
  37141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37142. */
  37143. checkInputs(): void;
  37144. /**
  37145. * Gets the class name of the current intput.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. /**
  37150. * Get the friendly name associated with the input class.
  37151. * @returns the input friendly name
  37152. */
  37153. getSimpleName(): string;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. interface ArcRotateCameraInputsManager {
  37158. /**
  37159. * Add orientation input support to the input manager.
  37160. * @returns the current input manager
  37161. */
  37162. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37163. }
  37164. /**
  37165. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37167. */
  37168. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37169. /**
  37170. * Defines the camera the input is attached to.
  37171. */
  37172. camera: ArcRotateCamera;
  37173. /**
  37174. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37175. */
  37176. alphaCorrection: number;
  37177. /**
  37178. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37179. */
  37180. gammaCorrection: number;
  37181. private _alpha;
  37182. private _gamma;
  37183. private _dirty;
  37184. private _deviceOrientationHandler;
  37185. /**
  37186. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37187. */
  37188. constructor();
  37189. /**
  37190. * Attach the input controls to a specific dom element to get the input from.
  37191. * @param element Defines the element the controls should be listened from
  37192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37193. */
  37194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37195. /** @hidden */
  37196. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37197. /**
  37198. * Update the current camera state depending on the inputs that have been used this frame.
  37199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37200. */
  37201. checkInputs(): void;
  37202. /**
  37203. * Detach the current controls from the specified dom element.
  37204. * @param element Defines the element to stop listening the inputs from
  37205. */
  37206. detachControl(element: Nullable<HTMLElement>): void;
  37207. /**
  37208. * Gets the class name of the current intput.
  37209. * @returns the class name
  37210. */
  37211. getClassName(): string;
  37212. /**
  37213. * Get the friendly name associated with the input class.
  37214. * @returns the input friendly name
  37215. */
  37216. getSimpleName(): string;
  37217. }
  37218. }
  37219. declare module BABYLON {
  37220. /**
  37221. * Listen to mouse events to control the camera.
  37222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37223. */
  37224. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37225. /**
  37226. * Defines the camera the input is attached to.
  37227. */
  37228. camera: FlyCamera;
  37229. /**
  37230. * Defines if touch is enabled. (Default is true.)
  37231. */
  37232. touchEnabled: boolean;
  37233. /**
  37234. * Defines the buttons associated with the input to handle camera rotation.
  37235. */
  37236. buttons: number[];
  37237. /**
  37238. * Assign buttons for Yaw control.
  37239. */
  37240. buttonsYaw: number[];
  37241. /**
  37242. * Assign buttons for Pitch control.
  37243. */
  37244. buttonsPitch: number[];
  37245. /**
  37246. * Assign buttons for Roll control.
  37247. */
  37248. buttonsRoll: number[];
  37249. /**
  37250. * Detect if any button is being pressed while mouse is moved.
  37251. * -1 = Mouse locked.
  37252. * 0 = Left button.
  37253. * 1 = Middle Button.
  37254. * 2 = Right Button.
  37255. */
  37256. activeButton: number;
  37257. /**
  37258. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37259. * Higher values reduce its sensitivity.
  37260. */
  37261. angularSensibility: number;
  37262. private _mousemoveCallback;
  37263. private _observer;
  37264. private _rollObserver;
  37265. private previousPosition;
  37266. private noPreventDefault;
  37267. private element;
  37268. /**
  37269. * Listen to mouse events to control the camera.
  37270. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37272. */
  37273. constructor(touchEnabled?: boolean);
  37274. /**
  37275. * Attach the mouse control to the HTML DOM element.
  37276. * @param element Defines the element that listens to the input events.
  37277. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37278. */
  37279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37280. /**
  37281. * Detach the current controls from the specified dom element.
  37282. * @param element Defines the element to stop listening the inputs from
  37283. */
  37284. detachControl(element: Nullable<HTMLElement>): void;
  37285. /**
  37286. * Gets the class name of the current input.
  37287. * @returns the class name.
  37288. */
  37289. getClassName(): string;
  37290. /**
  37291. * Get the friendly name associated with the input class.
  37292. * @returns the input's friendly name.
  37293. */
  37294. getSimpleName(): string;
  37295. private _pointerInput;
  37296. private _onMouseMove;
  37297. /**
  37298. * Rotate camera by mouse offset.
  37299. */
  37300. private rotateCamera;
  37301. }
  37302. }
  37303. declare module BABYLON {
  37304. /**
  37305. * Default Inputs manager for the FlyCamera.
  37306. * It groups all the default supported inputs for ease of use.
  37307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37308. */
  37309. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37310. /**
  37311. * Instantiates a new FlyCameraInputsManager.
  37312. * @param camera Defines the camera the inputs belong to.
  37313. */
  37314. constructor(camera: FlyCamera);
  37315. /**
  37316. * Add keyboard input support to the input manager.
  37317. * @returns the new FlyCameraKeyboardMoveInput().
  37318. */
  37319. addKeyboard(): FlyCameraInputsManager;
  37320. /**
  37321. * Add mouse input support to the input manager.
  37322. * @param touchEnabled Enable touch screen support.
  37323. * @returns the new FlyCameraMouseInput().
  37324. */
  37325. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37326. }
  37327. }
  37328. declare module BABYLON {
  37329. /**
  37330. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37331. * such as in a 3D Space Shooter or a Flight Simulator.
  37332. */
  37333. export class FlyCamera extends TargetCamera {
  37334. /**
  37335. * Define the collision ellipsoid of the camera.
  37336. * This is helpful for simulating a camera body, like a player's body.
  37337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37338. */
  37339. ellipsoid: Vector3;
  37340. /**
  37341. * Define an offset for the position of the ellipsoid around the camera.
  37342. * This can be helpful if the camera is attached away from the player's body center,
  37343. * such as at its head.
  37344. */
  37345. ellipsoidOffset: Vector3;
  37346. /**
  37347. * Enable or disable collisions of the camera with the rest of the scene objects.
  37348. */
  37349. checkCollisions: boolean;
  37350. /**
  37351. * Enable or disable gravity on the camera.
  37352. */
  37353. applyGravity: boolean;
  37354. /**
  37355. * Define the current direction the camera is moving to.
  37356. */
  37357. cameraDirection: Vector3;
  37358. /**
  37359. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37360. * This overrides and empties cameraRotation.
  37361. */
  37362. rotationQuaternion: Quaternion;
  37363. /**
  37364. * Track Roll to maintain the wanted Rolling when looking around.
  37365. */
  37366. _trackRoll: number;
  37367. /**
  37368. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37369. */
  37370. rollCorrect: number;
  37371. /**
  37372. * Mimic a banked turn, Rolling the camera when Yawing.
  37373. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37374. */
  37375. bankedTurn: boolean;
  37376. /**
  37377. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37378. */
  37379. bankedTurnLimit: number;
  37380. /**
  37381. * Value of 0 disables the banked Roll.
  37382. * Value of 1 is equal to the Yaw angle in radians.
  37383. */
  37384. bankedTurnMultiplier: number;
  37385. /**
  37386. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37387. */
  37388. inputs: FlyCameraInputsManager;
  37389. /**
  37390. * Gets the input sensibility for mouse input.
  37391. * Higher values reduce sensitivity.
  37392. */
  37393. /**
  37394. * Sets the input sensibility for a mouse input.
  37395. * Higher values reduce sensitivity.
  37396. */
  37397. angularSensibility: number;
  37398. /**
  37399. * Get the keys for camera movement forward.
  37400. */
  37401. /**
  37402. * Set the keys for camera movement forward.
  37403. */
  37404. keysForward: number[];
  37405. /**
  37406. * Get the keys for camera movement backward.
  37407. */
  37408. keysBackward: number[];
  37409. /**
  37410. * Get the keys for camera movement up.
  37411. */
  37412. /**
  37413. * Set the keys for camera movement up.
  37414. */
  37415. keysUp: number[];
  37416. /**
  37417. * Get the keys for camera movement down.
  37418. */
  37419. /**
  37420. * Set the keys for camera movement down.
  37421. */
  37422. keysDown: number[];
  37423. /**
  37424. * Get the keys for camera movement left.
  37425. */
  37426. /**
  37427. * Set the keys for camera movement left.
  37428. */
  37429. keysLeft: number[];
  37430. /**
  37431. * Set the keys for camera movement right.
  37432. */
  37433. /**
  37434. * Set the keys for camera movement right.
  37435. */
  37436. keysRight: number[];
  37437. /**
  37438. * Event raised when the camera collides with a mesh in the scene.
  37439. */
  37440. onCollide: (collidedMesh: AbstractMesh) => void;
  37441. private _collider;
  37442. private _needMoveForGravity;
  37443. private _oldPosition;
  37444. private _diffPosition;
  37445. private _newPosition;
  37446. /** @hidden */
  37447. _localDirection: Vector3;
  37448. /** @hidden */
  37449. _transformedDirection: Vector3;
  37450. /**
  37451. * Instantiates a FlyCamera.
  37452. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37453. * such as in a 3D Space Shooter or a Flight Simulator.
  37454. * @param name Define the name of the camera in the scene.
  37455. * @param position Define the starting position of the camera in the scene.
  37456. * @param scene Define the scene the camera belongs to.
  37457. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37458. */
  37459. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37460. /**
  37461. * Attach a control to the HTML DOM element.
  37462. * @param element Defines the element that listens to the input events.
  37463. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37464. */
  37465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37466. /**
  37467. * Detach a control from the HTML DOM element.
  37468. * The camera will stop reacting to that input.
  37469. * @param element Defines the element that listens to the input events.
  37470. */
  37471. detachControl(element: HTMLElement): void;
  37472. private _collisionMask;
  37473. /**
  37474. * Get the mask that the camera ignores in collision events.
  37475. */
  37476. /**
  37477. * Set the mask that the camera ignores in collision events.
  37478. */
  37479. collisionMask: number;
  37480. /** @hidden */
  37481. _collideWithWorld(displacement: Vector3): void;
  37482. /** @hidden */
  37483. private _onCollisionPositionChange;
  37484. /** @hidden */
  37485. _checkInputs(): void;
  37486. /** @hidden */
  37487. _decideIfNeedsToMove(): boolean;
  37488. /** @hidden */
  37489. _updatePosition(): void;
  37490. /**
  37491. * Restore the Roll to its target value at the rate specified.
  37492. * @param rate - Higher means slower restoring.
  37493. * @hidden
  37494. */
  37495. restoreRoll(rate: number): void;
  37496. /**
  37497. * Destroy the camera and release the current resources held by it.
  37498. */
  37499. dispose(): void;
  37500. /**
  37501. * Get the current object class name.
  37502. * @returns the class name.
  37503. */
  37504. getClassName(): string;
  37505. }
  37506. }
  37507. declare module BABYLON {
  37508. /**
  37509. * Listen to keyboard events to control the camera.
  37510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37511. */
  37512. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37513. /**
  37514. * Defines the camera the input is attached to.
  37515. */
  37516. camera: FlyCamera;
  37517. /**
  37518. * The list of keyboard keys used to control the forward move of the camera.
  37519. */
  37520. keysForward: number[];
  37521. /**
  37522. * The list of keyboard keys used to control the backward move of the camera.
  37523. */
  37524. keysBackward: number[];
  37525. /**
  37526. * The list of keyboard keys used to control the forward move of the camera.
  37527. */
  37528. keysUp: number[];
  37529. /**
  37530. * The list of keyboard keys used to control the backward move of the camera.
  37531. */
  37532. keysDown: number[];
  37533. /**
  37534. * The list of keyboard keys used to control the right strafe move of the camera.
  37535. */
  37536. keysRight: number[];
  37537. /**
  37538. * The list of keyboard keys used to control the left strafe move of the camera.
  37539. */
  37540. keysLeft: number[];
  37541. private _keys;
  37542. private _onCanvasBlurObserver;
  37543. private _onKeyboardObserver;
  37544. private _engine;
  37545. private _scene;
  37546. /**
  37547. * Attach the input controls to a specific dom element to get the input from.
  37548. * @param element Defines the element the controls should be listened from
  37549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37550. */
  37551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37552. /**
  37553. * Detach the current controls from the specified dom element.
  37554. * @param element Defines the element to stop listening the inputs from
  37555. */
  37556. detachControl(element: Nullable<HTMLElement>): void;
  37557. /**
  37558. * Gets the class name of the current intput.
  37559. * @returns the class name
  37560. */
  37561. getClassName(): string;
  37562. /** @hidden */
  37563. _onLostFocus(e: FocusEvent): void;
  37564. /**
  37565. * Get the friendly name associated with the input class.
  37566. * @returns the input friendly name
  37567. */
  37568. getSimpleName(): string;
  37569. /**
  37570. * Update the current camera state depending on the inputs that have been used this frame.
  37571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37572. */
  37573. checkInputs(): void;
  37574. }
  37575. }
  37576. declare module BABYLON {
  37577. /**
  37578. * Manage the mouse wheel inputs to control a follow camera.
  37579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37580. */
  37581. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37582. /**
  37583. * Defines the camera the input is attached to.
  37584. */
  37585. camera: FollowCamera;
  37586. /**
  37587. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37588. */
  37589. axisControlRadius: boolean;
  37590. /**
  37591. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37592. */
  37593. axisControlHeight: boolean;
  37594. /**
  37595. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37596. */
  37597. axisControlRotation: boolean;
  37598. /**
  37599. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37600. * relation to mouseWheel events.
  37601. */
  37602. wheelPrecision: number;
  37603. /**
  37604. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37605. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37606. */
  37607. wheelDeltaPercentage: number;
  37608. private _wheel;
  37609. private _observer;
  37610. /**
  37611. * Attach the input controls to a specific dom element to get the input from.
  37612. * @param element Defines the element the controls should be listened from
  37613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37614. */
  37615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37616. /**
  37617. * Detach the current controls from the specified dom element.
  37618. * @param element Defines the element to stop listening the inputs from
  37619. */
  37620. detachControl(element: Nullable<HTMLElement>): void;
  37621. /**
  37622. * Gets the class name of the current intput.
  37623. * @returns the class name
  37624. */
  37625. getClassName(): string;
  37626. /**
  37627. * Get the friendly name associated with the input class.
  37628. * @returns the input friendly name
  37629. */
  37630. getSimpleName(): string;
  37631. }
  37632. }
  37633. declare module BABYLON {
  37634. /**
  37635. * Manage the pointers inputs to control an follow camera.
  37636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37637. */
  37638. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37639. /**
  37640. * Defines the camera the input is attached to.
  37641. */
  37642. camera: FollowCamera;
  37643. /**
  37644. * Gets the class name of the current input.
  37645. * @returns the class name
  37646. */
  37647. getClassName(): string;
  37648. /**
  37649. * Defines the pointer angular sensibility along the X axis or how fast is
  37650. * the camera rotating.
  37651. * A negative number will reverse the axis direction.
  37652. */
  37653. angularSensibilityX: number;
  37654. /**
  37655. * Defines the pointer angular sensibility along the Y axis or how fast is
  37656. * the camera rotating.
  37657. * A negative number will reverse the axis direction.
  37658. */
  37659. angularSensibilityY: number;
  37660. /**
  37661. * Defines the pointer pinch precision or how fast is the camera zooming.
  37662. * A negative number will reverse the axis direction.
  37663. */
  37664. pinchPrecision: number;
  37665. /**
  37666. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37667. * from 0.
  37668. * It defines the percentage of current camera.radius to use as delta when
  37669. * pinch zoom is used.
  37670. */
  37671. pinchDeltaPercentage: number;
  37672. /**
  37673. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37674. */
  37675. axisXControlRadius: boolean;
  37676. /**
  37677. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37678. */
  37679. axisXControlHeight: boolean;
  37680. /**
  37681. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37682. */
  37683. axisXControlRotation: boolean;
  37684. /**
  37685. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37686. */
  37687. axisYControlRadius: boolean;
  37688. /**
  37689. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37690. */
  37691. axisYControlHeight: boolean;
  37692. /**
  37693. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37694. */
  37695. axisYControlRotation: boolean;
  37696. /**
  37697. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37698. */
  37699. axisPinchControlRadius: boolean;
  37700. /**
  37701. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37702. */
  37703. axisPinchControlHeight: boolean;
  37704. /**
  37705. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37706. */
  37707. axisPinchControlRotation: boolean;
  37708. /**
  37709. * Log error messages if basic misconfiguration has occurred.
  37710. */
  37711. warningEnable: boolean;
  37712. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37713. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37714. private _warningCounter;
  37715. private _warning;
  37716. }
  37717. }
  37718. declare module BABYLON {
  37719. /**
  37720. * Default Inputs manager for the FollowCamera.
  37721. * It groups all the default supported inputs for ease of use.
  37722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37723. */
  37724. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37725. /**
  37726. * Instantiates a new FollowCameraInputsManager.
  37727. * @param camera Defines the camera the inputs belong to
  37728. */
  37729. constructor(camera: FollowCamera);
  37730. /**
  37731. * Add keyboard input support to the input manager.
  37732. * @returns the current input manager
  37733. */
  37734. addKeyboard(): FollowCameraInputsManager;
  37735. /**
  37736. * Add mouse wheel input support to the input manager.
  37737. * @returns the current input manager
  37738. */
  37739. addMouseWheel(): FollowCameraInputsManager;
  37740. /**
  37741. * Add pointers input support to the input manager.
  37742. * @returns the current input manager
  37743. */
  37744. addPointers(): FollowCameraInputsManager;
  37745. /**
  37746. * Add orientation input support to the input manager.
  37747. * @returns the current input manager
  37748. */
  37749. addVRDeviceOrientation(): FollowCameraInputsManager;
  37750. }
  37751. }
  37752. declare module BABYLON {
  37753. /**
  37754. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37755. * an arc rotate version arcFollowCamera are available.
  37756. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37757. */
  37758. export class FollowCamera extends TargetCamera {
  37759. /**
  37760. * Distance the follow camera should follow an object at
  37761. */
  37762. radius: number;
  37763. /**
  37764. * Minimum allowed distance of the camera to the axis of rotation
  37765. * (The camera can not get closer).
  37766. * This can help limiting how the Camera is able to move in the scene.
  37767. */
  37768. lowerRadiusLimit: Nullable<number>;
  37769. /**
  37770. * Maximum allowed distance of the camera to the axis of rotation
  37771. * (The camera can not get further).
  37772. * This can help limiting how the Camera is able to move in the scene.
  37773. */
  37774. upperRadiusLimit: Nullable<number>;
  37775. /**
  37776. * Define a rotation offset between the camera and the object it follows
  37777. */
  37778. rotationOffset: number;
  37779. /**
  37780. * Minimum allowed angle to camera position relative to target object.
  37781. * This can help limiting how the Camera is able to move in the scene.
  37782. */
  37783. lowerRotationOffsetLimit: Nullable<number>;
  37784. /**
  37785. * Maximum allowed angle to camera position relative to target object.
  37786. * This can help limiting how the Camera is able to move in the scene.
  37787. */
  37788. upperRotationOffsetLimit: Nullable<number>;
  37789. /**
  37790. * Define a height offset between the camera and the object it follows.
  37791. * It can help following an object from the top (like a car chaing a plane)
  37792. */
  37793. heightOffset: number;
  37794. /**
  37795. * Minimum allowed height of camera position relative to target object.
  37796. * This can help limiting how the Camera is able to move in the scene.
  37797. */
  37798. lowerHeightOffsetLimit: Nullable<number>;
  37799. /**
  37800. * Maximum allowed height of camera position relative to target object.
  37801. * This can help limiting how the Camera is able to move in the scene.
  37802. */
  37803. upperHeightOffsetLimit: Nullable<number>;
  37804. /**
  37805. * Define how fast the camera can accelerate to follow it s target.
  37806. */
  37807. cameraAcceleration: number;
  37808. /**
  37809. * Define the speed limit of the camera following an object.
  37810. */
  37811. maxCameraSpeed: number;
  37812. /**
  37813. * Define the target of the camera.
  37814. */
  37815. lockedTarget: Nullable<AbstractMesh>;
  37816. /**
  37817. * Defines the input associated with the camera.
  37818. */
  37819. inputs: FollowCameraInputsManager;
  37820. /**
  37821. * Instantiates the follow camera.
  37822. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37823. * @param name Define the name of the camera in the scene
  37824. * @param position Define the position of the camera
  37825. * @param scene Define the scene the camera belong to
  37826. * @param lockedTarget Define the target of the camera
  37827. */
  37828. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37829. private _follow;
  37830. /**
  37831. * Attached controls to the current camera.
  37832. * @param element Defines the element the controls should be listened from
  37833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37834. */
  37835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37836. /**
  37837. * Detach the current controls from the camera.
  37838. * The camera will stop reacting to inputs.
  37839. * @param element Defines the element to stop listening the inputs from
  37840. */
  37841. detachControl(element: HTMLElement): void;
  37842. /** @hidden */
  37843. _checkInputs(): void;
  37844. private _checkLimits;
  37845. /**
  37846. * Gets the camera class name.
  37847. * @returns the class name
  37848. */
  37849. getClassName(): string;
  37850. }
  37851. /**
  37852. * Arc Rotate version of the follow camera.
  37853. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37854. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37855. */
  37856. export class ArcFollowCamera extends TargetCamera {
  37857. /** The longitudinal angle of the camera */
  37858. alpha: number;
  37859. /** The latitudinal angle of the camera */
  37860. beta: number;
  37861. /** The radius of the camera from its target */
  37862. radius: number;
  37863. /** Define the camera target (the messh it should follow) */
  37864. target: Nullable<AbstractMesh>;
  37865. private _cartesianCoordinates;
  37866. /**
  37867. * Instantiates a new ArcFollowCamera
  37868. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37869. * @param name Define the name of the camera
  37870. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37871. * @param beta Define the rotation angle of the camera around the elevation axis
  37872. * @param radius Define the radius of the camera from its target point
  37873. * @param target Define the target of the camera
  37874. * @param scene Define the scene the camera belongs to
  37875. */
  37876. constructor(name: string,
  37877. /** The longitudinal angle of the camera */
  37878. alpha: number,
  37879. /** The latitudinal angle of the camera */
  37880. beta: number,
  37881. /** The radius of the camera from its target */
  37882. radius: number,
  37883. /** Define the camera target (the messh it should follow) */
  37884. target: Nullable<AbstractMesh>, scene: Scene);
  37885. private _follow;
  37886. /** @hidden */
  37887. _checkInputs(): void;
  37888. /**
  37889. * Returns the class name of the object.
  37890. * It is mostly used internally for serialization purposes.
  37891. */
  37892. getClassName(): string;
  37893. }
  37894. }
  37895. declare module BABYLON {
  37896. /**
  37897. * Manage the keyboard inputs to control the movement of a follow camera.
  37898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37899. */
  37900. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37901. /**
  37902. * Defines the camera the input is attached to.
  37903. */
  37904. camera: FollowCamera;
  37905. /**
  37906. * Defines the list of key codes associated with the up action (increase heightOffset)
  37907. */
  37908. keysHeightOffsetIncr: number[];
  37909. /**
  37910. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37911. */
  37912. keysHeightOffsetDecr: number[];
  37913. /**
  37914. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37915. */
  37916. keysHeightOffsetModifierAlt: boolean;
  37917. /**
  37918. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37919. */
  37920. keysHeightOffsetModifierCtrl: boolean;
  37921. /**
  37922. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37923. */
  37924. keysHeightOffsetModifierShift: boolean;
  37925. /**
  37926. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37927. */
  37928. keysRotationOffsetIncr: number[];
  37929. /**
  37930. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37931. */
  37932. keysRotationOffsetDecr: number[];
  37933. /**
  37934. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37935. */
  37936. keysRotationOffsetModifierAlt: boolean;
  37937. /**
  37938. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37939. */
  37940. keysRotationOffsetModifierCtrl: boolean;
  37941. /**
  37942. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37943. */
  37944. keysRotationOffsetModifierShift: boolean;
  37945. /**
  37946. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37947. */
  37948. keysRadiusIncr: number[];
  37949. /**
  37950. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37951. */
  37952. keysRadiusDecr: number[];
  37953. /**
  37954. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37955. */
  37956. keysRadiusModifierAlt: boolean;
  37957. /**
  37958. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37959. */
  37960. keysRadiusModifierCtrl: boolean;
  37961. /**
  37962. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37963. */
  37964. keysRadiusModifierShift: boolean;
  37965. /**
  37966. * Defines the rate of change of heightOffset.
  37967. */
  37968. heightSensibility: number;
  37969. /**
  37970. * Defines the rate of change of rotationOffset.
  37971. */
  37972. rotationSensibility: number;
  37973. /**
  37974. * Defines the rate of change of radius.
  37975. */
  37976. radiusSensibility: number;
  37977. private _keys;
  37978. private _ctrlPressed;
  37979. private _altPressed;
  37980. private _shiftPressed;
  37981. private _onCanvasBlurObserver;
  37982. private _onKeyboardObserver;
  37983. private _engine;
  37984. private _scene;
  37985. /**
  37986. * Attach the input controls to a specific dom element to get the input from.
  37987. * @param element Defines the element the controls should be listened from
  37988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37989. */
  37990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37991. /**
  37992. * Detach the current controls from the specified dom element.
  37993. * @param element Defines the element to stop listening the inputs from
  37994. */
  37995. detachControl(element: Nullable<HTMLElement>): void;
  37996. /**
  37997. * Update the current camera state depending on the inputs that have been used this frame.
  37998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37999. */
  38000. checkInputs(): void;
  38001. /**
  38002. * Gets the class name of the current input.
  38003. * @returns the class name
  38004. */
  38005. getClassName(): string;
  38006. /**
  38007. * Get the friendly name associated with the input class.
  38008. * @returns the input friendly name
  38009. */
  38010. getSimpleName(): string;
  38011. /**
  38012. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38013. * allow modification of the heightOffset value.
  38014. */
  38015. private _modifierHeightOffset;
  38016. /**
  38017. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38018. * allow modification of the rotationOffset value.
  38019. */
  38020. private _modifierRotationOffset;
  38021. /**
  38022. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38023. * allow modification of the radius value.
  38024. */
  38025. private _modifierRadius;
  38026. }
  38027. }
  38028. declare module BABYLON {
  38029. interface FreeCameraInputsManager {
  38030. /**
  38031. * @hidden
  38032. */
  38033. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38034. /**
  38035. * Add orientation input support to the input manager.
  38036. * @returns the current input manager
  38037. */
  38038. addDeviceOrientation(): FreeCameraInputsManager;
  38039. }
  38040. /**
  38041. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38042. * Screen rotation is taken into account.
  38043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38044. */
  38045. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38046. private _camera;
  38047. private _screenOrientationAngle;
  38048. private _constantTranform;
  38049. private _screenQuaternion;
  38050. private _alpha;
  38051. private _beta;
  38052. private _gamma;
  38053. /**
  38054. * Can be used to detect if a device orientation sensor is availible on a device
  38055. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38056. * @returns a promise that will resolve on orientation change
  38057. */
  38058. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38059. /**
  38060. * @hidden
  38061. */
  38062. _onDeviceOrientationChangedObservable: Observable<void>;
  38063. /**
  38064. * Instantiates a new input
  38065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38066. */
  38067. constructor();
  38068. /**
  38069. * Define the camera controlled by the input.
  38070. */
  38071. camera: FreeCamera;
  38072. /**
  38073. * Attach the input controls to a specific dom element to get the input from.
  38074. * @param element Defines the element the controls should be listened from
  38075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38076. */
  38077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38078. private _orientationChanged;
  38079. private _deviceOrientation;
  38080. /**
  38081. * Detach the current controls from the specified dom element.
  38082. * @param element Defines the element to stop listening the inputs from
  38083. */
  38084. detachControl(element: Nullable<HTMLElement>): void;
  38085. /**
  38086. * Update the current camera state depending on the inputs that have been used this frame.
  38087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38088. */
  38089. checkInputs(): void;
  38090. /**
  38091. * Gets the class name of the current intput.
  38092. * @returns the class name
  38093. */
  38094. getClassName(): string;
  38095. /**
  38096. * Get the friendly name associated with the input class.
  38097. * @returns the input friendly name
  38098. */
  38099. getSimpleName(): string;
  38100. }
  38101. }
  38102. declare module BABYLON {
  38103. /**
  38104. * Manage the gamepad inputs to control a free camera.
  38105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38106. */
  38107. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38108. /**
  38109. * Define the camera the input is attached to.
  38110. */
  38111. camera: FreeCamera;
  38112. /**
  38113. * Define the Gamepad controlling the input
  38114. */
  38115. gamepad: Nullable<Gamepad>;
  38116. /**
  38117. * Defines the gamepad rotation sensiblity.
  38118. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38119. */
  38120. gamepadAngularSensibility: number;
  38121. /**
  38122. * Defines the gamepad move sensiblity.
  38123. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38124. */
  38125. gamepadMoveSensibility: number;
  38126. private _onGamepadConnectedObserver;
  38127. private _onGamepadDisconnectedObserver;
  38128. private _cameraTransform;
  38129. private _deltaTransform;
  38130. private _vector3;
  38131. private _vector2;
  38132. /**
  38133. * Attach the input controls to a specific dom element to get the input from.
  38134. * @param element Defines the element the controls should be listened from
  38135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38136. */
  38137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38138. /**
  38139. * Detach the current controls from the specified dom element.
  38140. * @param element Defines the element to stop listening the inputs from
  38141. */
  38142. detachControl(element: Nullable<HTMLElement>): void;
  38143. /**
  38144. * Update the current camera state depending on the inputs that have been used this frame.
  38145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38146. */
  38147. checkInputs(): void;
  38148. /**
  38149. * Gets the class name of the current intput.
  38150. * @returns the class name
  38151. */
  38152. getClassName(): string;
  38153. /**
  38154. * Get the friendly name associated with the input class.
  38155. * @returns the input friendly name
  38156. */
  38157. getSimpleName(): string;
  38158. }
  38159. }
  38160. declare module BABYLON {
  38161. /**
  38162. * Defines the potential axis of a Joystick
  38163. */
  38164. export enum JoystickAxis {
  38165. /** X axis */
  38166. X = 0,
  38167. /** Y axis */
  38168. Y = 1,
  38169. /** Z axis */
  38170. Z = 2
  38171. }
  38172. /**
  38173. * Class used to define virtual joystick (used in touch mode)
  38174. */
  38175. export class VirtualJoystick {
  38176. /**
  38177. * Gets or sets a boolean indicating that left and right values must be inverted
  38178. */
  38179. reverseLeftRight: boolean;
  38180. /**
  38181. * Gets or sets a boolean indicating that up and down values must be inverted
  38182. */
  38183. reverseUpDown: boolean;
  38184. /**
  38185. * Gets the offset value for the position (ie. the change of the position value)
  38186. */
  38187. deltaPosition: Vector3;
  38188. /**
  38189. * Gets a boolean indicating if the virtual joystick was pressed
  38190. */
  38191. pressed: boolean;
  38192. /**
  38193. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38194. */
  38195. static Canvas: Nullable<HTMLCanvasElement>;
  38196. private static _globalJoystickIndex;
  38197. private static vjCanvasContext;
  38198. private static vjCanvasWidth;
  38199. private static vjCanvasHeight;
  38200. private static halfWidth;
  38201. private _action;
  38202. private _axisTargetedByLeftAndRight;
  38203. private _axisTargetedByUpAndDown;
  38204. private _joystickSensibility;
  38205. private _inversedSensibility;
  38206. private _joystickPointerID;
  38207. private _joystickColor;
  38208. private _joystickPointerPos;
  38209. private _joystickPreviousPointerPos;
  38210. private _joystickPointerStartPos;
  38211. private _deltaJoystickVector;
  38212. private _leftJoystick;
  38213. private _touches;
  38214. private _onPointerDownHandlerRef;
  38215. private _onPointerMoveHandlerRef;
  38216. private _onPointerUpHandlerRef;
  38217. private _onResize;
  38218. /**
  38219. * Creates a new virtual joystick
  38220. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38221. */
  38222. constructor(leftJoystick?: boolean);
  38223. /**
  38224. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38225. * @param newJoystickSensibility defines the new sensibility
  38226. */
  38227. setJoystickSensibility(newJoystickSensibility: number): void;
  38228. private _onPointerDown;
  38229. private _onPointerMove;
  38230. private _onPointerUp;
  38231. /**
  38232. * Change the color of the virtual joystick
  38233. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38234. */
  38235. setJoystickColor(newColor: string): void;
  38236. /**
  38237. * Defines a callback to call when the joystick is touched
  38238. * @param action defines the callback
  38239. */
  38240. setActionOnTouch(action: () => any): void;
  38241. /**
  38242. * Defines which axis you'd like to control for left & right
  38243. * @param axis defines the axis to use
  38244. */
  38245. setAxisForLeftRight(axis: JoystickAxis): void;
  38246. /**
  38247. * Defines which axis you'd like to control for up & down
  38248. * @param axis defines the axis to use
  38249. */
  38250. setAxisForUpDown(axis: JoystickAxis): void;
  38251. private _drawVirtualJoystick;
  38252. /**
  38253. * Release internal HTML canvas
  38254. */
  38255. releaseCanvas(): void;
  38256. }
  38257. }
  38258. declare module BABYLON {
  38259. interface FreeCameraInputsManager {
  38260. /**
  38261. * Add virtual joystick input support to the input manager.
  38262. * @returns the current input manager
  38263. */
  38264. addVirtualJoystick(): FreeCameraInputsManager;
  38265. }
  38266. /**
  38267. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38269. */
  38270. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38271. /**
  38272. * Defines the camera the input is attached to.
  38273. */
  38274. camera: FreeCamera;
  38275. private _leftjoystick;
  38276. private _rightjoystick;
  38277. /**
  38278. * Gets the left stick of the virtual joystick.
  38279. * @returns The virtual Joystick
  38280. */
  38281. getLeftJoystick(): VirtualJoystick;
  38282. /**
  38283. * Gets the right stick of the virtual joystick.
  38284. * @returns The virtual Joystick
  38285. */
  38286. getRightJoystick(): VirtualJoystick;
  38287. /**
  38288. * Update the current camera state depending on the inputs that have been used this frame.
  38289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38290. */
  38291. checkInputs(): void;
  38292. /**
  38293. * Attach the input controls to a specific dom element to get the input from.
  38294. * @param element Defines the element the controls should be listened from
  38295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38296. */
  38297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38298. /**
  38299. * Detach the current controls from the specified dom element.
  38300. * @param element Defines the element to stop listening the inputs from
  38301. */
  38302. detachControl(element: Nullable<HTMLElement>): void;
  38303. /**
  38304. * Gets the class name of the current intput.
  38305. * @returns the class name
  38306. */
  38307. getClassName(): string;
  38308. /**
  38309. * Get the friendly name associated with the input class.
  38310. * @returns the input friendly name
  38311. */
  38312. getSimpleName(): string;
  38313. }
  38314. }
  38315. declare module BABYLON {
  38316. /**
  38317. * This represents a FPS type of camera controlled by touch.
  38318. * This is like a universal camera minus the Gamepad controls.
  38319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38320. */
  38321. export class TouchCamera extends FreeCamera {
  38322. /**
  38323. * Defines the touch sensibility for rotation.
  38324. * The higher the faster.
  38325. */
  38326. touchAngularSensibility: number;
  38327. /**
  38328. * Defines the touch sensibility for move.
  38329. * The higher the faster.
  38330. */
  38331. touchMoveSensibility: number;
  38332. /**
  38333. * Instantiates a new touch camera.
  38334. * This represents a FPS type of camera controlled by touch.
  38335. * This is like a universal camera minus the Gamepad controls.
  38336. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38337. * @param name Define the name of the camera in the scene
  38338. * @param position Define the start position of the camera in the scene
  38339. * @param scene Define the scene the camera belongs to
  38340. */
  38341. constructor(name: string, position: Vector3, scene: Scene);
  38342. /**
  38343. * Gets the current object class name.
  38344. * @return the class name
  38345. */
  38346. getClassName(): string;
  38347. /** @hidden */
  38348. _setupInputs(): void;
  38349. }
  38350. }
  38351. declare module BABYLON {
  38352. /**
  38353. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38354. * being tilted forward or back and left or right.
  38355. */
  38356. export class DeviceOrientationCamera extends FreeCamera {
  38357. private _initialQuaternion;
  38358. private _quaternionCache;
  38359. private _tmpDragQuaternion;
  38360. private _disablePointerInputWhenUsingDeviceOrientation;
  38361. /**
  38362. * Creates a new device orientation camera
  38363. * @param name The name of the camera
  38364. * @param position The start position camera
  38365. * @param scene The scene the camera belongs to
  38366. */
  38367. constructor(name: string, position: Vector3, scene: Scene);
  38368. /**
  38369. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38370. */
  38371. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38372. private _dragFactor;
  38373. /**
  38374. * Enabled turning on the y axis when the orientation sensor is active
  38375. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38376. */
  38377. enableHorizontalDragging(dragFactor?: number): void;
  38378. /**
  38379. * Gets the current instance class name ("DeviceOrientationCamera").
  38380. * This helps avoiding instanceof at run time.
  38381. * @returns the class name
  38382. */
  38383. getClassName(): string;
  38384. /**
  38385. * @hidden
  38386. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38387. */
  38388. _checkInputs(): void;
  38389. /**
  38390. * Reset the camera to its default orientation on the specified axis only.
  38391. * @param axis The axis to reset
  38392. */
  38393. resetToCurrentRotation(axis?: Axis): void;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. /**
  38398. * Defines supported buttons for XBox360 compatible gamepads
  38399. */
  38400. export enum Xbox360Button {
  38401. /** A */
  38402. A = 0,
  38403. /** B */
  38404. B = 1,
  38405. /** X */
  38406. X = 2,
  38407. /** Y */
  38408. Y = 3,
  38409. /** Start */
  38410. Start = 4,
  38411. /** Back */
  38412. Back = 5,
  38413. /** Left button */
  38414. LB = 6,
  38415. /** Right button */
  38416. RB = 7,
  38417. /** Left stick */
  38418. LeftStick = 8,
  38419. /** Right stick */
  38420. RightStick = 9
  38421. }
  38422. /** Defines values for XBox360 DPad */
  38423. export enum Xbox360Dpad {
  38424. /** Up */
  38425. Up = 0,
  38426. /** Down */
  38427. Down = 1,
  38428. /** Left */
  38429. Left = 2,
  38430. /** Right */
  38431. Right = 3
  38432. }
  38433. /**
  38434. * Defines a XBox360 gamepad
  38435. */
  38436. export class Xbox360Pad extends Gamepad {
  38437. private _leftTrigger;
  38438. private _rightTrigger;
  38439. private _onlefttriggerchanged;
  38440. private _onrighttriggerchanged;
  38441. private _onbuttondown;
  38442. private _onbuttonup;
  38443. private _ondpaddown;
  38444. private _ondpadup;
  38445. /** Observable raised when a button is pressed */
  38446. onButtonDownObservable: Observable<Xbox360Button>;
  38447. /** Observable raised when a button is released */
  38448. onButtonUpObservable: Observable<Xbox360Button>;
  38449. /** Observable raised when a pad is pressed */
  38450. onPadDownObservable: Observable<Xbox360Dpad>;
  38451. /** Observable raised when a pad is released */
  38452. onPadUpObservable: Observable<Xbox360Dpad>;
  38453. private _buttonA;
  38454. private _buttonB;
  38455. private _buttonX;
  38456. private _buttonY;
  38457. private _buttonBack;
  38458. private _buttonStart;
  38459. private _buttonLB;
  38460. private _buttonRB;
  38461. private _buttonLeftStick;
  38462. private _buttonRightStick;
  38463. private _dPadUp;
  38464. private _dPadDown;
  38465. private _dPadLeft;
  38466. private _dPadRight;
  38467. private _isXboxOnePad;
  38468. /**
  38469. * Creates a new XBox360 gamepad object
  38470. * @param id defines the id of this gamepad
  38471. * @param index defines its index
  38472. * @param gamepad defines the internal HTML gamepad object
  38473. * @param xboxOne defines if it is a XBox One gamepad
  38474. */
  38475. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38476. /**
  38477. * Defines the callback to call when left trigger is pressed
  38478. * @param callback defines the callback to use
  38479. */
  38480. onlefttriggerchanged(callback: (value: number) => void): void;
  38481. /**
  38482. * Defines the callback to call when right trigger is pressed
  38483. * @param callback defines the callback to use
  38484. */
  38485. onrighttriggerchanged(callback: (value: number) => void): void;
  38486. /**
  38487. * Gets the left trigger value
  38488. */
  38489. /**
  38490. * Sets the left trigger value
  38491. */
  38492. leftTrigger: number;
  38493. /**
  38494. * Gets the right trigger value
  38495. */
  38496. /**
  38497. * Sets the right trigger value
  38498. */
  38499. rightTrigger: number;
  38500. /**
  38501. * Defines the callback to call when a button is pressed
  38502. * @param callback defines the callback to use
  38503. */
  38504. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38505. /**
  38506. * Defines the callback to call when a button is released
  38507. * @param callback defines the callback to use
  38508. */
  38509. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38510. /**
  38511. * Defines the callback to call when a pad is pressed
  38512. * @param callback defines the callback to use
  38513. */
  38514. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38515. /**
  38516. * Defines the callback to call when a pad is released
  38517. * @param callback defines the callback to use
  38518. */
  38519. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38520. private _setButtonValue;
  38521. private _setDPadValue;
  38522. /**
  38523. * Gets the value of the `A` button
  38524. */
  38525. /**
  38526. * Sets the value of the `A` button
  38527. */
  38528. buttonA: number;
  38529. /**
  38530. * Gets the value of the `B` button
  38531. */
  38532. /**
  38533. * Sets the value of the `B` button
  38534. */
  38535. buttonB: number;
  38536. /**
  38537. * Gets the value of the `X` button
  38538. */
  38539. /**
  38540. * Sets the value of the `X` button
  38541. */
  38542. buttonX: number;
  38543. /**
  38544. * Gets the value of the `Y` button
  38545. */
  38546. /**
  38547. * Sets the value of the `Y` button
  38548. */
  38549. buttonY: number;
  38550. /**
  38551. * Gets the value of the `Start` button
  38552. */
  38553. /**
  38554. * Sets the value of the `Start` button
  38555. */
  38556. buttonStart: number;
  38557. /**
  38558. * Gets the value of the `Back` button
  38559. */
  38560. /**
  38561. * Sets the value of the `Back` button
  38562. */
  38563. buttonBack: number;
  38564. /**
  38565. * Gets the value of the `Left` button
  38566. */
  38567. /**
  38568. * Sets the value of the `Left` button
  38569. */
  38570. buttonLB: number;
  38571. /**
  38572. * Gets the value of the `Right` button
  38573. */
  38574. /**
  38575. * Sets the value of the `Right` button
  38576. */
  38577. buttonRB: number;
  38578. /**
  38579. * Gets the value of the Left joystick
  38580. */
  38581. /**
  38582. * Sets the value of the Left joystick
  38583. */
  38584. buttonLeftStick: number;
  38585. /**
  38586. * Gets the value of the Right joystick
  38587. */
  38588. /**
  38589. * Sets the value of the Right joystick
  38590. */
  38591. buttonRightStick: number;
  38592. /**
  38593. * Gets the value of D-pad up
  38594. */
  38595. /**
  38596. * Sets the value of D-pad up
  38597. */
  38598. dPadUp: number;
  38599. /**
  38600. * Gets the value of D-pad down
  38601. */
  38602. /**
  38603. * Sets the value of D-pad down
  38604. */
  38605. dPadDown: number;
  38606. /**
  38607. * Gets the value of D-pad left
  38608. */
  38609. /**
  38610. * Sets the value of D-pad left
  38611. */
  38612. dPadLeft: number;
  38613. /**
  38614. * Gets the value of D-pad right
  38615. */
  38616. /**
  38617. * Sets the value of D-pad right
  38618. */
  38619. dPadRight: number;
  38620. /**
  38621. * Force the gamepad to synchronize with device values
  38622. */
  38623. update(): void;
  38624. /**
  38625. * Disposes the gamepad
  38626. */
  38627. dispose(): void;
  38628. }
  38629. }
  38630. declare module BABYLON {
  38631. /**
  38632. * Defines supported buttons for DualShock compatible gamepads
  38633. */
  38634. export enum DualShockButton {
  38635. /** Cross */
  38636. Cross = 0,
  38637. /** Circle */
  38638. Circle = 1,
  38639. /** Square */
  38640. Square = 2,
  38641. /** Triangle */
  38642. Triangle = 3,
  38643. /** Options */
  38644. Options = 4,
  38645. /** Share */
  38646. Share = 5,
  38647. /** L1 */
  38648. L1 = 6,
  38649. /** R1 */
  38650. R1 = 7,
  38651. /** Left stick */
  38652. LeftStick = 8,
  38653. /** Right stick */
  38654. RightStick = 9
  38655. }
  38656. /** Defines values for DualShock DPad */
  38657. export enum DualShockDpad {
  38658. /** Up */
  38659. Up = 0,
  38660. /** Down */
  38661. Down = 1,
  38662. /** Left */
  38663. Left = 2,
  38664. /** Right */
  38665. Right = 3
  38666. }
  38667. /**
  38668. * Defines a DualShock gamepad
  38669. */
  38670. export class DualShockPad extends Gamepad {
  38671. private _leftTrigger;
  38672. private _rightTrigger;
  38673. private _onlefttriggerchanged;
  38674. private _onrighttriggerchanged;
  38675. private _onbuttondown;
  38676. private _onbuttonup;
  38677. private _ondpaddown;
  38678. private _ondpadup;
  38679. /** Observable raised when a button is pressed */
  38680. onButtonDownObservable: Observable<DualShockButton>;
  38681. /** Observable raised when a button is released */
  38682. onButtonUpObservable: Observable<DualShockButton>;
  38683. /** Observable raised when a pad is pressed */
  38684. onPadDownObservable: Observable<DualShockDpad>;
  38685. /** Observable raised when a pad is released */
  38686. onPadUpObservable: Observable<DualShockDpad>;
  38687. private _buttonCross;
  38688. private _buttonCircle;
  38689. private _buttonSquare;
  38690. private _buttonTriangle;
  38691. private _buttonShare;
  38692. private _buttonOptions;
  38693. private _buttonL1;
  38694. private _buttonR1;
  38695. private _buttonLeftStick;
  38696. private _buttonRightStick;
  38697. private _dPadUp;
  38698. private _dPadDown;
  38699. private _dPadLeft;
  38700. private _dPadRight;
  38701. /**
  38702. * Creates a new DualShock gamepad object
  38703. * @param id defines the id of this gamepad
  38704. * @param index defines its index
  38705. * @param gamepad defines the internal HTML gamepad object
  38706. */
  38707. constructor(id: string, index: number, gamepad: any);
  38708. /**
  38709. * Defines the callback to call when left trigger is pressed
  38710. * @param callback defines the callback to use
  38711. */
  38712. onlefttriggerchanged(callback: (value: number) => void): void;
  38713. /**
  38714. * Defines the callback to call when right trigger is pressed
  38715. * @param callback defines the callback to use
  38716. */
  38717. onrighttriggerchanged(callback: (value: number) => void): void;
  38718. /**
  38719. * Gets the left trigger value
  38720. */
  38721. /**
  38722. * Sets the left trigger value
  38723. */
  38724. leftTrigger: number;
  38725. /**
  38726. * Gets the right trigger value
  38727. */
  38728. /**
  38729. * Sets the right trigger value
  38730. */
  38731. rightTrigger: number;
  38732. /**
  38733. * Defines the callback to call when a button is pressed
  38734. * @param callback defines the callback to use
  38735. */
  38736. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38737. /**
  38738. * Defines the callback to call when a button is released
  38739. * @param callback defines the callback to use
  38740. */
  38741. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38742. /**
  38743. * Defines the callback to call when a pad is pressed
  38744. * @param callback defines the callback to use
  38745. */
  38746. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38747. /**
  38748. * Defines the callback to call when a pad is released
  38749. * @param callback defines the callback to use
  38750. */
  38751. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38752. private _setButtonValue;
  38753. private _setDPadValue;
  38754. /**
  38755. * Gets the value of the `Cross` button
  38756. */
  38757. /**
  38758. * Sets the value of the `Cross` button
  38759. */
  38760. buttonCross: number;
  38761. /**
  38762. * Gets the value of the `Circle` button
  38763. */
  38764. /**
  38765. * Sets the value of the `Circle` button
  38766. */
  38767. buttonCircle: number;
  38768. /**
  38769. * Gets the value of the `Square` button
  38770. */
  38771. /**
  38772. * Sets the value of the `Square` button
  38773. */
  38774. buttonSquare: number;
  38775. /**
  38776. * Gets the value of the `Triangle` button
  38777. */
  38778. /**
  38779. * Sets the value of the `Triangle` button
  38780. */
  38781. buttonTriangle: number;
  38782. /**
  38783. * Gets the value of the `Options` button
  38784. */
  38785. /**
  38786. * Sets the value of the `Options` button
  38787. */
  38788. buttonOptions: number;
  38789. /**
  38790. * Gets the value of the `Share` button
  38791. */
  38792. /**
  38793. * Sets the value of the `Share` button
  38794. */
  38795. buttonShare: number;
  38796. /**
  38797. * Gets the value of the `L1` button
  38798. */
  38799. /**
  38800. * Sets the value of the `L1` button
  38801. */
  38802. buttonL1: number;
  38803. /**
  38804. * Gets the value of the `R1` button
  38805. */
  38806. /**
  38807. * Sets the value of the `R1` button
  38808. */
  38809. buttonR1: number;
  38810. /**
  38811. * Gets the value of the Left joystick
  38812. */
  38813. /**
  38814. * Sets the value of the Left joystick
  38815. */
  38816. buttonLeftStick: number;
  38817. /**
  38818. * Gets the value of the Right joystick
  38819. */
  38820. /**
  38821. * Sets the value of the Right joystick
  38822. */
  38823. buttonRightStick: number;
  38824. /**
  38825. * Gets the value of D-pad up
  38826. */
  38827. /**
  38828. * Sets the value of D-pad up
  38829. */
  38830. dPadUp: number;
  38831. /**
  38832. * Gets the value of D-pad down
  38833. */
  38834. /**
  38835. * Sets the value of D-pad down
  38836. */
  38837. dPadDown: number;
  38838. /**
  38839. * Gets the value of D-pad left
  38840. */
  38841. /**
  38842. * Sets the value of D-pad left
  38843. */
  38844. dPadLeft: number;
  38845. /**
  38846. * Gets the value of D-pad right
  38847. */
  38848. /**
  38849. * Sets the value of D-pad right
  38850. */
  38851. dPadRight: number;
  38852. /**
  38853. * Force the gamepad to synchronize with device values
  38854. */
  38855. update(): void;
  38856. /**
  38857. * Disposes the gamepad
  38858. */
  38859. dispose(): void;
  38860. }
  38861. }
  38862. declare module BABYLON {
  38863. /**
  38864. * Manager for handling gamepads
  38865. */
  38866. export class GamepadManager {
  38867. private _scene?;
  38868. private _babylonGamepads;
  38869. private _oneGamepadConnected;
  38870. /** @hidden */
  38871. _isMonitoring: boolean;
  38872. private _gamepadEventSupported;
  38873. private _gamepadSupport;
  38874. /**
  38875. * observable to be triggered when the gamepad controller has been connected
  38876. */
  38877. onGamepadConnectedObservable: Observable<Gamepad>;
  38878. /**
  38879. * observable to be triggered when the gamepad controller has been disconnected
  38880. */
  38881. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38882. private _onGamepadConnectedEvent;
  38883. private _onGamepadDisconnectedEvent;
  38884. /**
  38885. * Initializes the gamepad manager
  38886. * @param _scene BabylonJS scene
  38887. */
  38888. constructor(_scene?: Scene | undefined);
  38889. /**
  38890. * The gamepads in the game pad manager
  38891. */
  38892. readonly gamepads: Gamepad[];
  38893. /**
  38894. * Get the gamepad controllers based on type
  38895. * @param type The type of gamepad controller
  38896. * @returns Nullable gamepad
  38897. */
  38898. getGamepadByType(type?: number): Nullable<Gamepad>;
  38899. /**
  38900. * Disposes the gamepad manager
  38901. */
  38902. dispose(): void;
  38903. private _addNewGamepad;
  38904. private _startMonitoringGamepads;
  38905. private _stopMonitoringGamepads;
  38906. /** @hidden */
  38907. _checkGamepadsStatus(): void;
  38908. private _updateGamepadObjects;
  38909. }
  38910. }
  38911. declare module BABYLON {
  38912. interface Scene {
  38913. /** @hidden */
  38914. _gamepadManager: Nullable<GamepadManager>;
  38915. /**
  38916. * Gets the gamepad manager associated with the scene
  38917. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38918. */
  38919. gamepadManager: GamepadManager;
  38920. }
  38921. /**
  38922. * Interface representing a free camera inputs manager
  38923. */
  38924. interface FreeCameraInputsManager {
  38925. /**
  38926. * Adds gamepad input support to the FreeCameraInputsManager.
  38927. * @returns the FreeCameraInputsManager
  38928. */
  38929. addGamepad(): FreeCameraInputsManager;
  38930. }
  38931. /**
  38932. * Interface representing an arc rotate camera inputs manager
  38933. */
  38934. interface ArcRotateCameraInputsManager {
  38935. /**
  38936. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38937. * @returns the camera inputs manager
  38938. */
  38939. addGamepad(): ArcRotateCameraInputsManager;
  38940. }
  38941. /**
  38942. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38943. */
  38944. export class GamepadSystemSceneComponent implements ISceneComponent {
  38945. /**
  38946. * The component name helpfull to identify the component in the list of scene components.
  38947. */
  38948. readonly name: string;
  38949. /**
  38950. * The scene the component belongs to.
  38951. */
  38952. scene: Scene;
  38953. /**
  38954. * Creates a new instance of the component for the given scene
  38955. * @param scene Defines the scene to register the component in
  38956. */
  38957. constructor(scene: Scene);
  38958. /**
  38959. * Registers the component in a given scene
  38960. */
  38961. register(): void;
  38962. /**
  38963. * Rebuilds the elements related to this component in case of
  38964. * context lost for instance.
  38965. */
  38966. rebuild(): void;
  38967. /**
  38968. * Disposes the component and the associated ressources
  38969. */
  38970. dispose(): void;
  38971. private _beforeCameraUpdate;
  38972. }
  38973. }
  38974. declare module BABYLON {
  38975. /**
  38976. * 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,
  38977. * which still works and will still be found in many Playgrounds.
  38978. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38979. */
  38980. export class UniversalCamera extends TouchCamera {
  38981. /**
  38982. * Defines the gamepad rotation sensiblity.
  38983. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38984. */
  38985. gamepadAngularSensibility: number;
  38986. /**
  38987. * Defines the gamepad move sensiblity.
  38988. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38989. */
  38990. gamepadMoveSensibility: number;
  38991. /**
  38992. * 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,
  38993. * which still works and will still be found in many Playgrounds.
  38994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38995. * @param name Define the name of the camera in the scene
  38996. * @param position Define the start position of the camera in the scene
  38997. * @param scene Define the scene the camera belongs to
  38998. */
  38999. constructor(name: string, position: Vector3, scene: Scene);
  39000. /**
  39001. * Gets the current object class name.
  39002. * @return the class name
  39003. */
  39004. getClassName(): string;
  39005. }
  39006. }
  39007. declare module BABYLON {
  39008. /**
  39009. * This represents a FPS type of camera. This is only here for back compat purpose.
  39010. * Please use the UniversalCamera instead as both are identical.
  39011. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39012. */
  39013. export class GamepadCamera extends UniversalCamera {
  39014. /**
  39015. * Instantiates a new Gamepad Camera
  39016. * This represents a FPS type of camera. This is only here for back compat purpose.
  39017. * Please use the UniversalCamera instead as both are identical.
  39018. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39019. * @param name Define the name of the camera in the scene
  39020. * @param position Define the start position of the camera in the scene
  39021. * @param scene Define the scene the camera belongs to
  39022. */
  39023. constructor(name: string, position: Vector3, scene: Scene);
  39024. /**
  39025. * Gets the current object class name.
  39026. * @return the class name
  39027. */
  39028. getClassName(): string;
  39029. }
  39030. }
  39031. declare module BABYLON {
  39032. /** @hidden */
  39033. export var passPixelShader: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module BABYLON {
  39039. /** @hidden */
  39040. export var passCubePixelShader: {
  39041. name: string;
  39042. shader: string;
  39043. };
  39044. }
  39045. declare module BABYLON {
  39046. /**
  39047. * PassPostProcess which produces an output the same as it's input
  39048. */
  39049. export class PassPostProcess extends PostProcess {
  39050. /**
  39051. * Creates the PassPostProcess
  39052. * @param name The name of the effect.
  39053. * @param options The required width/height ratio to downsize to before computing the render pass.
  39054. * @param camera The camera to apply the render pass to.
  39055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39056. * @param engine The engine which the post process will be applied. (default: current engine)
  39057. * @param reusable If the post process can be reused on the same frame. (default: false)
  39058. * @param textureType The type of texture to be used when performing the post processing.
  39059. * @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)
  39060. */
  39061. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39062. }
  39063. /**
  39064. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39065. */
  39066. export class PassCubePostProcess extends PostProcess {
  39067. private _face;
  39068. /**
  39069. * Gets or sets the cube face to display.
  39070. * * 0 is +X
  39071. * * 1 is -X
  39072. * * 2 is +Y
  39073. * * 3 is -Y
  39074. * * 4 is +Z
  39075. * * 5 is -Z
  39076. */
  39077. face: number;
  39078. /**
  39079. * Creates the PassCubePostProcess
  39080. * @param name The name of the effect.
  39081. * @param options The required width/height ratio to downsize to before computing the render pass.
  39082. * @param camera The camera to apply the render pass to.
  39083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39084. * @param engine The engine which the post process will be applied. (default: current engine)
  39085. * @param reusable If the post process can be reused on the same frame. (default: false)
  39086. * @param textureType The type of texture to be used when performing the post processing.
  39087. * @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)
  39088. */
  39089. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39090. }
  39091. }
  39092. declare module BABYLON {
  39093. /** @hidden */
  39094. export var anaglyphPixelShader: {
  39095. name: string;
  39096. shader: string;
  39097. };
  39098. }
  39099. declare module BABYLON {
  39100. /**
  39101. * Postprocess used to generate anaglyphic rendering
  39102. */
  39103. export class AnaglyphPostProcess extends PostProcess {
  39104. private _passedProcess;
  39105. /**
  39106. * Creates a new AnaglyphPostProcess
  39107. * @param name defines postprocess name
  39108. * @param options defines creation options or target ratio scale
  39109. * @param rigCameras defines cameras using this postprocess
  39110. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39111. * @param engine defines hosting engine
  39112. * @param reusable defines if the postprocess will be reused multiple times per frame
  39113. */
  39114. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39120. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39121. */
  39122. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39123. /**
  39124. * Creates a new AnaglyphArcRotateCamera
  39125. * @param name defines camera name
  39126. * @param alpha defines alpha angle (in radians)
  39127. * @param beta defines beta angle (in radians)
  39128. * @param radius defines radius
  39129. * @param target defines camera target
  39130. * @param interaxialDistance defines distance between each color axis
  39131. * @param scene defines the hosting scene
  39132. */
  39133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39134. /**
  39135. * Gets camera class name
  39136. * @returns AnaglyphArcRotateCamera
  39137. */
  39138. getClassName(): string;
  39139. }
  39140. }
  39141. declare module BABYLON {
  39142. /**
  39143. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39144. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39145. */
  39146. export class AnaglyphFreeCamera extends FreeCamera {
  39147. /**
  39148. * Creates a new AnaglyphFreeCamera
  39149. * @param name defines camera name
  39150. * @param position defines initial position
  39151. * @param interaxialDistance defines distance between each color axis
  39152. * @param scene defines the hosting scene
  39153. */
  39154. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39155. /**
  39156. * Gets camera class name
  39157. * @returns AnaglyphFreeCamera
  39158. */
  39159. getClassName(): string;
  39160. }
  39161. }
  39162. declare module BABYLON {
  39163. /**
  39164. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39165. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39166. */
  39167. export class AnaglyphGamepadCamera extends GamepadCamera {
  39168. /**
  39169. * Creates a new AnaglyphGamepadCamera
  39170. * @param name defines camera name
  39171. * @param position defines initial position
  39172. * @param interaxialDistance defines distance between each color axis
  39173. * @param scene defines the hosting scene
  39174. */
  39175. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39176. /**
  39177. * Gets camera class name
  39178. * @returns AnaglyphGamepadCamera
  39179. */
  39180. getClassName(): string;
  39181. }
  39182. }
  39183. declare module BABYLON {
  39184. /**
  39185. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39186. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39187. */
  39188. export class AnaglyphUniversalCamera extends UniversalCamera {
  39189. /**
  39190. * Creates a new AnaglyphUniversalCamera
  39191. * @param name defines camera name
  39192. * @param position defines initial position
  39193. * @param interaxialDistance defines distance between each color axis
  39194. * @param scene defines the hosting scene
  39195. */
  39196. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39197. /**
  39198. * Gets camera class name
  39199. * @returns AnaglyphUniversalCamera
  39200. */
  39201. getClassName(): string;
  39202. }
  39203. }
  39204. declare module BABYLON {
  39205. /** @hidden */
  39206. export var stereoscopicInterlacePixelShader: {
  39207. name: string;
  39208. shader: string;
  39209. };
  39210. }
  39211. declare module BABYLON {
  39212. /**
  39213. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39214. */
  39215. export class StereoscopicInterlacePostProcess extends PostProcess {
  39216. private _stepSize;
  39217. private _passedProcess;
  39218. /**
  39219. * Initializes a StereoscopicInterlacePostProcess
  39220. * @param name The name of the effect.
  39221. * @param rigCameras The rig cameras to be appled to the post process
  39222. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39224. * @param engine The engine which the post process will be applied. (default: current engine)
  39225. * @param reusable If the post process can be reused on the same frame. (default: false)
  39226. */
  39227. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39228. }
  39229. }
  39230. declare module BABYLON {
  39231. /**
  39232. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39233. * @see http://doc.babylonjs.com/features/cameras
  39234. */
  39235. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39236. /**
  39237. * Creates a new StereoscopicArcRotateCamera
  39238. * @param name defines camera name
  39239. * @param alpha defines alpha angle (in radians)
  39240. * @param beta defines beta angle (in radians)
  39241. * @param radius defines radius
  39242. * @param target defines camera target
  39243. * @param interaxialDistance defines distance between each color axis
  39244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39245. * @param scene defines the hosting scene
  39246. */
  39247. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39248. /**
  39249. * Gets camera class name
  39250. * @returns StereoscopicArcRotateCamera
  39251. */
  39252. getClassName(): string;
  39253. }
  39254. }
  39255. declare module BABYLON {
  39256. /**
  39257. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39258. * @see http://doc.babylonjs.com/features/cameras
  39259. */
  39260. export class StereoscopicFreeCamera extends FreeCamera {
  39261. /**
  39262. * Creates a new StereoscopicFreeCamera
  39263. * @param name defines camera name
  39264. * @param position defines initial position
  39265. * @param interaxialDistance defines distance between each color axis
  39266. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39267. * @param scene defines the hosting scene
  39268. */
  39269. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39270. /**
  39271. * Gets camera class name
  39272. * @returns StereoscopicFreeCamera
  39273. */
  39274. getClassName(): string;
  39275. }
  39276. }
  39277. declare module BABYLON {
  39278. /**
  39279. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39280. * @see http://doc.babylonjs.com/features/cameras
  39281. */
  39282. export class StereoscopicGamepadCamera extends GamepadCamera {
  39283. /**
  39284. * Creates a new StereoscopicGamepadCamera
  39285. * @param name defines camera name
  39286. * @param position defines initial position
  39287. * @param interaxialDistance defines distance between each color axis
  39288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39289. * @param scene defines the hosting scene
  39290. */
  39291. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39292. /**
  39293. * Gets camera class name
  39294. * @returns StereoscopicGamepadCamera
  39295. */
  39296. getClassName(): string;
  39297. }
  39298. }
  39299. declare module BABYLON {
  39300. /**
  39301. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39302. * @see http://doc.babylonjs.com/features/cameras
  39303. */
  39304. export class StereoscopicUniversalCamera extends UniversalCamera {
  39305. /**
  39306. * Creates a new StereoscopicUniversalCamera
  39307. * @param name defines camera name
  39308. * @param position defines initial position
  39309. * @param interaxialDistance defines distance between each color axis
  39310. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39311. * @param scene defines the hosting scene
  39312. */
  39313. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39314. /**
  39315. * Gets camera class name
  39316. * @returns StereoscopicUniversalCamera
  39317. */
  39318. getClassName(): string;
  39319. }
  39320. }
  39321. declare module BABYLON {
  39322. /**
  39323. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39324. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39325. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39326. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39327. */
  39328. export class VirtualJoysticksCamera extends FreeCamera {
  39329. /**
  39330. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39331. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39332. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39333. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39334. * @param name Define the name of the camera in the scene
  39335. * @param position Define the start position of the camera in the scene
  39336. * @param scene Define the scene the camera belongs to
  39337. */
  39338. constructor(name: string, position: Vector3, scene: Scene);
  39339. /**
  39340. * Gets the current object class name.
  39341. * @return the class name
  39342. */
  39343. getClassName(): string;
  39344. }
  39345. }
  39346. declare module BABYLON {
  39347. /**
  39348. * This represents all the required metrics to create a VR camera.
  39349. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39350. */
  39351. export class VRCameraMetrics {
  39352. /**
  39353. * Define the horizontal resolution off the screen.
  39354. */
  39355. hResolution: number;
  39356. /**
  39357. * Define the vertical resolution off the screen.
  39358. */
  39359. vResolution: number;
  39360. /**
  39361. * Define the horizontal screen size.
  39362. */
  39363. hScreenSize: number;
  39364. /**
  39365. * Define the vertical screen size.
  39366. */
  39367. vScreenSize: number;
  39368. /**
  39369. * Define the vertical screen center position.
  39370. */
  39371. vScreenCenter: number;
  39372. /**
  39373. * Define the distance of the eyes to the screen.
  39374. */
  39375. eyeToScreenDistance: number;
  39376. /**
  39377. * Define the distance between both lenses
  39378. */
  39379. lensSeparationDistance: number;
  39380. /**
  39381. * Define the distance between both viewer's eyes.
  39382. */
  39383. interpupillaryDistance: number;
  39384. /**
  39385. * Define the distortion factor of the VR postprocess.
  39386. * Please, touch with care.
  39387. */
  39388. distortionK: number[];
  39389. /**
  39390. * Define the chromatic aberration correction factors for the VR post process.
  39391. */
  39392. chromaAbCorrection: number[];
  39393. /**
  39394. * Define the scale factor of the post process.
  39395. * The smaller the better but the slower.
  39396. */
  39397. postProcessScaleFactor: number;
  39398. /**
  39399. * Define an offset for the lens center.
  39400. */
  39401. lensCenterOffset: number;
  39402. /**
  39403. * Define if the current vr camera should compensate the distortion of the lense or not.
  39404. */
  39405. compensateDistortion: boolean;
  39406. /**
  39407. * Defines if multiview should be enabled when rendering (Default: false)
  39408. */
  39409. multiviewEnabled: boolean;
  39410. /**
  39411. * Gets the rendering aspect ratio based on the provided resolutions.
  39412. */
  39413. readonly aspectRatio: number;
  39414. /**
  39415. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39416. */
  39417. readonly aspectRatioFov: number;
  39418. /**
  39419. * @hidden
  39420. */
  39421. readonly leftHMatrix: Matrix;
  39422. /**
  39423. * @hidden
  39424. */
  39425. readonly rightHMatrix: Matrix;
  39426. /**
  39427. * @hidden
  39428. */
  39429. readonly leftPreViewMatrix: Matrix;
  39430. /**
  39431. * @hidden
  39432. */
  39433. readonly rightPreViewMatrix: Matrix;
  39434. /**
  39435. * Get the default VRMetrics based on the most generic setup.
  39436. * @returns the default vr metrics
  39437. */
  39438. static GetDefault(): VRCameraMetrics;
  39439. }
  39440. }
  39441. declare module BABYLON {
  39442. /** @hidden */
  39443. export var vrDistortionCorrectionPixelShader: {
  39444. name: string;
  39445. shader: string;
  39446. };
  39447. }
  39448. declare module BABYLON {
  39449. /**
  39450. * VRDistortionCorrectionPostProcess used for mobile VR
  39451. */
  39452. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39453. private _isRightEye;
  39454. private _distortionFactors;
  39455. private _postProcessScaleFactor;
  39456. private _lensCenterOffset;
  39457. private _scaleIn;
  39458. private _scaleFactor;
  39459. private _lensCenter;
  39460. /**
  39461. * Initializes the VRDistortionCorrectionPostProcess
  39462. * @param name The name of the effect.
  39463. * @param camera The camera to apply the render pass to.
  39464. * @param isRightEye If this is for the right eye distortion
  39465. * @param vrMetrics All the required metrics for the VR camera
  39466. */
  39467. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39468. }
  39469. }
  39470. declare module BABYLON {
  39471. /**
  39472. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39473. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39474. */
  39475. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39476. /**
  39477. * Creates a new VRDeviceOrientationArcRotateCamera
  39478. * @param name defines camera name
  39479. * @param alpha defines the camera rotation along the logitudinal axis
  39480. * @param beta defines the camera rotation along the latitudinal axis
  39481. * @param radius defines the camera distance from its target
  39482. * @param target defines the camera target
  39483. * @param scene defines the scene the camera belongs to
  39484. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39485. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39486. */
  39487. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39488. /**
  39489. * Gets camera class name
  39490. * @returns VRDeviceOrientationArcRotateCamera
  39491. */
  39492. getClassName(): string;
  39493. }
  39494. }
  39495. declare module BABYLON {
  39496. /**
  39497. * Camera used to simulate VR rendering (based on FreeCamera)
  39498. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39499. */
  39500. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39501. /**
  39502. * Creates a new VRDeviceOrientationFreeCamera
  39503. * @param name defines camera name
  39504. * @param position defines the start position of the camera
  39505. * @param scene defines the scene the camera belongs to
  39506. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39507. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39508. */
  39509. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39510. /**
  39511. * Gets camera class name
  39512. * @returns VRDeviceOrientationFreeCamera
  39513. */
  39514. getClassName(): string;
  39515. }
  39516. }
  39517. declare module BABYLON {
  39518. /**
  39519. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39520. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39521. */
  39522. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39523. /**
  39524. * Creates a new VRDeviceOrientationGamepadCamera
  39525. * @param name defines camera name
  39526. * @param position defines the start position of the camera
  39527. * @param scene defines the scene the camera belongs to
  39528. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39529. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39530. */
  39531. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39532. /**
  39533. * Gets camera class name
  39534. * @returns VRDeviceOrientationGamepadCamera
  39535. */
  39536. getClassName(): string;
  39537. }
  39538. }
  39539. declare module BABYLON {
  39540. /**
  39541. * Base class of materials working in push mode in babylon JS
  39542. * @hidden
  39543. */
  39544. export class PushMaterial extends Material {
  39545. protected _activeEffect: Effect;
  39546. protected _normalMatrix: Matrix;
  39547. /**
  39548. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39549. * This means that the material can keep using a previous shader while a new one is being compiled.
  39550. * This is mostly used when shader parallel compilation is supported (true by default)
  39551. */
  39552. allowShaderHotSwapping: boolean;
  39553. constructor(name: string, scene: Scene);
  39554. getEffect(): Effect;
  39555. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39556. /**
  39557. * Binds the given world matrix to the active effect
  39558. *
  39559. * @param world the matrix to bind
  39560. */
  39561. bindOnlyWorldMatrix(world: Matrix): void;
  39562. /**
  39563. * Binds the given normal matrix to the active effect
  39564. *
  39565. * @param normalMatrix the matrix to bind
  39566. */
  39567. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39568. bind(world: Matrix, mesh?: Mesh): void;
  39569. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39570. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39571. }
  39572. }
  39573. declare module BABYLON {
  39574. /**
  39575. * This groups all the flags used to control the materials channel.
  39576. */
  39577. export class MaterialFlags {
  39578. private static _DiffuseTextureEnabled;
  39579. /**
  39580. * Are diffuse textures enabled in the application.
  39581. */
  39582. static DiffuseTextureEnabled: boolean;
  39583. private static _AmbientTextureEnabled;
  39584. /**
  39585. * Are ambient textures enabled in the application.
  39586. */
  39587. static AmbientTextureEnabled: boolean;
  39588. private static _OpacityTextureEnabled;
  39589. /**
  39590. * Are opacity textures enabled in the application.
  39591. */
  39592. static OpacityTextureEnabled: boolean;
  39593. private static _ReflectionTextureEnabled;
  39594. /**
  39595. * Are reflection textures enabled in the application.
  39596. */
  39597. static ReflectionTextureEnabled: boolean;
  39598. private static _EmissiveTextureEnabled;
  39599. /**
  39600. * Are emissive textures enabled in the application.
  39601. */
  39602. static EmissiveTextureEnabled: boolean;
  39603. private static _SpecularTextureEnabled;
  39604. /**
  39605. * Are specular textures enabled in the application.
  39606. */
  39607. static SpecularTextureEnabled: boolean;
  39608. private static _BumpTextureEnabled;
  39609. /**
  39610. * Are bump textures enabled in the application.
  39611. */
  39612. static BumpTextureEnabled: boolean;
  39613. private static _LightmapTextureEnabled;
  39614. /**
  39615. * Are lightmap textures enabled in the application.
  39616. */
  39617. static LightmapTextureEnabled: boolean;
  39618. private static _RefractionTextureEnabled;
  39619. /**
  39620. * Are refraction textures enabled in the application.
  39621. */
  39622. static RefractionTextureEnabled: boolean;
  39623. private static _ColorGradingTextureEnabled;
  39624. /**
  39625. * Are color grading textures enabled in the application.
  39626. */
  39627. static ColorGradingTextureEnabled: boolean;
  39628. private static _FresnelEnabled;
  39629. /**
  39630. * Are fresnels enabled in the application.
  39631. */
  39632. static FresnelEnabled: boolean;
  39633. private static _ClearCoatTextureEnabled;
  39634. /**
  39635. * Are clear coat textures enabled in the application.
  39636. */
  39637. static ClearCoatTextureEnabled: boolean;
  39638. private static _ClearCoatBumpTextureEnabled;
  39639. /**
  39640. * Are clear coat bump textures enabled in the application.
  39641. */
  39642. static ClearCoatBumpTextureEnabled: boolean;
  39643. private static _ClearCoatTintTextureEnabled;
  39644. /**
  39645. * Are clear coat tint textures enabled in the application.
  39646. */
  39647. static ClearCoatTintTextureEnabled: boolean;
  39648. private static _SheenTextureEnabled;
  39649. /**
  39650. * Are sheen textures enabled in the application.
  39651. */
  39652. static SheenTextureEnabled: boolean;
  39653. private static _AnisotropicTextureEnabled;
  39654. /**
  39655. * Are anisotropic textures enabled in the application.
  39656. */
  39657. static AnisotropicTextureEnabled: boolean;
  39658. private static _ThicknessTextureEnabled;
  39659. /**
  39660. * Are thickness textures enabled in the application.
  39661. */
  39662. static ThicknessTextureEnabled: boolean;
  39663. }
  39664. }
  39665. declare module BABYLON {
  39666. /** @hidden */
  39667. export var defaultFragmentDeclaration: {
  39668. name: string;
  39669. shader: string;
  39670. };
  39671. }
  39672. declare module BABYLON {
  39673. /** @hidden */
  39674. export var defaultUboDeclaration: {
  39675. name: string;
  39676. shader: string;
  39677. };
  39678. }
  39679. declare module BABYLON {
  39680. /** @hidden */
  39681. export var lightFragmentDeclaration: {
  39682. name: string;
  39683. shader: string;
  39684. };
  39685. }
  39686. declare module BABYLON {
  39687. /** @hidden */
  39688. export var lightUboDeclaration: {
  39689. name: string;
  39690. shader: string;
  39691. };
  39692. }
  39693. declare module BABYLON {
  39694. /** @hidden */
  39695. export var lightsFragmentFunctions: {
  39696. name: string;
  39697. shader: string;
  39698. };
  39699. }
  39700. declare module BABYLON {
  39701. /** @hidden */
  39702. export var shadowsFragmentFunctions: {
  39703. name: string;
  39704. shader: string;
  39705. };
  39706. }
  39707. declare module BABYLON {
  39708. /** @hidden */
  39709. export var fresnelFunction: {
  39710. name: string;
  39711. shader: string;
  39712. };
  39713. }
  39714. declare module BABYLON {
  39715. /** @hidden */
  39716. export var reflectionFunction: {
  39717. name: string;
  39718. shader: string;
  39719. };
  39720. }
  39721. declare module BABYLON {
  39722. /** @hidden */
  39723. export var bumpFragmentFunctions: {
  39724. name: string;
  39725. shader: string;
  39726. };
  39727. }
  39728. declare module BABYLON {
  39729. /** @hidden */
  39730. export var logDepthDeclaration: {
  39731. name: string;
  39732. shader: string;
  39733. };
  39734. }
  39735. declare module BABYLON {
  39736. /** @hidden */
  39737. export var bumpFragment: {
  39738. name: string;
  39739. shader: string;
  39740. };
  39741. }
  39742. declare module BABYLON {
  39743. /** @hidden */
  39744. export var depthPrePass: {
  39745. name: string;
  39746. shader: string;
  39747. };
  39748. }
  39749. declare module BABYLON {
  39750. /** @hidden */
  39751. export var lightFragment: {
  39752. name: string;
  39753. shader: string;
  39754. };
  39755. }
  39756. declare module BABYLON {
  39757. /** @hidden */
  39758. export var logDepthFragment: {
  39759. name: string;
  39760. shader: string;
  39761. };
  39762. }
  39763. declare module BABYLON {
  39764. /** @hidden */
  39765. export var defaultPixelShader: {
  39766. name: string;
  39767. shader: string;
  39768. };
  39769. }
  39770. declare module BABYLON {
  39771. /** @hidden */
  39772. export var defaultVertexDeclaration: {
  39773. name: string;
  39774. shader: string;
  39775. };
  39776. }
  39777. declare module BABYLON {
  39778. /** @hidden */
  39779. export var bumpVertexDeclaration: {
  39780. name: string;
  39781. shader: string;
  39782. };
  39783. }
  39784. declare module BABYLON {
  39785. /** @hidden */
  39786. export var bumpVertex: {
  39787. name: string;
  39788. shader: string;
  39789. };
  39790. }
  39791. declare module BABYLON {
  39792. /** @hidden */
  39793. export var fogVertex: {
  39794. name: string;
  39795. shader: string;
  39796. };
  39797. }
  39798. declare module BABYLON {
  39799. /** @hidden */
  39800. export var shadowsVertex: {
  39801. name: string;
  39802. shader: string;
  39803. };
  39804. }
  39805. declare module BABYLON {
  39806. /** @hidden */
  39807. export var pointCloudVertex: {
  39808. name: string;
  39809. shader: string;
  39810. };
  39811. }
  39812. declare module BABYLON {
  39813. /** @hidden */
  39814. export var logDepthVertex: {
  39815. name: string;
  39816. shader: string;
  39817. };
  39818. }
  39819. declare module BABYLON {
  39820. /** @hidden */
  39821. export var defaultVertexShader: {
  39822. name: string;
  39823. shader: string;
  39824. };
  39825. }
  39826. declare module BABYLON {
  39827. /** @hidden */
  39828. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39829. MAINUV1: boolean;
  39830. MAINUV2: boolean;
  39831. DIFFUSE: boolean;
  39832. DIFFUSEDIRECTUV: number;
  39833. AMBIENT: boolean;
  39834. AMBIENTDIRECTUV: number;
  39835. OPACITY: boolean;
  39836. OPACITYDIRECTUV: number;
  39837. OPACITYRGB: boolean;
  39838. REFLECTION: boolean;
  39839. EMISSIVE: boolean;
  39840. EMISSIVEDIRECTUV: number;
  39841. SPECULAR: boolean;
  39842. SPECULARDIRECTUV: number;
  39843. BUMP: boolean;
  39844. BUMPDIRECTUV: number;
  39845. PARALLAX: boolean;
  39846. PARALLAXOCCLUSION: boolean;
  39847. SPECULAROVERALPHA: boolean;
  39848. CLIPPLANE: boolean;
  39849. CLIPPLANE2: boolean;
  39850. CLIPPLANE3: boolean;
  39851. CLIPPLANE4: boolean;
  39852. ALPHATEST: boolean;
  39853. DEPTHPREPASS: boolean;
  39854. ALPHAFROMDIFFUSE: boolean;
  39855. POINTSIZE: boolean;
  39856. FOG: boolean;
  39857. SPECULARTERM: boolean;
  39858. DIFFUSEFRESNEL: boolean;
  39859. OPACITYFRESNEL: boolean;
  39860. REFLECTIONFRESNEL: boolean;
  39861. REFRACTIONFRESNEL: boolean;
  39862. EMISSIVEFRESNEL: boolean;
  39863. FRESNEL: boolean;
  39864. NORMAL: boolean;
  39865. UV1: boolean;
  39866. UV2: boolean;
  39867. VERTEXCOLOR: boolean;
  39868. VERTEXALPHA: boolean;
  39869. NUM_BONE_INFLUENCERS: number;
  39870. BonesPerMesh: number;
  39871. BONETEXTURE: boolean;
  39872. INSTANCES: boolean;
  39873. GLOSSINESS: boolean;
  39874. ROUGHNESS: boolean;
  39875. EMISSIVEASILLUMINATION: boolean;
  39876. LINKEMISSIVEWITHDIFFUSE: boolean;
  39877. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39878. LIGHTMAP: boolean;
  39879. LIGHTMAPDIRECTUV: number;
  39880. OBJECTSPACE_NORMALMAP: boolean;
  39881. USELIGHTMAPASSHADOWMAP: boolean;
  39882. REFLECTIONMAP_3D: boolean;
  39883. REFLECTIONMAP_SPHERICAL: boolean;
  39884. REFLECTIONMAP_PLANAR: boolean;
  39885. REFLECTIONMAP_CUBIC: boolean;
  39886. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39887. REFLECTIONMAP_PROJECTION: boolean;
  39888. REFLECTIONMAP_SKYBOX: boolean;
  39889. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39890. REFLECTIONMAP_EXPLICIT: boolean;
  39891. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39892. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39893. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39894. INVERTCUBICMAP: boolean;
  39895. LOGARITHMICDEPTH: boolean;
  39896. REFRACTION: boolean;
  39897. REFRACTIONMAP_3D: boolean;
  39898. REFLECTIONOVERALPHA: boolean;
  39899. TWOSIDEDLIGHTING: boolean;
  39900. SHADOWFLOAT: boolean;
  39901. MORPHTARGETS: boolean;
  39902. MORPHTARGETS_NORMAL: boolean;
  39903. MORPHTARGETS_TANGENT: boolean;
  39904. MORPHTARGETS_UV: boolean;
  39905. NUM_MORPH_INFLUENCERS: number;
  39906. NONUNIFORMSCALING: boolean;
  39907. PREMULTIPLYALPHA: boolean;
  39908. IMAGEPROCESSING: boolean;
  39909. VIGNETTE: boolean;
  39910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39911. VIGNETTEBLENDMODEOPAQUE: boolean;
  39912. TONEMAPPING: boolean;
  39913. TONEMAPPING_ACES: boolean;
  39914. CONTRAST: boolean;
  39915. COLORCURVES: boolean;
  39916. COLORGRADING: boolean;
  39917. COLORGRADING3D: boolean;
  39918. SAMPLER3DGREENDEPTH: boolean;
  39919. SAMPLER3DBGRMAP: boolean;
  39920. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39921. MULTIVIEW: boolean;
  39922. /**
  39923. * If the reflection texture on this material is in linear color space
  39924. * @hidden
  39925. */
  39926. IS_REFLECTION_LINEAR: boolean;
  39927. /**
  39928. * If the refraction texture on this material is in linear color space
  39929. * @hidden
  39930. */
  39931. IS_REFRACTION_LINEAR: boolean;
  39932. EXPOSURE: boolean;
  39933. constructor();
  39934. setReflectionMode(modeToEnable: string): void;
  39935. }
  39936. /**
  39937. * This is the default material used in Babylon. It is the best trade off between quality
  39938. * and performances.
  39939. * @see http://doc.babylonjs.com/babylon101/materials
  39940. */
  39941. export class StandardMaterial extends PushMaterial {
  39942. private _diffuseTexture;
  39943. /**
  39944. * The basic texture of the material as viewed under a light.
  39945. */
  39946. diffuseTexture: Nullable<BaseTexture>;
  39947. private _ambientTexture;
  39948. /**
  39949. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39950. */
  39951. ambientTexture: Nullable<BaseTexture>;
  39952. private _opacityTexture;
  39953. /**
  39954. * Define the transparency of the material from a texture.
  39955. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39956. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39957. */
  39958. opacityTexture: Nullable<BaseTexture>;
  39959. private _reflectionTexture;
  39960. /**
  39961. * Define the texture used to display the reflection.
  39962. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39963. */
  39964. reflectionTexture: Nullable<BaseTexture>;
  39965. private _emissiveTexture;
  39966. /**
  39967. * Define texture of the material as if self lit.
  39968. * This will be mixed in the final result even in the absence of light.
  39969. */
  39970. emissiveTexture: Nullable<BaseTexture>;
  39971. private _specularTexture;
  39972. /**
  39973. * Define how the color and intensity of the highlight given by the light in the material.
  39974. */
  39975. specularTexture: Nullable<BaseTexture>;
  39976. private _bumpTexture;
  39977. /**
  39978. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39979. * 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.
  39980. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39981. */
  39982. bumpTexture: Nullable<BaseTexture>;
  39983. private _lightmapTexture;
  39984. /**
  39985. * Complex lighting can be computationally expensive to compute at runtime.
  39986. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39987. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39988. */
  39989. lightmapTexture: Nullable<BaseTexture>;
  39990. private _refractionTexture;
  39991. /**
  39992. * Define the texture used to display the refraction.
  39993. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39994. */
  39995. refractionTexture: Nullable<BaseTexture>;
  39996. /**
  39997. * The color of the material lit by the environmental background lighting.
  39998. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39999. */
  40000. ambientColor: Color3;
  40001. /**
  40002. * The basic color of the material as viewed under a light.
  40003. */
  40004. diffuseColor: Color3;
  40005. /**
  40006. * Define how the color and intensity of the highlight given by the light in the material.
  40007. */
  40008. specularColor: Color3;
  40009. /**
  40010. * Define the color of the material as if self lit.
  40011. * This will be mixed in the final result even in the absence of light.
  40012. */
  40013. emissiveColor: Color3;
  40014. /**
  40015. * Defines how sharp are the highlights in the material.
  40016. * The bigger the value the sharper giving a more glossy feeling to the result.
  40017. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40018. */
  40019. specularPower: number;
  40020. private _useAlphaFromDiffuseTexture;
  40021. /**
  40022. * Does the transparency come from the diffuse texture alpha channel.
  40023. */
  40024. useAlphaFromDiffuseTexture: boolean;
  40025. private _useEmissiveAsIllumination;
  40026. /**
  40027. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40028. */
  40029. useEmissiveAsIllumination: boolean;
  40030. private _linkEmissiveWithDiffuse;
  40031. /**
  40032. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40033. * the emissive level when the final color is close to one.
  40034. */
  40035. linkEmissiveWithDiffuse: boolean;
  40036. private _useSpecularOverAlpha;
  40037. /**
  40038. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40039. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40040. */
  40041. useSpecularOverAlpha: boolean;
  40042. private _useReflectionOverAlpha;
  40043. /**
  40044. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40045. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40046. */
  40047. useReflectionOverAlpha: boolean;
  40048. private _disableLighting;
  40049. /**
  40050. * Does lights from the scene impacts this material.
  40051. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40052. */
  40053. disableLighting: boolean;
  40054. private _useObjectSpaceNormalMap;
  40055. /**
  40056. * Allows using an object space normal map (instead of tangent space).
  40057. */
  40058. useObjectSpaceNormalMap: boolean;
  40059. private _useParallax;
  40060. /**
  40061. * Is parallax enabled or not.
  40062. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40063. */
  40064. useParallax: boolean;
  40065. private _useParallaxOcclusion;
  40066. /**
  40067. * Is parallax occlusion enabled or not.
  40068. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40069. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40070. */
  40071. useParallaxOcclusion: boolean;
  40072. /**
  40073. * 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.
  40074. */
  40075. parallaxScaleBias: number;
  40076. private _roughness;
  40077. /**
  40078. * Helps to define how blurry the reflections should appears in the material.
  40079. */
  40080. roughness: number;
  40081. /**
  40082. * In case of refraction, define the value of the index of refraction.
  40083. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40084. */
  40085. indexOfRefraction: number;
  40086. /**
  40087. * Invert the refraction texture alongside the y axis.
  40088. * It can be useful with procedural textures or probe for instance.
  40089. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40090. */
  40091. invertRefractionY: boolean;
  40092. /**
  40093. * Defines the alpha limits in alpha test mode.
  40094. */
  40095. alphaCutOff: number;
  40096. private _useLightmapAsShadowmap;
  40097. /**
  40098. * In case of light mapping, define whether the map contains light or shadow informations.
  40099. */
  40100. useLightmapAsShadowmap: boolean;
  40101. private _diffuseFresnelParameters;
  40102. /**
  40103. * Define the diffuse fresnel parameters of the material.
  40104. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40105. */
  40106. diffuseFresnelParameters: FresnelParameters;
  40107. private _opacityFresnelParameters;
  40108. /**
  40109. * Define the opacity fresnel parameters of the material.
  40110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40111. */
  40112. opacityFresnelParameters: FresnelParameters;
  40113. private _reflectionFresnelParameters;
  40114. /**
  40115. * Define the reflection fresnel parameters of the material.
  40116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40117. */
  40118. reflectionFresnelParameters: FresnelParameters;
  40119. private _refractionFresnelParameters;
  40120. /**
  40121. * Define the refraction fresnel parameters of the material.
  40122. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40123. */
  40124. refractionFresnelParameters: FresnelParameters;
  40125. private _emissiveFresnelParameters;
  40126. /**
  40127. * Define the emissive fresnel parameters of the material.
  40128. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40129. */
  40130. emissiveFresnelParameters: FresnelParameters;
  40131. private _useReflectionFresnelFromSpecular;
  40132. /**
  40133. * If true automatically deducts the fresnels values from the material specularity.
  40134. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40135. */
  40136. useReflectionFresnelFromSpecular: boolean;
  40137. private _useGlossinessFromSpecularMapAlpha;
  40138. /**
  40139. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40140. */
  40141. useGlossinessFromSpecularMapAlpha: boolean;
  40142. private _maxSimultaneousLights;
  40143. /**
  40144. * Defines the maximum number of lights that can be used in the material
  40145. */
  40146. maxSimultaneousLights: number;
  40147. private _invertNormalMapX;
  40148. /**
  40149. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40150. */
  40151. invertNormalMapX: boolean;
  40152. private _invertNormalMapY;
  40153. /**
  40154. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40155. */
  40156. invertNormalMapY: boolean;
  40157. private _twoSidedLighting;
  40158. /**
  40159. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40160. */
  40161. twoSidedLighting: boolean;
  40162. /**
  40163. * Default configuration related to image processing available in the standard Material.
  40164. */
  40165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40166. /**
  40167. * Gets the image processing configuration used either in this material.
  40168. */
  40169. /**
  40170. * Sets the Default image processing configuration used either in the this material.
  40171. *
  40172. * If sets to null, the scene one is in use.
  40173. */
  40174. imageProcessingConfiguration: ImageProcessingConfiguration;
  40175. /**
  40176. * Keep track of the image processing observer to allow dispose and replace.
  40177. */
  40178. private _imageProcessingObserver;
  40179. /**
  40180. * Attaches a new image processing configuration to the Standard Material.
  40181. * @param configuration
  40182. */
  40183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40184. /**
  40185. * Gets wether the color curves effect is enabled.
  40186. */
  40187. /**
  40188. * Sets wether the color curves effect is enabled.
  40189. */
  40190. cameraColorCurvesEnabled: boolean;
  40191. /**
  40192. * Gets wether the color grading effect is enabled.
  40193. */
  40194. /**
  40195. * Gets wether the color grading effect is enabled.
  40196. */
  40197. cameraColorGradingEnabled: boolean;
  40198. /**
  40199. * Gets wether tonemapping is enabled or not.
  40200. */
  40201. /**
  40202. * Sets wether tonemapping is enabled or not
  40203. */
  40204. cameraToneMappingEnabled: boolean;
  40205. /**
  40206. * The camera exposure used on this material.
  40207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40208. * This corresponds to a photographic exposure.
  40209. */
  40210. /**
  40211. * The camera exposure used on this material.
  40212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40213. * This corresponds to a photographic exposure.
  40214. */
  40215. cameraExposure: number;
  40216. /**
  40217. * Gets The camera contrast used on this material.
  40218. */
  40219. /**
  40220. * Sets The camera contrast used on this material.
  40221. */
  40222. cameraContrast: number;
  40223. /**
  40224. * Gets the Color Grading 2D Lookup Texture.
  40225. */
  40226. /**
  40227. * Sets the Color Grading 2D Lookup Texture.
  40228. */
  40229. cameraColorGradingTexture: Nullable<BaseTexture>;
  40230. /**
  40231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40233. * 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;
  40234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40235. */
  40236. /**
  40237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40239. * 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;
  40240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40241. */
  40242. cameraColorCurves: Nullable<ColorCurves>;
  40243. /**
  40244. * Custom callback helping to override the default shader used in the material.
  40245. */
  40246. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40247. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40248. protected _worldViewProjectionMatrix: Matrix;
  40249. protected _globalAmbientColor: Color3;
  40250. protected _useLogarithmicDepth: boolean;
  40251. protected _rebuildInParallel: boolean;
  40252. /**
  40253. * Instantiates a new standard material.
  40254. * This is the default material used in Babylon. It is the best trade off between quality
  40255. * and performances.
  40256. * @see http://doc.babylonjs.com/babylon101/materials
  40257. * @param name Define the name of the material in the scene
  40258. * @param scene Define the scene the material belong to
  40259. */
  40260. constructor(name: string, scene: Scene);
  40261. /**
  40262. * Gets a boolean indicating that current material needs to register RTT
  40263. */
  40264. readonly hasRenderTargetTextures: boolean;
  40265. /**
  40266. * Gets the current class name of the material e.g. "StandardMaterial"
  40267. * Mainly use in serialization.
  40268. * @returns the class name
  40269. */
  40270. getClassName(): string;
  40271. /**
  40272. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40273. * You can try switching to logarithmic depth.
  40274. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40275. */
  40276. useLogarithmicDepth: boolean;
  40277. /**
  40278. * Specifies if the material will require alpha blending
  40279. * @returns a boolean specifying if alpha blending is needed
  40280. */
  40281. needAlphaBlending(): boolean;
  40282. /**
  40283. * Specifies if this material should be rendered in alpha test mode
  40284. * @returns a boolean specifying if an alpha test is needed.
  40285. */
  40286. needAlphaTesting(): boolean;
  40287. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40288. /**
  40289. * Get the texture used for alpha test purpose.
  40290. * @returns the diffuse texture in case of the standard material.
  40291. */
  40292. getAlphaTestTexture(): Nullable<BaseTexture>;
  40293. /**
  40294. * Get if the submesh is ready to be used and all its information available.
  40295. * Child classes can use it to update shaders
  40296. * @param mesh defines the mesh to check
  40297. * @param subMesh defines which submesh to check
  40298. * @param useInstances specifies that instances should be used
  40299. * @returns a boolean indicating that the submesh is ready or not
  40300. */
  40301. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40302. /**
  40303. * Builds the material UBO layouts.
  40304. * Used internally during the effect preparation.
  40305. */
  40306. buildUniformLayout(): void;
  40307. /**
  40308. * Unbinds the material from the mesh
  40309. */
  40310. unbind(): void;
  40311. /**
  40312. * Binds the submesh to this material by preparing the effect and shader to draw
  40313. * @param world defines the world transformation matrix
  40314. * @param mesh defines the mesh containing the submesh
  40315. * @param subMesh defines the submesh to bind the material to
  40316. */
  40317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40318. /**
  40319. * Get the list of animatables in the material.
  40320. * @returns the list of animatables object used in the material
  40321. */
  40322. getAnimatables(): IAnimatable[];
  40323. /**
  40324. * Gets the active textures from the material
  40325. * @returns an array of textures
  40326. */
  40327. getActiveTextures(): BaseTexture[];
  40328. /**
  40329. * Specifies if the material uses a texture
  40330. * @param texture defines the texture to check against the material
  40331. * @returns a boolean specifying if the material uses the texture
  40332. */
  40333. hasTexture(texture: BaseTexture): boolean;
  40334. /**
  40335. * Disposes the material
  40336. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40337. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40338. */
  40339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40340. /**
  40341. * Makes a duplicate of the material, and gives it a new name
  40342. * @param name defines the new name for the duplicated material
  40343. * @returns the cloned material
  40344. */
  40345. clone(name: string): StandardMaterial;
  40346. /**
  40347. * Serializes this material in a JSON representation
  40348. * @returns the serialized material object
  40349. */
  40350. serialize(): any;
  40351. /**
  40352. * Creates a standard material from parsed material data
  40353. * @param source defines the JSON representation of the material
  40354. * @param scene defines the hosting scene
  40355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40356. * @returns a new standard material
  40357. */
  40358. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40359. /**
  40360. * Are diffuse textures enabled in the application.
  40361. */
  40362. static DiffuseTextureEnabled: boolean;
  40363. /**
  40364. * Are ambient textures enabled in the application.
  40365. */
  40366. static AmbientTextureEnabled: boolean;
  40367. /**
  40368. * Are opacity textures enabled in the application.
  40369. */
  40370. static OpacityTextureEnabled: boolean;
  40371. /**
  40372. * Are reflection textures enabled in the application.
  40373. */
  40374. static ReflectionTextureEnabled: boolean;
  40375. /**
  40376. * Are emissive textures enabled in the application.
  40377. */
  40378. static EmissiveTextureEnabled: boolean;
  40379. /**
  40380. * Are specular textures enabled in the application.
  40381. */
  40382. static SpecularTextureEnabled: boolean;
  40383. /**
  40384. * Are bump textures enabled in the application.
  40385. */
  40386. static BumpTextureEnabled: boolean;
  40387. /**
  40388. * Are lightmap textures enabled in the application.
  40389. */
  40390. static LightmapTextureEnabled: boolean;
  40391. /**
  40392. * Are refraction textures enabled in the application.
  40393. */
  40394. static RefractionTextureEnabled: boolean;
  40395. /**
  40396. * Are color grading textures enabled in the application.
  40397. */
  40398. static ColorGradingTextureEnabled: boolean;
  40399. /**
  40400. * Are fresnels enabled in the application.
  40401. */
  40402. static FresnelEnabled: boolean;
  40403. }
  40404. }
  40405. declare module BABYLON {
  40406. /**
  40407. * A class extending Texture allowing drawing on a texture
  40408. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40409. */
  40410. export class DynamicTexture extends Texture {
  40411. private _generateMipMaps;
  40412. private _canvas;
  40413. private _context;
  40414. private _engine;
  40415. /**
  40416. * Creates a DynamicTexture
  40417. * @param name defines the name of the texture
  40418. * @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
  40419. * @param scene defines the scene where you want the texture
  40420. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40421. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40422. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40423. */
  40424. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40425. /**
  40426. * Get the current class name of the texture useful for serialization or dynamic coding.
  40427. * @returns "DynamicTexture"
  40428. */
  40429. getClassName(): string;
  40430. /**
  40431. * Gets the current state of canRescale
  40432. */
  40433. readonly canRescale: boolean;
  40434. private _recreate;
  40435. /**
  40436. * Scales the texture
  40437. * @param ratio the scale factor to apply to both width and height
  40438. */
  40439. scale(ratio: number): void;
  40440. /**
  40441. * Resizes the texture
  40442. * @param width the new width
  40443. * @param height the new height
  40444. */
  40445. scaleTo(width: number, height: number): void;
  40446. /**
  40447. * Gets the context of the canvas used by the texture
  40448. * @returns the canvas context of the dynamic texture
  40449. */
  40450. getContext(): CanvasRenderingContext2D;
  40451. /**
  40452. * Clears the texture
  40453. */
  40454. clear(): void;
  40455. /**
  40456. * Updates the texture
  40457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40458. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40459. */
  40460. update(invertY?: boolean, premulAlpha?: boolean): void;
  40461. /**
  40462. * Draws text onto the texture
  40463. * @param text defines the text to be drawn
  40464. * @param x defines the placement of the text from the left
  40465. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40466. * @param font defines the font to be used with font-style, font-size, font-name
  40467. * @param color defines the color used for the text
  40468. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40469. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40470. * @param update defines whether texture is immediately update (default is true)
  40471. */
  40472. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40473. /**
  40474. * Clones the texture
  40475. * @returns the clone of the texture.
  40476. */
  40477. clone(): DynamicTexture;
  40478. /**
  40479. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40480. * @returns a serialized dynamic texture object
  40481. */
  40482. serialize(): any;
  40483. /** @hidden */
  40484. _rebuild(): void;
  40485. }
  40486. }
  40487. declare module BABYLON {
  40488. /** @hidden */
  40489. export var imageProcessingPixelShader: {
  40490. name: string;
  40491. shader: string;
  40492. };
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * ImageProcessingPostProcess
  40497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40498. */
  40499. export class ImageProcessingPostProcess extends PostProcess {
  40500. /**
  40501. * Default configuration related to image processing available in the PBR Material.
  40502. */
  40503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40504. /**
  40505. * Gets the image processing configuration used either in this material.
  40506. */
  40507. /**
  40508. * Sets the Default image processing configuration used either in the this material.
  40509. *
  40510. * If sets to null, the scene one is in use.
  40511. */
  40512. imageProcessingConfiguration: ImageProcessingConfiguration;
  40513. /**
  40514. * Keep track of the image processing observer to allow dispose and replace.
  40515. */
  40516. private _imageProcessingObserver;
  40517. /**
  40518. * Attaches a new image processing configuration to the PBR Material.
  40519. * @param configuration
  40520. */
  40521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40522. /**
  40523. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40524. */
  40525. /**
  40526. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40527. */
  40528. colorCurves: Nullable<ColorCurves>;
  40529. /**
  40530. * Gets wether the color curves effect is enabled.
  40531. */
  40532. /**
  40533. * Sets wether the color curves effect is enabled.
  40534. */
  40535. colorCurvesEnabled: boolean;
  40536. /**
  40537. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40538. */
  40539. /**
  40540. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40541. */
  40542. colorGradingTexture: Nullable<BaseTexture>;
  40543. /**
  40544. * Gets wether the color grading effect is enabled.
  40545. */
  40546. /**
  40547. * Gets wether the color grading effect is enabled.
  40548. */
  40549. colorGradingEnabled: boolean;
  40550. /**
  40551. * Gets exposure used in the effect.
  40552. */
  40553. /**
  40554. * Sets exposure used in the effect.
  40555. */
  40556. exposure: number;
  40557. /**
  40558. * Gets wether tonemapping is enabled or not.
  40559. */
  40560. /**
  40561. * Sets wether tonemapping is enabled or not
  40562. */
  40563. toneMappingEnabled: boolean;
  40564. /**
  40565. * Gets the type of tone mapping effect.
  40566. */
  40567. /**
  40568. * Sets the type of tone mapping effect.
  40569. */
  40570. toneMappingType: number;
  40571. /**
  40572. * Gets contrast used in the effect.
  40573. */
  40574. /**
  40575. * Sets contrast used in the effect.
  40576. */
  40577. contrast: number;
  40578. /**
  40579. * Gets Vignette stretch size.
  40580. */
  40581. /**
  40582. * Sets Vignette stretch size.
  40583. */
  40584. vignetteStretch: number;
  40585. /**
  40586. * Gets Vignette centre X Offset.
  40587. */
  40588. /**
  40589. * Sets Vignette centre X Offset.
  40590. */
  40591. vignetteCentreX: number;
  40592. /**
  40593. * Gets Vignette centre Y Offset.
  40594. */
  40595. /**
  40596. * Sets Vignette centre Y Offset.
  40597. */
  40598. vignetteCentreY: number;
  40599. /**
  40600. * Gets Vignette weight or intensity of the vignette effect.
  40601. */
  40602. /**
  40603. * Sets Vignette weight or intensity of the vignette effect.
  40604. */
  40605. vignetteWeight: number;
  40606. /**
  40607. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40608. * if vignetteEnabled is set to true.
  40609. */
  40610. /**
  40611. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40612. * if vignetteEnabled is set to true.
  40613. */
  40614. vignetteColor: Color4;
  40615. /**
  40616. * Gets Camera field of view used by the Vignette effect.
  40617. */
  40618. /**
  40619. * Sets Camera field of view used by the Vignette effect.
  40620. */
  40621. vignetteCameraFov: number;
  40622. /**
  40623. * Gets the vignette blend mode allowing different kind of effect.
  40624. */
  40625. /**
  40626. * Sets the vignette blend mode allowing different kind of effect.
  40627. */
  40628. vignetteBlendMode: number;
  40629. /**
  40630. * Gets wether the vignette effect is enabled.
  40631. */
  40632. /**
  40633. * Sets wether the vignette effect is enabled.
  40634. */
  40635. vignetteEnabled: boolean;
  40636. private _fromLinearSpace;
  40637. /**
  40638. * Gets wether the input of the processing is in Gamma or Linear Space.
  40639. */
  40640. /**
  40641. * Sets wether the input of the processing is in Gamma or Linear Space.
  40642. */
  40643. fromLinearSpace: boolean;
  40644. /**
  40645. * Defines cache preventing GC.
  40646. */
  40647. private _defines;
  40648. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40649. /**
  40650. * "ImageProcessingPostProcess"
  40651. * @returns "ImageProcessingPostProcess"
  40652. */
  40653. getClassName(): string;
  40654. protected _updateParameters(): void;
  40655. dispose(camera?: Camera): void;
  40656. }
  40657. }
  40658. declare module BABYLON {
  40659. /**
  40660. * Class containing static functions to help procedurally build meshes
  40661. */
  40662. export class GroundBuilder {
  40663. /**
  40664. * Creates a ground mesh
  40665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40668. * @param name defines the name of the mesh
  40669. * @param options defines the options used to create the mesh
  40670. * @param scene defines the hosting scene
  40671. * @returns the ground mesh
  40672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40673. */
  40674. static CreateGround(name: string, options: {
  40675. width?: number;
  40676. height?: number;
  40677. subdivisions?: number;
  40678. subdivisionsX?: number;
  40679. subdivisionsY?: number;
  40680. updatable?: boolean;
  40681. }, scene: any): Mesh;
  40682. /**
  40683. * Creates a tiled ground mesh
  40684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40686. * * 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
  40687. * * 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
  40688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40689. * @param name defines the name of the mesh
  40690. * @param options defines the options used to create the mesh
  40691. * @param scene defines the hosting scene
  40692. * @returns the tiled ground mesh
  40693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40694. */
  40695. static CreateTiledGround(name: string, options: {
  40696. xmin: number;
  40697. zmin: number;
  40698. xmax: number;
  40699. zmax: number;
  40700. subdivisions?: {
  40701. w: number;
  40702. h: number;
  40703. };
  40704. precision?: {
  40705. w: number;
  40706. h: number;
  40707. };
  40708. updatable?: boolean;
  40709. }, scene?: Nullable<Scene>): Mesh;
  40710. /**
  40711. * Creates a ground mesh from a height map
  40712. * * The parameter `url` sets the URL of the height map image resource.
  40713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40717. * * 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.
  40718. * * 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).
  40719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40721. * @param name defines the name of the mesh
  40722. * @param url defines the url to the height map
  40723. * @param options defines the options used to create the mesh
  40724. * @param scene defines the hosting scene
  40725. * @returns the ground mesh
  40726. * @see https://doc.babylonjs.com/babylon101/height_map
  40727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40728. */
  40729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40730. width?: number;
  40731. height?: number;
  40732. subdivisions?: number;
  40733. minHeight?: number;
  40734. maxHeight?: number;
  40735. colorFilter?: Color3;
  40736. alphaFilter?: number;
  40737. updatable?: boolean;
  40738. onReady?: (mesh: GroundMesh) => void;
  40739. }, scene?: Nullable<Scene>): GroundMesh;
  40740. }
  40741. }
  40742. declare module BABYLON {
  40743. /**
  40744. * Class containing static functions to help procedurally build meshes
  40745. */
  40746. export class TorusBuilder {
  40747. /**
  40748. * Creates a torus mesh
  40749. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40750. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40751. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40753. * * 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
  40754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40755. * @param name defines the name of the mesh
  40756. * @param options defines the options used to create the mesh
  40757. * @param scene defines the hosting scene
  40758. * @returns the torus mesh
  40759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40760. */
  40761. static CreateTorus(name: string, options: {
  40762. diameter?: number;
  40763. thickness?: number;
  40764. tessellation?: number;
  40765. updatable?: boolean;
  40766. sideOrientation?: number;
  40767. frontUVs?: Vector4;
  40768. backUVs?: Vector4;
  40769. }, scene: any): Mesh;
  40770. }
  40771. }
  40772. declare module BABYLON {
  40773. /**
  40774. * Class containing static functions to help procedurally build meshes
  40775. */
  40776. export class CylinderBuilder {
  40777. /**
  40778. * Creates a cylinder or a cone mesh
  40779. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40780. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40781. * * 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.
  40782. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40783. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40784. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40785. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40786. * * 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).
  40787. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40788. * * 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).
  40789. * * 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
  40790. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40791. * * 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
  40792. * * 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.
  40793. * * If `enclose` is false, a ring surface is one element.
  40794. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40795. * * 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
  40796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40797. * * 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
  40798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40799. * @param name defines the name of the mesh
  40800. * @param options defines the options used to create the mesh
  40801. * @param scene defines the hosting scene
  40802. * @returns the cylinder mesh
  40803. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40804. */
  40805. static CreateCylinder(name: string, options: {
  40806. height?: number;
  40807. diameterTop?: number;
  40808. diameterBottom?: number;
  40809. diameter?: number;
  40810. tessellation?: number;
  40811. subdivisions?: number;
  40812. arc?: number;
  40813. faceColors?: Color4[];
  40814. faceUV?: Vector4[];
  40815. updatable?: boolean;
  40816. hasRings?: boolean;
  40817. enclose?: boolean;
  40818. cap?: number;
  40819. sideOrientation?: number;
  40820. frontUVs?: Vector4;
  40821. backUVs?: Vector4;
  40822. }, scene: any): Mesh;
  40823. }
  40824. }
  40825. declare module BABYLON {
  40826. /**
  40827. * Options to modify the vr teleportation behavior.
  40828. */
  40829. export interface VRTeleportationOptions {
  40830. /**
  40831. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40832. */
  40833. floorMeshName?: string;
  40834. /**
  40835. * A list of meshes to be used as the teleportation floor. (default: empty)
  40836. */
  40837. floorMeshes?: Mesh[];
  40838. }
  40839. /**
  40840. * Options to modify the vr experience helper's behavior.
  40841. */
  40842. export interface VRExperienceHelperOptions extends WebVROptions {
  40843. /**
  40844. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40845. */
  40846. createDeviceOrientationCamera?: boolean;
  40847. /**
  40848. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40849. */
  40850. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40851. /**
  40852. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40853. */
  40854. laserToggle?: boolean;
  40855. /**
  40856. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40857. */
  40858. floorMeshes?: Mesh[];
  40859. /**
  40860. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40861. */
  40862. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40863. }
  40864. /**
  40865. * Event containing information after VR has been entered
  40866. */
  40867. export class OnAfterEnteringVRObservableEvent {
  40868. /**
  40869. * If entering vr was successful
  40870. */
  40871. success: boolean;
  40872. }
  40873. /**
  40874. * Helps to quickly add VR support to an existing scene.
  40875. * See http://doc.babylonjs.com/how_to/webvr_helper
  40876. */
  40877. export class VRExperienceHelper {
  40878. /** Options to modify the vr experience helper's behavior. */
  40879. webVROptions: VRExperienceHelperOptions;
  40880. private _scene;
  40881. private _position;
  40882. private _btnVR;
  40883. private _btnVRDisplayed;
  40884. private _webVRsupported;
  40885. private _webVRready;
  40886. private _webVRrequesting;
  40887. private _webVRpresenting;
  40888. private _hasEnteredVR;
  40889. private _fullscreenVRpresenting;
  40890. private _canvas;
  40891. private _webVRCamera;
  40892. private _vrDeviceOrientationCamera;
  40893. private _deviceOrientationCamera;
  40894. private _existingCamera;
  40895. private _onKeyDown;
  40896. private _onVrDisplayPresentChange;
  40897. private _onVRDisplayChanged;
  40898. private _onVRRequestPresentStart;
  40899. private _onVRRequestPresentComplete;
  40900. /**
  40901. * 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)
  40902. */
  40903. enableGazeEvenWhenNoPointerLock: boolean;
  40904. /**
  40905. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40906. */
  40907. exitVROnDoubleTap: boolean;
  40908. /**
  40909. * Observable raised right before entering VR.
  40910. */
  40911. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40912. /**
  40913. * Observable raised when entering VR has completed.
  40914. */
  40915. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40916. /**
  40917. * Observable raised when exiting VR.
  40918. */
  40919. onExitingVRObservable: Observable<VRExperienceHelper>;
  40920. /**
  40921. * Observable raised when controller mesh is loaded.
  40922. */
  40923. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40924. /** Return this.onEnteringVRObservable
  40925. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40926. */
  40927. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40928. /** Return this.onExitingVRObservable
  40929. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40930. */
  40931. readonly onExitingVR: Observable<VRExperienceHelper>;
  40932. /** Return this.onControllerMeshLoadedObservable
  40933. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40934. */
  40935. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40936. private _rayLength;
  40937. private _useCustomVRButton;
  40938. private _teleportationRequested;
  40939. private _teleportActive;
  40940. private _floorMeshName;
  40941. private _floorMeshesCollection;
  40942. private _rotationAllowed;
  40943. private _teleportBackwardsVector;
  40944. private _teleportationTarget;
  40945. private _isDefaultTeleportationTarget;
  40946. private _postProcessMove;
  40947. private _teleportationFillColor;
  40948. private _teleportationBorderColor;
  40949. private _rotationAngle;
  40950. private _haloCenter;
  40951. private _cameraGazer;
  40952. private _padSensibilityUp;
  40953. private _padSensibilityDown;
  40954. private _leftController;
  40955. private _rightController;
  40956. /**
  40957. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40958. */
  40959. onNewMeshSelected: Observable<AbstractMesh>;
  40960. /**
  40961. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40962. * This observable will provide the mesh and the controller used to select the mesh
  40963. */
  40964. onMeshSelectedWithController: Observable<{
  40965. mesh: AbstractMesh;
  40966. controller: WebVRController;
  40967. }>;
  40968. /**
  40969. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40970. */
  40971. onNewMeshPicked: Observable<PickingInfo>;
  40972. private _circleEase;
  40973. /**
  40974. * Observable raised before camera teleportation
  40975. */
  40976. onBeforeCameraTeleport: Observable<Vector3>;
  40977. /**
  40978. * Observable raised after camera teleportation
  40979. */
  40980. onAfterCameraTeleport: Observable<Vector3>;
  40981. /**
  40982. * Observable raised when current selected mesh gets unselected
  40983. */
  40984. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40985. private _raySelectionPredicate;
  40986. /**
  40987. * To be optionaly changed by user to define custom ray selection
  40988. */
  40989. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40990. /**
  40991. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40992. */
  40993. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40994. /**
  40995. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40996. */
  40997. teleportationEnabled: boolean;
  40998. private _defaultHeight;
  40999. private _teleportationInitialized;
  41000. private _interactionsEnabled;
  41001. private _interactionsRequested;
  41002. private _displayGaze;
  41003. private _displayLaserPointer;
  41004. /**
  41005. * The mesh used to display where the user is going to teleport.
  41006. */
  41007. /**
  41008. * Sets the mesh to be used to display where the user is going to teleport.
  41009. */
  41010. teleportationTarget: Mesh;
  41011. /**
  41012. * 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
  41013. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41014. * See http://doc.babylonjs.com/resources/baking_transformations
  41015. */
  41016. gazeTrackerMesh: Mesh;
  41017. /**
  41018. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41019. */
  41020. updateGazeTrackerScale: boolean;
  41021. /**
  41022. * If the gaze trackers color should be updated when selecting meshes
  41023. */
  41024. updateGazeTrackerColor: boolean;
  41025. /**
  41026. * The gaze tracking mesh corresponding to the left controller
  41027. */
  41028. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41029. /**
  41030. * The gaze tracking mesh corresponding to the right controller
  41031. */
  41032. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41033. /**
  41034. * If the ray of the gaze should be displayed.
  41035. */
  41036. /**
  41037. * Sets if the ray of the gaze should be displayed.
  41038. */
  41039. displayGaze: boolean;
  41040. /**
  41041. * If the ray of the LaserPointer should be displayed.
  41042. */
  41043. /**
  41044. * Sets if the ray of the LaserPointer should be displayed.
  41045. */
  41046. displayLaserPointer: boolean;
  41047. /**
  41048. * The deviceOrientationCamera used as the camera when not in VR.
  41049. */
  41050. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41051. /**
  41052. * Based on the current WebVR support, returns the current VR camera used.
  41053. */
  41054. readonly currentVRCamera: Nullable<Camera>;
  41055. /**
  41056. * The webVRCamera which is used when in VR.
  41057. */
  41058. readonly webVRCamera: WebVRFreeCamera;
  41059. /**
  41060. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41061. */
  41062. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41063. /**
  41064. * The html button that is used to trigger entering into VR.
  41065. */
  41066. readonly vrButton: Nullable<HTMLButtonElement>;
  41067. private readonly _teleportationRequestInitiated;
  41068. /**
  41069. * Defines wether or not Pointer lock should be requested when switching to
  41070. * full screen.
  41071. */
  41072. requestPointerLockOnFullScreen: boolean;
  41073. /**
  41074. * Instantiates a VRExperienceHelper.
  41075. * Helps to quickly add VR support to an existing scene.
  41076. * @param scene The scene the VRExperienceHelper belongs to.
  41077. * @param webVROptions Options to modify the vr experience helper's behavior.
  41078. */
  41079. constructor(scene: Scene,
  41080. /** Options to modify the vr experience helper's behavior. */
  41081. webVROptions?: VRExperienceHelperOptions);
  41082. private _onDefaultMeshLoaded;
  41083. private _onResize;
  41084. private _onFullscreenChange;
  41085. /**
  41086. * Gets a value indicating if we are currently in VR mode.
  41087. */
  41088. readonly isInVRMode: boolean;
  41089. private onVrDisplayPresentChange;
  41090. private onVRDisplayChanged;
  41091. private moveButtonToBottomRight;
  41092. private displayVRButton;
  41093. private updateButtonVisibility;
  41094. private _cachedAngularSensibility;
  41095. /**
  41096. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41097. * Otherwise, will use the fullscreen API.
  41098. */
  41099. enterVR(): void;
  41100. /**
  41101. * Attempt to exit VR, or fullscreen.
  41102. */
  41103. exitVR(): void;
  41104. /**
  41105. * The position of the vr experience helper.
  41106. */
  41107. /**
  41108. * Sets the position of the vr experience helper.
  41109. */
  41110. position: Vector3;
  41111. /**
  41112. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41113. */
  41114. enableInteractions(): void;
  41115. private readonly _noControllerIsActive;
  41116. private beforeRender;
  41117. private _isTeleportationFloor;
  41118. /**
  41119. * Adds a floor mesh to be used for teleportation.
  41120. * @param floorMesh the mesh to be used for teleportation.
  41121. */
  41122. addFloorMesh(floorMesh: Mesh): void;
  41123. /**
  41124. * Removes a floor mesh from being used for teleportation.
  41125. * @param floorMesh the mesh to be removed.
  41126. */
  41127. removeFloorMesh(floorMesh: Mesh): void;
  41128. /**
  41129. * Enables interactions and teleportation using the VR controllers and gaze.
  41130. * @param vrTeleportationOptions options to modify teleportation behavior.
  41131. */
  41132. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41133. private _onNewGamepadConnected;
  41134. private _tryEnableInteractionOnController;
  41135. private _onNewGamepadDisconnected;
  41136. private _enableInteractionOnController;
  41137. private _checkTeleportWithRay;
  41138. private _checkRotate;
  41139. private _checkTeleportBackwards;
  41140. private _enableTeleportationOnController;
  41141. private _createTeleportationCircles;
  41142. private _displayTeleportationTarget;
  41143. private _hideTeleportationTarget;
  41144. private _rotateCamera;
  41145. private _moveTeleportationSelectorTo;
  41146. private _workingVector;
  41147. private _workingQuaternion;
  41148. private _workingMatrix;
  41149. /**
  41150. * Teleports the users feet to the desired location
  41151. * @param location The location where the user's feet should be placed
  41152. */
  41153. teleportCamera(location: Vector3): void;
  41154. private _convertNormalToDirectionOfRay;
  41155. private _castRayAndSelectObject;
  41156. private _notifySelectedMeshUnselected;
  41157. /**
  41158. * Sets the color of the laser ray from the vr controllers.
  41159. * @param color new color for the ray.
  41160. */
  41161. changeLaserColor(color: Color3): void;
  41162. /**
  41163. * Sets the color of the ray from the vr headsets gaze.
  41164. * @param color new color for the ray.
  41165. */
  41166. changeGazeColor(color: Color3): void;
  41167. /**
  41168. * Exits VR and disposes of the vr experience helper
  41169. */
  41170. dispose(): void;
  41171. /**
  41172. * Gets the name of the VRExperienceHelper class
  41173. * @returns "VRExperienceHelper"
  41174. */
  41175. getClassName(): string;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Manages an XRSession to work with Babylon's engine
  41181. * @see https://doc.babylonjs.com/how_to/webxr
  41182. */
  41183. export class WebXRSessionManager implements IDisposable {
  41184. private scene;
  41185. /**
  41186. * Fires every time a new xrFrame arrives which can be used to update the camera
  41187. */
  41188. onXRFrameObservable: Observable<any>;
  41189. /**
  41190. * Fires when the xr session is ended either by the device or manually done
  41191. */
  41192. onXRSessionEnded: Observable<any>;
  41193. /**
  41194. * Underlying xr session
  41195. */
  41196. session: XRSession;
  41197. /**
  41198. * Type of reference space used when creating the session
  41199. */
  41200. referenceSpace: XRReferenceSpace;
  41201. /** @hidden */
  41202. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41203. /**
  41204. * Current XR frame
  41205. */
  41206. currentFrame: Nullable<XRFrame>;
  41207. private _xrNavigator;
  41208. private baseLayer;
  41209. /**
  41210. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41211. * @param scene The scene which the session should be created for
  41212. */
  41213. constructor(scene: Scene);
  41214. /**
  41215. * Initializes the manager
  41216. * After initialization enterXR can be called to start an XR session
  41217. * @returns Promise which resolves after it is initialized
  41218. */
  41219. initializeAsync(): Promise<void>;
  41220. /**
  41221. * Initializes an xr session
  41222. * @param xrSessionMode mode to initialize
  41223. * @returns a promise which will resolve once the session has been initialized
  41224. */
  41225. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41226. /**
  41227. * Sets the reference space on the xr session
  41228. * @param referenceSpace space to set
  41229. * @returns a promise that will resolve once the reference space has been set
  41230. */
  41231. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41232. /**
  41233. * Updates the render state of the session
  41234. * @param state state to set
  41235. * @returns a promise that resolves once the render state has been updated
  41236. */
  41237. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41238. /**
  41239. * Starts rendering to the xr layer
  41240. * @returns a promise that will resolve once rendering has started
  41241. */
  41242. startRenderingToXRAsync(): Promise<void>;
  41243. /**
  41244. * Stops the xrSession and restores the renderloop
  41245. * @returns Promise which resolves after it exits XR
  41246. */
  41247. exitXRAsync(): Promise<unknown>;
  41248. /**
  41249. * Checks if a session would be supported for the creation options specified
  41250. * @param sessionMode session mode to check if supported eg. immersive-vr
  41251. * @returns true if supported
  41252. */
  41253. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41254. /**
  41255. * @hidden
  41256. * Converts the render layer of xrSession to a render target
  41257. * @param session session to create render target for
  41258. * @param scene scene the new render target should be created for
  41259. */
  41260. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41261. /**
  41262. * Disposes of the session manager
  41263. */
  41264. dispose(): void;
  41265. }
  41266. }
  41267. declare module BABYLON {
  41268. /**
  41269. * WebXR Camera which holds the views for the xrSession
  41270. * @see https://doc.babylonjs.com/how_to/webxr
  41271. */
  41272. export class WebXRCamera extends FreeCamera {
  41273. private static _TmpMatrix;
  41274. /**
  41275. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41276. * @param name the name of the camera
  41277. * @param scene the scene to add the camera to
  41278. */
  41279. constructor(name: string, scene: Scene);
  41280. private _updateNumberOfRigCameras;
  41281. /** @hidden */
  41282. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41283. /**
  41284. * Updates the cameras position from the current pose information of the XR session
  41285. * @param xrSessionManager the session containing pose information
  41286. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41287. */
  41288. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41289. }
  41290. }
  41291. declare module BABYLON {
  41292. /**
  41293. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41294. */
  41295. export class WebXRManagedOutputCanvas implements IDisposable {
  41296. private helper;
  41297. private _canvas;
  41298. /**
  41299. * xrpresent context of the canvas which can be used to display/mirror xr content
  41300. */
  41301. canvasContext: WebGLRenderingContext;
  41302. /**
  41303. * xr layer for the canvas
  41304. */
  41305. xrLayer: Nullable<XRWebGLLayer>;
  41306. /**
  41307. * Initializes the xr layer for the session
  41308. * @param xrSession xr session
  41309. * @returns a promise that will resolve once the XR Layer has been created
  41310. */
  41311. initializeXRLayerAsync(xrSession: any): any;
  41312. /**
  41313. * Initializes the canvas to be added/removed upon entering/exiting xr
  41314. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41315. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41316. */
  41317. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41318. /**
  41319. * Disposes of the object
  41320. */
  41321. dispose(): void;
  41322. private _setManagedOutputCanvas;
  41323. private _addCanvas;
  41324. private _removeCanvas;
  41325. }
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * States of the webXR experience
  41330. */
  41331. export enum WebXRState {
  41332. /**
  41333. * Transitioning to being in XR mode
  41334. */
  41335. ENTERING_XR = 0,
  41336. /**
  41337. * Transitioning to non XR mode
  41338. */
  41339. EXITING_XR = 1,
  41340. /**
  41341. * In XR mode and presenting
  41342. */
  41343. IN_XR = 2,
  41344. /**
  41345. * Not entered XR mode
  41346. */
  41347. NOT_IN_XR = 3
  41348. }
  41349. /**
  41350. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41351. * @see https://doc.babylonjs.com/how_to/webxr
  41352. */
  41353. export class WebXRExperienceHelper implements IDisposable {
  41354. private scene;
  41355. /**
  41356. * 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
  41357. */
  41358. container: AbstractMesh;
  41359. /**
  41360. * Camera used to render xr content
  41361. */
  41362. camera: WebXRCamera;
  41363. /**
  41364. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41365. */
  41366. state: WebXRState;
  41367. private _setState;
  41368. private static _TmpVector;
  41369. /**
  41370. * Fires when the state of the experience helper has changed
  41371. */
  41372. onStateChangedObservable: Observable<WebXRState>;
  41373. /** Session manager used to keep track of xr session */
  41374. sessionManager: WebXRSessionManager;
  41375. private _nonVRCamera;
  41376. private _originalSceneAutoClear;
  41377. private _supported;
  41378. /**
  41379. * Creates the experience helper
  41380. * @param scene the scene to attach the experience helper to
  41381. * @returns a promise for the experience helper
  41382. */
  41383. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41384. /**
  41385. * Creates a WebXRExperienceHelper
  41386. * @param scene The scene the helper should be created in
  41387. */
  41388. private constructor();
  41389. /**
  41390. * Exits XR mode and returns the scene to its original state
  41391. * @returns promise that resolves after xr mode has exited
  41392. */
  41393. exitXRAsync(): Promise<unknown>;
  41394. /**
  41395. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41396. * @param sessionCreationOptions options for the XR session
  41397. * @param referenceSpaceType frame of reference of the XR session
  41398. * @param outputCanvas the output canvas that will be used to enter XR mode
  41399. * @returns promise that resolves after xr mode has entered
  41400. */
  41401. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41402. /**
  41403. * Updates the global position of the camera by moving the camera's container
  41404. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41405. * @param position The desired global position of the camera
  41406. */
  41407. setPositionOfCameraUsingContainer(position: Vector3): void;
  41408. /**
  41409. * Rotates the xr camera by rotating the camera's container around the camera's position
  41410. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41411. * @param rotation the desired quaternion rotation to apply to the camera
  41412. */
  41413. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41414. /**
  41415. * Disposes of the experience helper
  41416. */
  41417. dispose(): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * Button which can be used to enter a different mode of XR
  41423. */
  41424. export class WebXREnterExitUIButton {
  41425. /** button element */
  41426. element: HTMLElement;
  41427. /** XR initialization options for the button */
  41428. sessionMode: XRSessionMode;
  41429. /** Reference space type */
  41430. referenceSpaceType: XRReferenceSpaceType;
  41431. /**
  41432. * Creates a WebXREnterExitUIButton
  41433. * @param element button element
  41434. * @param sessionMode XR initialization session mode
  41435. * @param referenceSpaceType the type of reference space to be used
  41436. */
  41437. constructor(
  41438. /** button element */
  41439. element: HTMLElement,
  41440. /** XR initialization options for the button */
  41441. sessionMode: XRSessionMode,
  41442. /** Reference space type */
  41443. referenceSpaceType: XRReferenceSpaceType);
  41444. /**
  41445. * Overwritable function which can be used to update the button's visuals when the state changes
  41446. * @param activeButton the current active button in the UI
  41447. */
  41448. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41449. }
  41450. /**
  41451. * Options to create the webXR UI
  41452. */
  41453. export class WebXREnterExitUIOptions {
  41454. /**
  41455. * Context to enter xr with
  41456. */
  41457. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41458. /**
  41459. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41460. */
  41461. customButtons?: Array<WebXREnterExitUIButton>;
  41462. }
  41463. /**
  41464. * UI to allow the user to enter/exit XR mode
  41465. */
  41466. export class WebXREnterExitUI implements IDisposable {
  41467. private scene;
  41468. private _overlay;
  41469. private _buttons;
  41470. private _activeButton;
  41471. /**
  41472. * Fired every time the active button is changed.
  41473. *
  41474. * When xr is entered via a button that launches xr that button will be the callback parameter
  41475. *
  41476. * When exiting xr the callback parameter will be null)
  41477. */
  41478. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41479. /**
  41480. * Creates UI to allow the user to enter/exit XR mode
  41481. * @param scene the scene to add the ui to
  41482. * @param helper the xr experience helper to enter/exit xr with
  41483. * @param options options to configure the UI
  41484. * @returns the created ui
  41485. */
  41486. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41487. private constructor();
  41488. private _updateButtons;
  41489. /**
  41490. * Disposes of the object
  41491. */
  41492. dispose(): void;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Represents an XR input
  41498. */
  41499. export class WebXRController {
  41500. private scene;
  41501. /** The underlying input source for the controller */
  41502. inputSource: XRInputSource;
  41503. private parentContainer;
  41504. /**
  41505. * 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
  41506. */
  41507. grip?: AbstractMesh;
  41508. /**
  41509. * Pointer which can be used to select objects or attach a visible laser to
  41510. */
  41511. pointer: AbstractMesh;
  41512. /**
  41513. * Event that fires when the controller is removed/disposed
  41514. */
  41515. onDisposeObservable: Observable<{}>;
  41516. private _tmpMatrix;
  41517. private _tmpQuaternion;
  41518. private _tmpVector;
  41519. /**
  41520. * Creates the controller
  41521. * @see https://doc.babylonjs.com/how_to/webxr
  41522. * @param scene the scene which the controller should be associated to
  41523. * @param inputSource the underlying input source for the controller
  41524. * @param parentContainer parent that the controller meshes should be children of
  41525. */
  41526. constructor(scene: Scene,
  41527. /** The underlying input source for the controller */
  41528. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41529. /**
  41530. * Updates the controller pose based on the given XRFrame
  41531. * @param xrFrame xr frame to update the pose with
  41532. * @param referenceSpace reference space to use
  41533. */
  41534. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41535. /**
  41536. * Gets a world space ray coming from the controller
  41537. * @param result the resulting ray
  41538. */
  41539. getWorldPointerRayToRef(result: Ray): void;
  41540. /**
  41541. * Disposes of the object
  41542. */
  41543. dispose(): void;
  41544. }
  41545. }
  41546. declare module BABYLON {
  41547. /**
  41548. * XR input used to track XR inputs such as controllers/rays
  41549. */
  41550. export class WebXRInput implements IDisposable {
  41551. /**
  41552. * Base experience the input listens to
  41553. */
  41554. baseExperience: WebXRExperienceHelper;
  41555. /**
  41556. * XR controllers being tracked
  41557. */
  41558. controllers: Array<WebXRController>;
  41559. private _frameObserver;
  41560. private _stateObserver;
  41561. /**
  41562. * Event when a controller has been connected/added
  41563. */
  41564. onControllerAddedObservable: Observable<WebXRController>;
  41565. /**
  41566. * Event when a controller has been removed/disconnected
  41567. */
  41568. onControllerRemovedObservable: Observable<WebXRController>;
  41569. /**
  41570. * Initializes the WebXRInput
  41571. * @param baseExperience experience helper which the input should be created for
  41572. */
  41573. constructor(
  41574. /**
  41575. * Base experience the input listens to
  41576. */
  41577. baseExperience: WebXRExperienceHelper);
  41578. private _onInputSourcesChange;
  41579. private _addAndRemoveControllers;
  41580. /**
  41581. * Disposes of the object
  41582. */
  41583. dispose(): void;
  41584. }
  41585. }
  41586. declare module BABYLON {
  41587. /**
  41588. * Enables teleportation
  41589. */
  41590. export class WebXRControllerTeleportation {
  41591. private _teleportationFillColor;
  41592. private _teleportationBorderColor;
  41593. private _tmpRay;
  41594. private _tmpVector;
  41595. /**
  41596. * Creates a WebXRControllerTeleportation
  41597. * @param input input manager to add teleportation to
  41598. * @param floorMeshes floormeshes which can be teleported to
  41599. */
  41600. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41601. }
  41602. }
  41603. declare module BABYLON {
  41604. /**
  41605. * Handles pointer input automatically for the pointer of XR controllers
  41606. */
  41607. export class WebXRControllerPointerSelection {
  41608. private static _idCounter;
  41609. private _tmpRay;
  41610. /**
  41611. * Creates a WebXRControllerPointerSelection
  41612. * @param input input manager to setup pointer selection
  41613. */
  41614. constructor(input: WebXRInput);
  41615. private _convertNormalToDirectionOfRay;
  41616. private _updatePointerDistance;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * Class used to represent data loading progression
  41622. */
  41623. export class SceneLoaderProgressEvent {
  41624. /** defines if data length to load can be evaluated */
  41625. readonly lengthComputable: boolean;
  41626. /** defines the loaded data length */
  41627. readonly loaded: number;
  41628. /** defines the data length to load */
  41629. readonly total: number;
  41630. /**
  41631. * Create a new progress event
  41632. * @param lengthComputable defines if data length to load can be evaluated
  41633. * @param loaded defines the loaded data length
  41634. * @param total defines the data length to load
  41635. */
  41636. constructor(
  41637. /** defines if data length to load can be evaluated */
  41638. lengthComputable: boolean,
  41639. /** defines the loaded data length */
  41640. loaded: number,
  41641. /** defines the data length to load */
  41642. total: number);
  41643. /**
  41644. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41645. * @param event defines the source event
  41646. * @returns a new SceneLoaderProgressEvent
  41647. */
  41648. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41649. }
  41650. /**
  41651. * Interface used by SceneLoader plugins to define supported file extensions
  41652. */
  41653. export interface ISceneLoaderPluginExtensions {
  41654. /**
  41655. * Defines the list of supported extensions
  41656. */
  41657. [extension: string]: {
  41658. isBinary: boolean;
  41659. };
  41660. }
  41661. /**
  41662. * Interface used by SceneLoader plugin factory
  41663. */
  41664. export interface ISceneLoaderPluginFactory {
  41665. /**
  41666. * Defines the name of the factory
  41667. */
  41668. name: string;
  41669. /**
  41670. * Function called to create a new plugin
  41671. * @return the new plugin
  41672. */
  41673. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41674. /**
  41675. * Boolean indicating if the plugin can direct load specific data
  41676. */
  41677. canDirectLoad?: (data: string) => boolean;
  41678. }
  41679. /**
  41680. * Interface used to define a SceneLoader plugin
  41681. */
  41682. export interface ISceneLoaderPlugin {
  41683. /**
  41684. * The friendly name of this plugin.
  41685. */
  41686. name: string;
  41687. /**
  41688. * The file extensions supported by this plugin.
  41689. */
  41690. extensions: string | ISceneLoaderPluginExtensions;
  41691. /**
  41692. * Import meshes into a scene.
  41693. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41694. * @param scene The scene to import into
  41695. * @param data The data to import
  41696. * @param rootUrl The root url for scene and resources
  41697. * @param meshes The meshes array to import into
  41698. * @param particleSystems The particle systems array to import into
  41699. * @param skeletons The skeletons array to import into
  41700. * @param onError The callback when import fails
  41701. * @returns True if successful or false otherwise
  41702. */
  41703. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41704. /**
  41705. * Load into a scene.
  41706. * @param scene The scene to load into
  41707. * @param data The data to import
  41708. * @param rootUrl The root url for scene and resources
  41709. * @param onError The callback when import fails
  41710. * @returns true if successful or false otherwise
  41711. */
  41712. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41713. /**
  41714. * The callback that returns true if the data can be directly loaded.
  41715. */
  41716. canDirectLoad?: (data: string) => boolean;
  41717. /**
  41718. * The callback that allows custom handling of the root url based on the response url.
  41719. */
  41720. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41721. /**
  41722. * Load into an asset container.
  41723. * @param scene The scene to load into
  41724. * @param data The data to import
  41725. * @param rootUrl The root url for scene and resources
  41726. * @param onError The callback when import fails
  41727. * @returns The loaded asset container
  41728. */
  41729. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41730. }
  41731. /**
  41732. * Interface used to define an async SceneLoader plugin
  41733. */
  41734. export interface ISceneLoaderPluginAsync {
  41735. /**
  41736. * The friendly name of this plugin.
  41737. */
  41738. name: string;
  41739. /**
  41740. * The file extensions supported by this plugin.
  41741. */
  41742. extensions: string | ISceneLoaderPluginExtensions;
  41743. /**
  41744. * Import meshes into a scene.
  41745. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41746. * @param scene The scene to import into
  41747. * @param data The data to import
  41748. * @param rootUrl The root url for scene and resources
  41749. * @param onProgress The callback when the load progresses
  41750. * @param fileName Defines the name of the file to load
  41751. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41752. */
  41753. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41754. meshes: AbstractMesh[];
  41755. particleSystems: IParticleSystem[];
  41756. skeletons: Skeleton[];
  41757. animationGroups: AnimationGroup[];
  41758. }>;
  41759. /**
  41760. * Load into a scene.
  41761. * @param scene The scene to load into
  41762. * @param data The data to import
  41763. * @param rootUrl The root url for scene and resources
  41764. * @param onProgress The callback when the load progresses
  41765. * @param fileName Defines the name of the file to load
  41766. * @returns Nothing
  41767. */
  41768. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41769. /**
  41770. * The callback that returns true if the data can be directly loaded.
  41771. */
  41772. canDirectLoad?: (data: string) => boolean;
  41773. /**
  41774. * The callback that allows custom handling of the root url based on the response url.
  41775. */
  41776. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41777. /**
  41778. * Load into an asset container.
  41779. * @param scene The scene to load into
  41780. * @param data The data to import
  41781. * @param rootUrl The root url for scene and resources
  41782. * @param onProgress The callback when the load progresses
  41783. * @param fileName Defines the name of the file to load
  41784. * @returns The loaded asset container
  41785. */
  41786. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41787. }
  41788. /**
  41789. * Class used to load scene from various file formats using registered plugins
  41790. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41791. */
  41792. export class SceneLoader {
  41793. /**
  41794. * No logging while loading
  41795. */
  41796. static readonly NO_LOGGING: number;
  41797. /**
  41798. * Minimal logging while loading
  41799. */
  41800. static readonly MINIMAL_LOGGING: number;
  41801. /**
  41802. * Summary logging while loading
  41803. */
  41804. static readonly SUMMARY_LOGGING: number;
  41805. /**
  41806. * Detailled logging while loading
  41807. */
  41808. static readonly DETAILED_LOGGING: number;
  41809. /**
  41810. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41811. */
  41812. static ForceFullSceneLoadingForIncremental: boolean;
  41813. /**
  41814. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41815. */
  41816. static ShowLoadingScreen: boolean;
  41817. /**
  41818. * Defines the current logging level (while loading the scene)
  41819. * @ignorenaming
  41820. */
  41821. static loggingLevel: number;
  41822. /**
  41823. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41824. */
  41825. static CleanBoneMatrixWeights: boolean;
  41826. /**
  41827. * Event raised when a plugin is used to load a scene
  41828. */
  41829. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41830. private static _registeredPlugins;
  41831. private static _getDefaultPlugin;
  41832. private static _getPluginForExtension;
  41833. private static _getPluginForDirectLoad;
  41834. private static _getPluginForFilename;
  41835. private static _getDirectLoad;
  41836. private static _loadData;
  41837. private static _getFileInfo;
  41838. /**
  41839. * Gets a plugin that can load the given extension
  41840. * @param extension defines the extension to load
  41841. * @returns a plugin or null if none works
  41842. */
  41843. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41844. /**
  41845. * Gets a boolean indicating that the given extension can be loaded
  41846. * @param extension defines the extension to load
  41847. * @returns true if the extension is supported
  41848. */
  41849. static IsPluginForExtensionAvailable(extension: string): boolean;
  41850. /**
  41851. * Adds a new plugin to the list of registered plugins
  41852. * @param plugin defines the plugin to add
  41853. */
  41854. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41855. /**
  41856. * Import meshes into a scene
  41857. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41858. * @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)
  41859. * @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)
  41860. * @param scene the instance of BABYLON.Scene to append to
  41861. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41862. * @param onProgress a callback with a progress event for each file being loaded
  41863. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41864. * @param pluginExtension the extension used to determine the plugin
  41865. * @returns The loaded plugin
  41866. */
  41867. 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>;
  41868. /**
  41869. * Import meshes into a scene
  41870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41871. * @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)
  41872. * @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)
  41873. * @param scene the instance of BABYLON.Scene to append to
  41874. * @param onProgress a callback with a progress event for each file being loaded
  41875. * @param pluginExtension the extension used to determine the plugin
  41876. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41877. */
  41878. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41879. meshes: AbstractMesh[];
  41880. particleSystems: IParticleSystem[];
  41881. skeletons: Skeleton[];
  41882. animationGroups: AnimationGroup[];
  41883. }>;
  41884. /**
  41885. * Load a scene
  41886. * @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)
  41887. * @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)
  41888. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41889. * @param onSuccess a callback with the scene when import succeeds
  41890. * @param onProgress a callback with a progress event for each file being loaded
  41891. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41892. * @param pluginExtension the extension used to determine the plugin
  41893. * @returns The loaded plugin
  41894. */
  41895. 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>;
  41896. /**
  41897. * Load a scene
  41898. * @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)
  41899. * @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)
  41900. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41901. * @param onProgress a callback with a progress event for each file being loaded
  41902. * @param pluginExtension the extension used to determine the plugin
  41903. * @returns The loaded scene
  41904. */
  41905. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41906. /**
  41907. * Append a scene
  41908. * @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)
  41909. * @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)
  41910. * @param scene is the instance of BABYLON.Scene to append to
  41911. * @param onSuccess a callback with the scene when import succeeds
  41912. * @param onProgress a callback with a progress event for each file being loaded
  41913. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41914. * @param pluginExtension the extension used to determine the plugin
  41915. * @returns The loaded plugin
  41916. */
  41917. 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>;
  41918. /**
  41919. * Append a scene
  41920. * @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)
  41921. * @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)
  41922. * @param scene is the instance of BABYLON.Scene to append to
  41923. * @param onProgress a callback with a progress event for each file being loaded
  41924. * @param pluginExtension the extension used to determine the plugin
  41925. * @returns The given scene
  41926. */
  41927. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41928. /**
  41929. * Load a scene into an asset container
  41930. * @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)
  41931. * @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)
  41932. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41933. * @param onSuccess a callback with the scene when import succeeds
  41934. * @param onProgress a callback with a progress event for each file being loaded
  41935. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41936. * @param pluginExtension the extension used to determine the plugin
  41937. * @returns The loaded plugin
  41938. */
  41939. 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>;
  41940. /**
  41941. * Load a scene into an asset container
  41942. * @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)
  41943. * @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)
  41944. * @param scene is the instance of Scene to append to
  41945. * @param onProgress a callback with a progress event for each file being loaded
  41946. * @param pluginExtension the extension used to determine the plugin
  41947. * @returns The loaded asset container
  41948. */
  41949. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. /**
  41954. * Generic Controller
  41955. */
  41956. export class GenericController extends WebVRController {
  41957. /**
  41958. * Base Url for the controller model.
  41959. */
  41960. static readonly MODEL_BASE_URL: string;
  41961. /**
  41962. * File name for the controller model.
  41963. */
  41964. static readonly MODEL_FILENAME: string;
  41965. /**
  41966. * Creates a new GenericController from a gamepad
  41967. * @param vrGamepad the gamepad that the controller should be created from
  41968. */
  41969. constructor(vrGamepad: any);
  41970. /**
  41971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41972. * @param scene scene in which to add meshes
  41973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41974. */
  41975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41976. /**
  41977. * Called once for each button that changed state since the last frame
  41978. * @param buttonIdx Which button index changed
  41979. * @param state New state of the button
  41980. * @param changes Which properties on the state changed since last frame
  41981. */
  41982. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41983. }
  41984. }
  41985. declare module BABYLON {
  41986. /**
  41987. * Defines the WindowsMotionController object that the state of the windows motion controller
  41988. */
  41989. export class WindowsMotionController extends WebVRController {
  41990. /**
  41991. * The base url used to load the left and right controller models
  41992. */
  41993. static MODEL_BASE_URL: string;
  41994. /**
  41995. * The name of the left controller model file
  41996. */
  41997. static MODEL_LEFT_FILENAME: string;
  41998. /**
  41999. * The name of the right controller model file
  42000. */
  42001. static MODEL_RIGHT_FILENAME: string;
  42002. /**
  42003. * The controller name prefix for this controller type
  42004. */
  42005. static readonly GAMEPAD_ID_PREFIX: string;
  42006. /**
  42007. * The controller id pattern for this controller type
  42008. */
  42009. private static readonly GAMEPAD_ID_PATTERN;
  42010. private _loadedMeshInfo;
  42011. private readonly _mapping;
  42012. /**
  42013. * Fired when the trackpad on this controller is clicked
  42014. */
  42015. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42016. /**
  42017. * Fired when the trackpad on this controller is modified
  42018. */
  42019. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42020. /**
  42021. * The current x and y values of this controller's trackpad
  42022. */
  42023. trackpad: StickValues;
  42024. /**
  42025. * Creates a new WindowsMotionController from a gamepad
  42026. * @param vrGamepad the gamepad that the controller should be created from
  42027. */
  42028. constructor(vrGamepad: any);
  42029. /**
  42030. * Fired when the trigger on this controller is modified
  42031. */
  42032. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42033. /**
  42034. * Fired when the menu button on this controller is modified
  42035. */
  42036. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42037. /**
  42038. * Fired when the grip button on this controller is modified
  42039. */
  42040. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42041. /**
  42042. * Fired when the thumbstick button on this controller is modified
  42043. */
  42044. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42045. /**
  42046. * Fired when the touchpad button on this controller is modified
  42047. */
  42048. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42049. /**
  42050. * Fired when the touchpad values on this controller are modified
  42051. */
  42052. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42053. private _updateTrackpad;
  42054. /**
  42055. * Called once per frame by the engine.
  42056. */
  42057. update(): void;
  42058. /**
  42059. * Called once for each button that changed state since the last frame
  42060. * @param buttonIdx Which button index changed
  42061. * @param state New state of the button
  42062. * @param changes Which properties on the state changed since last frame
  42063. */
  42064. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42065. /**
  42066. * Moves the buttons on the controller mesh based on their current state
  42067. * @param buttonName the name of the button to move
  42068. * @param buttonValue the value of the button which determines the buttons new position
  42069. */
  42070. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42071. /**
  42072. * Moves the axis on the controller mesh based on its current state
  42073. * @param axis the index of the axis
  42074. * @param axisValue the value of the axis which determines the meshes new position
  42075. * @hidden
  42076. */
  42077. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42078. /**
  42079. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42080. * @param scene scene in which to add meshes
  42081. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42082. */
  42083. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42084. /**
  42085. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42086. * can be transformed by button presses and axes values, based on this._mapping.
  42087. *
  42088. * @param scene scene in which the meshes exist
  42089. * @param meshes list of meshes that make up the controller model to process
  42090. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42091. */
  42092. private processModel;
  42093. private createMeshInfo;
  42094. /**
  42095. * Gets the ray of the controller in the direction the controller is pointing
  42096. * @param length the length the resulting ray should be
  42097. * @returns a ray in the direction the controller is pointing
  42098. */
  42099. getForwardRay(length?: number): Ray;
  42100. /**
  42101. * Disposes of the controller
  42102. */
  42103. dispose(): void;
  42104. }
  42105. }
  42106. declare module BABYLON {
  42107. /**
  42108. * Oculus Touch Controller
  42109. */
  42110. export class OculusTouchController extends WebVRController {
  42111. /**
  42112. * Base Url for the controller model.
  42113. */
  42114. static MODEL_BASE_URL: string;
  42115. /**
  42116. * File name for the left controller model.
  42117. */
  42118. static MODEL_LEFT_FILENAME: string;
  42119. /**
  42120. * File name for the right controller model.
  42121. */
  42122. static MODEL_RIGHT_FILENAME: string;
  42123. /**
  42124. * Base Url for the Quest controller model.
  42125. */
  42126. static QUEST_MODEL_BASE_URL: string;
  42127. /**
  42128. * @hidden
  42129. * If the controllers are running on a device that needs the updated Quest controller models
  42130. */
  42131. static _IsQuest: boolean;
  42132. /**
  42133. * Fired when the secondary trigger on this controller is modified
  42134. */
  42135. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42136. /**
  42137. * Fired when the thumb rest on this controller is modified
  42138. */
  42139. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42140. /**
  42141. * Creates a new OculusTouchController from a gamepad
  42142. * @param vrGamepad the gamepad that the controller should be created from
  42143. */
  42144. constructor(vrGamepad: any);
  42145. /**
  42146. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42147. * @param scene scene in which to add meshes
  42148. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42149. */
  42150. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42151. /**
  42152. * Fired when the A button on this controller is modified
  42153. */
  42154. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42155. /**
  42156. * Fired when the B button on this controller is modified
  42157. */
  42158. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42159. /**
  42160. * Fired when the X button on this controller is modified
  42161. */
  42162. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42163. /**
  42164. * Fired when the Y button on this controller is modified
  42165. */
  42166. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42167. /**
  42168. * Called once for each button that changed state since the last frame
  42169. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42170. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42171. * 2) secondary trigger (same)
  42172. * 3) A (right) X (left), touch, pressed = value
  42173. * 4) B / Y
  42174. * 5) thumb rest
  42175. * @param buttonIdx Which button index changed
  42176. * @param state New state of the button
  42177. * @param changes Which properties on the state changed since last frame
  42178. */
  42179. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42180. }
  42181. }
  42182. declare module BABYLON {
  42183. /**
  42184. * Vive Controller
  42185. */
  42186. export class ViveController extends WebVRController {
  42187. /**
  42188. * Base Url for the controller model.
  42189. */
  42190. static MODEL_BASE_URL: string;
  42191. /**
  42192. * File name for the controller model.
  42193. */
  42194. static MODEL_FILENAME: string;
  42195. /**
  42196. * Creates a new ViveController from a gamepad
  42197. * @param vrGamepad the gamepad that the controller should be created from
  42198. */
  42199. constructor(vrGamepad: any);
  42200. /**
  42201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42202. * @param scene scene in which to add meshes
  42203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42204. */
  42205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42206. /**
  42207. * Fired when the left button on this controller is modified
  42208. */
  42209. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42210. /**
  42211. * Fired when the right button on this controller is modified
  42212. */
  42213. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42214. /**
  42215. * Fired when the menu button on this controller is modified
  42216. */
  42217. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42218. /**
  42219. * Called once for each button that changed state since the last frame
  42220. * Vive mapping:
  42221. * 0: touchpad
  42222. * 1: trigger
  42223. * 2: left AND right buttons
  42224. * 3: menu button
  42225. * @param buttonIdx Which button index changed
  42226. * @param state New state of the button
  42227. * @param changes Which properties on the state changed since last frame
  42228. */
  42229. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42230. }
  42231. }
  42232. declare module BABYLON {
  42233. /**
  42234. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42235. */
  42236. export class WebXRControllerModelLoader {
  42237. /**
  42238. * Creates the WebXRControllerModelLoader
  42239. * @param input xr input that creates the controllers
  42240. */
  42241. constructor(input: WebXRInput);
  42242. }
  42243. }
  42244. declare module BABYLON {
  42245. /**
  42246. * Contains an array of blocks representing the octree
  42247. */
  42248. export interface IOctreeContainer<T> {
  42249. /**
  42250. * Blocks within the octree
  42251. */
  42252. blocks: Array<OctreeBlock<T>>;
  42253. }
  42254. /**
  42255. * Class used to store a cell in an octree
  42256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42257. */
  42258. export class OctreeBlock<T> {
  42259. /**
  42260. * Gets the content of the current block
  42261. */
  42262. entries: T[];
  42263. /**
  42264. * Gets the list of block children
  42265. */
  42266. blocks: Array<OctreeBlock<T>>;
  42267. private _depth;
  42268. private _maxDepth;
  42269. private _capacity;
  42270. private _minPoint;
  42271. private _maxPoint;
  42272. private _boundingVectors;
  42273. private _creationFunc;
  42274. /**
  42275. * Creates a new block
  42276. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42277. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42278. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42279. * @param depth defines the current depth of this block in the octree
  42280. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42281. * @param creationFunc defines a callback to call when an element is added to the block
  42282. */
  42283. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42284. /**
  42285. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42286. */
  42287. readonly capacity: number;
  42288. /**
  42289. * Gets the minimum vector (in world space) of the block's bounding box
  42290. */
  42291. readonly minPoint: Vector3;
  42292. /**
  42293. * Gets the maximum vector (in world space) of the block's bounding box
  42294. */
  42295. readonly maxPoint: Vector3;
  42296. /**
  42297. * Add a new element to this block
  42298. * @param entry defines the element to add
  42299. */
  42300. addEntry(entry: T): void;
  42301. /**
  42302. * Remove an element from this block
  42303. * @param entry defines the element to remove
  42304. */
  42305. removeEntry(entry: T): void;
  42306. /**
  42307. * Add an array of elements to this block
  42308. * @param entries defines the array of elements to add
  42309. */
  42310. addEntries(entries: T[]): void;
  42311. /**
  42312. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42313. * @param frustumPlanes defines the frustum planes to test
  42314. * @param selection defines the array to store current content if selection is positive
  42315. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42316. */
  42317. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42318. /**
  42319. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42320. * @param sphereCenter defines the bounding sphere center
  42321. * @param sphereRadius defines the bounding sphere radius
  42322. * @param selection defines the array to store current content if selection is positive
  42323. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42324. */
  42325. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42326. /**
  42327. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42328. * @param ray defines the ray to test with
  42329. * @param selection defines the array to store current content if selection is positive
  42330. */
  42331. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42332. /**
  42333. * Subdivide the content into child blocks (this block will then be empty)
  42334. */
  42335. createInnerBlocks(): void;
  42336. /**
  42337. * @hidden
  42338. */
  42339. 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;
  42340. }
  42341. }
  42342. declare module BABYLON {
  42343. /**
  42344. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42346. */
  42347. export class Octree<T> {
  42348. /** 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.) */
  42349. maxDepth: number;
  42350. /**
  42351. * Blocks within the octree containing objects
  42352. */
  42353. blocks: Array<OctreeBlock<T>>;
  42354. /**
  42355. * Content stored in the octree
  42356. */
  42357. dynamicContent: T[];
  42358. private _maxBlockCapacity;
  42359. private _selectionContent;
  42360. private _creationFunc;
  42361. /**
  42362. * Creates a octree
  42363. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42364. * @param creationFunc function to be used to instatiate the octree
  42365. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42366. * @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.)
  42367. */
  42368. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42369. /** 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.) */
  42370. maxDepth?: number);
  42371. /**
  42372. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42373. * @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);
  42374. * @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);
  42375. * @param entries meshes to be added to the octree blocks
  42376. */
  42377. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42378. /**
  42379. * Adds a mesh to the octree
  42380. * @param entry Mesh to add to the octree
  42381. */
  42382. addMesh(entry: T): void;
  42383. /**
  42384. * Remove an element from the octree
  42385. * @param entry defines the element to remove
  42386. */
  42387. removeMesh(entry: T): void;
  42388. /**
  42389. * Selects an array of meshes within the frustum
  42390. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42391. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42392. * @returns array of meshes within the frustum
  42393. */
  42394. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42395. /**
  42396. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42397. * @param sphereCenter defines the bounding sphere center
  42398. * @param sphereRadius defines the bounding sphere radius
  42399. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42400. * @returns an array of objects that intersect the sphere
  42401. */
  42402. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42403. /**
  42404. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42405. * @param ray defines the ray to test with
  42406. * @returns array of intersected objects
  42407. */
  42408. intersectsRay(ray: Ray): SmartArray<T>;
  42409. /**
  42410. * Adds a mesh into the octree block if it intersects the block
  42411. */
  42412. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42413. /**
  42414. * Adds a submesh into the octree block if it intersects the block
  42415. */
  42416. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42417. }
  42418. }
  42419. declare module BABYLON {
  42420. interface Scene {
  42421. /**
  42422. * @hidden
  42423. * Backing Filed
  42424. */
  42425. _selectionOctree: Octree<AbstractMesh>;
  42426. /**
  42427. * Gets the octree used to boost mesh selection (picking)
  42428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42429. */
  42430. selectionOctree: Octree<AbstractMesh>;
  42431. /**
  42432. * Creates or updates the octree used to boost selection (picking)
  42433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42434. * @param maxCapacity defines the maximum capacity per leaf
  42435. * @param maxDepth defines the maximum depth of the octree
  42436. * @returns an octree of AbstractMesh
  42437. */
  42438. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42439. }
  42440. interface AbstractMesh {
  42441. /**
  42442. * @hidden
  42443. * Backing Field
  42444. */
  42445. _submeshesOctree: Octree<SubMesh>;
  42446. /**
  42447. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42448. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42449. * @param maxCapacity defines the maximum size of each block (64 by default)
  42450. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42451. * @returns the new octree
  42452. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42454. */
  42455. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42456. }
  42457. /**
  42458. * Defines the octree scene component responsible to manage any octrees
  42459. * in a given scene.
  42460. */
  42461. export class OctreeSceneComponent {
  42462. /**
  42463. * The component name help to identify the component in the list of scene components.
  42464. */
  42465. readonly name: string;
  42466. /**
  42467. * The scene the component belongs to.
  42468. */
  42469. scene: Scene;
  42470. /**
  42471. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42472. */
  42473. readonly checksIsEnabled: boolean;
  42474. /**
  42475. * Creates a new instance of the component for the given scene
  42476. * @param scene Defines the scene to register the component in
  42477. */
  42478. constructor(scene: Scene);
  42479. /**
  42480. * Registers the component in a given scene
  42481. */
  42482. register(): void;
  42483. /**
  42484. * Return the list of active meshes
  42485. * @returns the list of active meshes
  42486. */
  42487. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42488. /**
  42489. * Return the list of active sub meshes
  42490. * @param mesh The mesh to get the candidates sub meshes from
  42491. * @returns the list of active sub meshes
  42492. */
  42493. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42494. private _tempRay;
  42495. /**
  42496. * Return the list of sub meshes intersecting with a given local ray
  42497. * @param mesh defines the mesh to find the submesh for
  42498. * @param localRay defines the ray in local space
  42499. * @returns the list of intersecting sub meshes
  42500. */
  42501. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42502. /**
  42503. * Return the list of sub meshes colliding with a collider
  42504. * @param mesh defines the mesh to find the submesh for
  42505. * @param collider defines the collider to evaluate the collision against
  42506. * @returns the list of colliding sub meshes
  42507. */
  42508. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42509. /**
  42510. * Rebuilds the elements related to this component in case of
  42511. * context lost for instance.
  42512. */
  42513. rebuild(): void;
  42514. /**
  42515. * Disposes the component and the associated ressources.
  42516. */
  42517. dispose(): void;
  42518. }
  42519. }
  42520. declare module BABYLON {
  42521. /**
  42522. * Renders a layer on top of an existing scene
  42523. */
  42524. export class UtilityLayerRenderer implements IDisposable {
  42525. /** the original scene that will be rendered on top of */
  42526. originalScene: Scene;
  42527. private _pointerCaptures;
  42528. private _lastPointerEvents;
  42529. private static _DefaultUtilityLayer;
  42530. private static _DefaultKeepDepthUtilityLayer;
  42531. private _sharedGizmoLight;
  42532. private _renderCamera;
  42533. /**
  42534. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42535. * @returns the camera that is used when rendering the utility layer
  42536. */
  42537. getRenderCamera(): Nullable<Camera>;
  42538. /**
  42539. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42540. * @param cam the camera that should be used when rendering the utility layer
  42541. */
  42542. setRenderCamera(cam: Nullable<Camera>): void;
  42543. /**
  42544. * @hidden
  42545. * Light which used by gizmos to get light shading
  42546. */
  42547. _getSharedGizmoLight(): HemisphericLight;
  42548. /**
  42549. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42550. */
  42551. pickUtilitySceneFirst: boolean;
  42552. /**
  42553. * 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)
  42554. */
  42555. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42556. /**
  42557. * 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)
  42558. */
  42559. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42560. /**
  42561. * The scene that is rendered on top of the original scene
  42562. */
  42563. utilityLayerScene: Scene;
  42564. /**
  42565. * If the utility layer should automatically be rendered on top of existing scene
  42566. */
  42567. shouldRender: boolean;
  42568. /**
  42569. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42570. */
  42571. onlyCheckPointerDownEvents: boolean;
  42572. /**
  42573. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42574. */
  42575. processAllEvents: boolean;
  42576. /**
  42577. * Observable raised when the pointer move from the utility layer scene to the main scene
  42578. */
  42579. onPointerOutObservable: Observable<number>;
  42580. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42581. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42582. private _afterRenderObserver;
  42583. private _sceneDisposeObserver;
  42584. private _originalPointerObserver;
  42585. /**
  42586. * Instantiates a UtilityLayerRenderer
  42587. * @param originalScene the original scene that will be rendered on top of
  42588. * @param handleEvents boolean indicating if the utility layer should handle events
  42589. */
  42590. constructor(
  42591. /** the original scene that will be rendered on top of */
  42592. originalScene: Scene, handleEvents?: boolean);
  42593. private _notifyObservers;
  42594. /**
  42595. * Renders the utility layers scene on top of the original scene
  42596. */
  42597. render(): void;
  42598. /**
  42599. * Disposes of the renderer
  42600. */
  42601. dispose(): void;
  42602. private _updateCamera;
  42603. }
  42604. }
  42605. declare module BABYLON {
  42606. /**
  42607. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42608. */
  42609. export class Gizmo implements IDisposable {
  42610. /** The utility layer the gizmo will be added to */
  42611. gizmoLayer: UtilityLayerRenderer;
  42612. /**
  42613. * The root mesh of the gizmo
  42614. */
  42615. _rootMesh: Mesh;
  42616. private _attachedMesh;
  42617. /**
  42618. * Ratio for the scale of the gizmo (Default: 1)
  42619. */
  42620. scaleRatio: number;
  42621. /**
  42622. * If a custom mesh has been set (Default: false)
  42623. */
  42624. protected _customMeshSet: boolean;
  42625. /**
  42626. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42627. * * When set, interactions will be enabled
  42628. */
  42629. attachedMesh: Nullable<AbstractMesh>;
  42630. /**
  42631. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42632. * @param mesh The mesh to replace the default mesh of the gizmo
  42633. */
  42634. setCustomMesh(mesh: Mesh): void;
  42635. /**
  42636. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42637. */
  42638. updateGizmoRotationToMatchAttachedMesh: boolean;
  42639. /**
  42640. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42641. */
  42642. updateGizmoPositionToMatchAttachedMesh: boolean;
  42643. /**
  42644. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42645. */
  42646. updateScale: boolean;
  42647. protected _interactionsEnabled: boolean;
  42648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42649. private _beforeRenderObserver;
  42650. private _tempVector;
  42651. /**
  42652. * Creates a gizmo
  42653. * @param gizmoLayer The utility layer the gizmo will be added to
  42654. */
  42655. constructor(
  42656. /** The utility layer the gizmo will be added to */
  42657. gizmoLayer?: UtilityLayerRenderer);
  42658. /**
  42659. * Updates the gizmo to match the attached mesh's position/rotation
  42660. */
  42661. protected _update(): void;
  42662. /**
  42663. * Disposes of the gizmo
  42664. */
  42665. dispose(): void;
  42666. }
  42667. }
  42668. declare module BABYLON {
  42669. /**
  42670. * Single plane drag gizmo
  42671. */
  42672. export class PlaneDragGizmo extends Gizmo {
  42673. /**
  42674. * Drag behavior responsible for the gizmos dragging interactions
  42675. */
  42676. dragBehavior: PointerDragBehavior;
  42677. private _pointerObserver;
  42678. /**
  42679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42680. */
  42681. snapDistance: number;
  42682. /**
  42683. * Event that fires each time the gizmo snaps to a new location.
  42684. * * snapDistance is the the change in distance
  42685. */
  42686. onSnapObservable: Observable<{
  42687. snapDistance: number;
  42688. }>;
  42689. private _plane;
  42690. private _coloredMaterial;
  42691. private _hoverMaterial;
  42692. private _isEnabled;
  42693. private _parent;
  42694. /** @hidden */
  42695. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42696. /** @hidden */
  42697. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42698. /**
  42699. * Creates a PlaneDragGizmo
  42700. * @param gizmoLayer The utility layer the gizmo will be added to
  42701. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42702. * @param color The color of the gizmo
  42703. */
  42704. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42706. /**
  42707. * If the gizmo is enabled
  42708. */
  42709. isEnabled: boolean;
  42710. /**
  42711. * Disposes of the gizmo
  42712. */
  42713. dispose(): void;
  42714. }
  42715. }
  42716. declare module BABYLON {
  42717. /**
  42718. * Gizmo that enables dragging a mesh along 3 axis
  42719. */
  42720. export class PositionGizmo extends Gizmo {
  42721. /**
  42722. * Internal gizmo used for interactions on the x axis
  42723. */
  42724. xGizmo: AxisDragGizmo;
  42725. /**
  42726. * Internal gizmo used for interactions on the y axis
  42727. */
  42728. yGizmo: AxisDragGizmo;
  42729. /**
  42730. * Internal gizmo used for interactions on the z axis
  42731. */
  42732. zGizmo: AxisDragGizmo;
  42733. /**
  42734. * Internal gizmo used for interactions on the yz plane
  42735. */
  42736. xPlaneGizmo: PlaneDragGizmo;
  42737. /**
  42738. * Internal gizmo used for interactions on the xz plane
  42739. */
  42740. yPlaneGizmo: PlaneDragGizmo;
  42741. /**
  42742. * Internal gizmo used for interactions on the xy plane
  42743. */
  42744. zPlaneGizmo: PlaneDragGizmo;
  42745. /**
  42746. * private variables
  42747. */
  42748. private _meshAttached;
  42749. private _updateGizmoRotationToMatchAttachedMesh;
  42750. private _snapDistance;
  42751. private _scaleRatio;
  42752. /** Fires an event when any of it's sub gizmos are dragged */
  42753. onDragStartObservable: Observable<unknown>;
  42754. /** Fires an event when any of it's sub gizmos are released from dragging */
  42755. onDragEndObservable: Observable<unknown>;
  42756. /**
  42757. * If set to true, planar drag is enabled
  42758. */
  42759. private _planarGizmoEnabled;
  42760. attachedMesh: Nullable<AbstractMesh>;
  42761. /**
  42762. * Creates a PositionGizmo
  42763. * @param gizmoLayer The utility layer the gizmo will be added to
  42764. */
  42765. constructor(gizmoLayer?: UtilityLayerRenderer);
  42766. /**
  42767. * If the planar drag gizmo is enabled
  42768. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42769. */
  42770. planarGizmoEnabled: boolean;
  42771. updateGizmoRotationToMatchAttachedMesh: boolean;
  42772. /**
  42773. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42774. */
  42775. snapDistance: number;
  42776. /**
  42777. * Ratio for the scale of the gizmo (Default: 1)
  42778. */
  42779. scaleRatio: number;
  42780. /**
  42781. * Disposes of the gizmo
  42782. */
  42783. dispose(): void;
  42784. /**
  42785. * CustomMeshes are not supported by this gizmo
  42786. * @param mesh The mesh to replace the default mesh of the gizmo
  42787. */
  42788. setCustomMesh(mesh: Mesh): void;
  42789. }
  42790. }
  42791. declare module BABYLON {
  42792. /**
  42793. * Single axis drag gizmo
  42794. */
  42795. export class AxisDragGizmo extends Gizmo {
  42796. /**
  42797. * Drag behavior responsible for the gizmos dragging interactions
  42798. */
  42799. dragBehavior: PointerDragBehavior;
  42800. private _pointerObserver;
  42801. /**
  42802. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42803. */
  42804. snapDistance: number;
  42805. /**
  42806. * Event that fires each time the gizmo snaps to a new location.
  42807. * * snapDistance is the the change in distance
  42808. */
  42809. onSnapObservable: Observable<{
  42810. snapDistance: number;
  42811. }>;
  42812. private _isEnabled;
  42813. private _parent;
  42814. private _arrow;
  42815. private _coloredMaterial;
  42816. private _hoverMaterial;
  42817. /** @hidden */
  42818. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42819. /** @hidden */
  42820. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42821. /**
  42822. * Creates an AxisDragGizmo
  42823. * @param gizmoLayer The utility layer the gizmo will be added to
  42824. * @param dragAxis The axis which the gizmo will be able to drag on
  42825. * @param color The color of the gizmo
  42826. */
  42827. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42829. /**
  42830. * If the gizmo is enabled
  42831. */
  42832. isEnabled: boolean;
  42833. /**
  42834. * Disposes of the gizmo
  42835. */
  42836. dispose(): void;
  42837. }
  42838. }
  42839. declare module BABYLON.Debug {
  42840. /**
  42841. * The Axes viewer will show 3 axes in a specific point in space
  42842. */
  42843. export class AxesViewer {
  42844. private _xAxis;
  42845. private _yAxis;
  42846. private _zAxis;
  42847. private _scaleLinesFactor;
  42848. private _instanced;
  42849. /**
  42850. * Gets the hosting scene
  42851. */
  42852. scene: Scene;
  42853. /**
  42854. * Gets or sets a number used to scale line length
  42855. */
  42856. scaleLines: number;
  42857. /** Gets the node hierarchy used to render x-axis */
  42858. readonly xAxis: TransformNode;
  42859. /** Gets the node hierarchy used to render y-axis */
  42860. readonly yAxis: TransformNode;
  42861. /** Gets the node hierarchy used to render z-axis */
  42862. readonly zAxis: TransformNode;
  42863. /**
  42864. * Creates a new AxesViewer
  42865. * @param scene defines the hosting scene
  42866. * @param scaleLines defines a number used to scale line length (1 by default)
  42867. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42868. * @param xAxis defines the node hierarchy used to render the x-axis
  42869. * @param yAxis defines the node hierarchy used to render the y-axis
  42870. * @param zAxis defines the node hierarchy used to render the z-axis
  42871. */
  42872. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42873. /**
  42874. * Force the viewer to update
  42875. * @param position defines the position of the viewer
  42876. * @param xaxis defines the x axis of the viewer
  42877. * @param yaxis defines the y axis of the viewer
  42878. * @param zaxis defines the z axis of the viewer
  42879. */
  42880. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42881. /**
  42882. * Creates an instance of this axes viewer.
  42883. * @returns a new axes viewer with instanced meshes
  42884. */
  42885. createInstance(): AxesViewer;
  42886. /** Releases resources */
  42887. dispose(): void;
  42888. private static _SetRenderingGroupId;
  42889. }
  42890. }
  42891. declare module BABYLON.Debug {
  42892. /**
  42893. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42894. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42895. */
  42896. export class BoneAxesViewer extends AxesViewer {
  42897. /**
  42898. * Gets or sets the target mesh where to display the axes viewer
  42899. */
  42900. mesh: Nullable<Mesh>;
  42901. /**
  42902. * Gets or sets the target bone where to display the axes viewer
  42903. */
  42904. bone: Nullable<Bone>;
  42905. /** Gets current position */
  42906. pos: Vector3;
  42907. /** Gets direction of X axis */
  42908. xaxis: Vector3;
  42909. /** Gets direction of Y axis */
  42910. yaxis: Vector3;
  42911. /** Gets direction of Z axis */
  42912. zaxis: Vector3;
  42913. /**
  42914. * Creates a new BoneAxesViewer
  42915. * @param scene defines the hosting scene
  42916. * @param bone defines the target bone
  42917. * @param mesh defines the target mesh
  42918. * @param scaleLines defines a scaling factor for line length (1 by default)
  42919. */
  42920. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42921. /**
  42922. * Force the viewer to update
  42923. */
  42924. update(): void;
  42925. /** Releases resources */
  42926. dispose(): void;
  42927. }
  42928. }
  42929. declare module BABYLON {
  42930. /**
  42931. * Interface used to define scene explorer extensibility option
  42932. */
  42933. export interface IExplorerExtensibilityOption {
  42934. /**
  42935. * Define the option label
  42936. */
  42937. label: string;
  42938. /**
  42939. * Defines the action to execute on click
  42940. */
  42941. action: (entity: any) => void;
  42942. }
  42943. /**
  42944. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42945. */
  42946. export interface IExplorerExtensibilityGroup {
  42947. /**
  42948. * Defines a predicate to test if a given type mut be extended
  42949. */
  42950. predicate: (entity: any) => boolean;
  42951. /**
  42952. * Gets the list of options added to a type
  42953. */
  42954. entries: IExplorerExtensibilityOption[];
  42955. }
  42956. /**
  42957. * Interface used to define the options to use to create the Inspector
  42958. */
  42959. export interface IInspectorOptions {
  42960. /**
  42961. * Display in overlay mode (default: false)
  42962. */
  42963. overlay?: boolean;
  42964. /**
  42965. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42966. */
  42967. globalRoot?: HTMLElement;
  42968. /**
  42969. * Display the Scene explorer
  42970. */
  42971. showExplorer?: boolean;
  42972. /**
  42973. * Display the property inspector
  42974. */
  42975. showInspector?: boolean;
  42976. /**
  42977. * Display in embed mode (both panes on the right)
  42978. */
  42979. embedMode?: boolean;
  42980. /**
  42981. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42982. */
  42983. handleResize?: boolean;
  42984. /**
  42985. * Allow the panes to popup (default: true)
  42986. */
  42987. enablePopup?: boolean;
  42988. /**
  42989. * Allow the panes to be closed by users (default: true)
  42990. */
  42991. enableClose?: boolean;
  42992. /**
  42993. * Optional list of extensibility entries
  42994. */
  42995. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42996. /**
  42997. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42998. */
  42999. inspectorURL?: string;
  43000. }
  43001. interface Scene {
  43002. /**
  43003. * @hidden
  43004. * Backing field
  43005. */
  43006. _debugLayer: DebugLayer;
  43007. /**
  43008. * Gets the debug layer (aka Inspector) associated with the scene
  43009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43010. */
  43011. debugLayer: DebugLayer;
  43012. }
  43013. /**
  43014. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43015. * what is happening in your scene
  43016. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43017. */
  43018. export class DebugLayer {
  43019. /**
  43020. * Define the url to get the inspector script from.
  43021. * By default it uses the babylonjs CDN.
  43022. * @ignoreNaming
  43023. */
  43024. static InspectorURL: string;
  43025. private _scene;
  43026. private BJSINSPECTOR;
  43027. private _onPropertyChangedObservable?;
  43028. /**
  43029. * Observable triggered when a property is changed through the inspector.
  43030. */
  43031. readonly onPropertyChangedObservable: any;
  43032. /**
  43033. * Instantiates a new debug layer.
  43034. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43035. * what is happening in your scene
  43036. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43037. * @param scene Defines the scene to inspect
  43038. */
  43039. constructor(scene: Scene);
  43040. /** Creates the inspector window. */
  43041. private _createInspector;
  43042. /**
  43043. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43044. * @param entity defines the entity to select
  43045. * @param lineContainerTitle defines the specific block to highlight
  43046. */
  43047. select(entity: any, lineContainerTitle?: string): void;
  43048. /** Get the inspector from bundle or global */
  43049. private _getGlobalInspector;
  43050. /**
  43051. * Get if the inspector is visible or not.
  43052. * @returns true if visible otherwise, false
  43053. */
  43054. isVisible(): boolean;
  43055. /**
  43056. * Hide the inspector and close its window.
  43057. */
  43058. hide(): void;
  43059. /**
  43060. * Launch the debugLayer.
  43061. * @param config Define the configuration of the inspector
  43062. * @return a promise fulfilled when the debug layer is visible
  43063. */
  43064. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43065. }
  43066. }
  43067. declare module BABYLON {
  43068. /**
  43069. * Class containing static functions to help procedurally build meshes
  43070. */
  43071. export class BoxBuilder {
  43072. /**
  43073. * Creates a box mesh
  43074. * * The parameter `size` sets the size (float) of each box side (default 1)
  43075. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43076. * * 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)
  43077. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43079. * * 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
  43080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43081. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43082. * @param name defines the name of the mesh
  43083. * @param options defines the options used to create the mesh
  43084. * @param scene defines the hosting scene
  43085. * @returns the box mesh
  43086. */
  43087. static CreateBox(name: string, options: {
  43088. size?: number;
  43089. width?: number;
  43090. height?: number;
  43091. depth?: number;
  43092. faceUV?: Vector4[];
  43093. faceColors?: Color4[];
  43094. sideOrientation?: number;
  43095. frontUVs?: Vector4;
  43096. backUVs?: Vector4;
  43097. wrap?: boolean;
  43098. topBaseAt?: number;
  43099. bottomBaseAt?: number;
  43100. updatable?: boolean;
  43101. }, scene?: Nullable<Scene>): Mesh;
  43102. }
  43103. }
  43104. declare module BABYLON {
  43105. /**
  43106. * Class containing static functions to help procedurally build meshes
  43107. */
  43108. export class SphereBuilder {
  43109. /**
  43110. * Creates a sphere mesh
  43111. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43112. * * 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`)
  43113. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43114. * * 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
  43115. * * 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)
  43116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43117. * * 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
  43118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43119. * @param name defines the name of the mesh
  43120. * @param options defines the options used to create the mesh
  43121. * @param scene defines the hosting scene
  43122. * @returns the sphere mesh
  43123. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43124. */
  43125. static CreateSphere(name: string, options: {
  43126. segments?: number;
  43127. diameter?: number;
  43128. diameterX?: number;
  43129. diameterY?: number;
  43130. diameterZ?: number;
  43131. arc?: number;
  43132. slice?: number;
  43133. sideOrientation?: number;
  43134. frontUVs?: Vector4;
  43135. backUVs?: Vector4;
  43136. updatable?: boolean;
  43137. }, scene?: Nullable<Scene>): Mesh;
  43138. }
  43139. }
  43140. declare module BABYLON.Debug {
  43141. /**
  43142. * Used to show the physics impostor around the specific mesh
  43143. */
  43144. export class PhysicsViewer {
  43145. /** @hidden */
  43146. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43147. /** @hidden */
  43148. protected _meshes: Array<Nullable<AbstractMesh>>;
  43149. /** @hidden */
  43150. protected _scene: Nullable<Scene>;
  43151. /** @hidden */
  43152. protected _numMeshes: number;
  43153. /** @hidden */
  43154. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43155. private _renderFunction;
  43156. private _utilityLayer;
  43157. private _debugBoxMesh;
  43158. private _debugSphereMesh;
  43159. private _debugCylinderMesh;
  43160. private _debugMaterial;
  43161. private _debugMeshMeshes;
  43162. /**
  43163. * Creates a new PhysicsViewer
  43164. * @param scene defines the hosting scene
  43165. */
  43166. constructor(scene: Scene);
  43167. /** @hidden */
  43168. protected _updateDebugMeshes(): void;
  43169. /**
  43170. * Renders a specified physic impostor
  43171. * @param impostor defines the impostor to render
  43172. * @param targetMesh defines the mesh represented by the impostor
  43173. * @returns the new debug mesh used to render the impostor
  43174. */
  43175. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43176. /**
  43177. * Hides a specified physic impostor
  43178. * @param impostor defines the impostor to hide
  43179. */
  43180. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43181. private _getDebugMaterial;
  43182. private _getDebugBoxMesh;
  43183. private _getDebugSphereMesh;
  43184. private _getDebugCylinderMesh;
  43185. private _getDebugMeshMesh;
  43186. private _getDebugMesh;
  43187. /** Releases all resources */
  43188. dispose(): void;
  43189. }
  43190. }
  43191. declare module BABYLON {
  43192. /**
  43193. * Class containing static functions to help procedurally build meshes
  43194. */
  43195. export class LinesBuilder {
  43196. /**
  43197. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43198. * * 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
  43199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43200. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43201. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43202. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43204. * * 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
  43205. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43208. * @param name defines the name of the new line system
  43209. * @param options defines the options used to create the line system
  43210. * @param scene defines the hosting scene
  43211. * @returns a new line system mesh
  43212. */
  43213. static CreateLineSystem(name: string, options: {
  43214. lines: Vector3[][];
  43215. updatable?: boolean;
  43216. instance?: Nullable<LinesMesh>;
  43217. colors?: Nullable<Color4[][]>;
  43218. useVertexAlpha?: boolean;
  43219. }, scene: Nullable<Scene>): LinesMesh;
  43220. /**
  43221. * Creates a line mesh
  43222. * 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
  43223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43224. * * The parameter `points` is an array successive Vector3
  43225. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  43226. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43227. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43228. * * When updating an instance, remember that only point positions can change, not the number of points
  43229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43231. * @param name defines the name of the new line system
  43232. * @param options defines the options used to create the line system
  43233. * @param scene defines the hosting scene
  43234. * @returns a new line mesh
  43235. */
  43236. static CreateLines(name: string, options: {
  43237. points: Vector3[];
  43238. updatable?: boolean;
  43239. instance?: Nullable<LinesMesh>;
  43240. colors?: Color4[];
  43241. useVertexAlpha?: boolean;
  43242. }, scene?: Nullable<Scene>): LinesMesh;
  43243. /**
  43244. * Creates a dashed line mesh
  43245. * * 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
  43246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43247. * * The parameter `points` is an array successive Vector3
  43248. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43249. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43250. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43251. * * 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
  43252. * * When updating an instance, remember that only point positions can change, not the number of points
  43253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43254. * @param name defines the name of the mesh
  43255. * @param options defines the options used to create the mesh
  43256. * @param scene defines the hosting scene
  43257. * @returns the dashed line mesh
  43258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43259. */
  43260. static CreateDashedLines(name: string, options: {
  43261. points: Vector3[];
  43262. dashSize?: number;
  43263. gapSize?: number;
  43264. dashNb?: number;
  43265. updatable?: boolean;
  43266. instance?: LinesMesh;
  43267. }, scene?: Nullable<Scene>): LinesMesh;
  43268. }
  43269. }
  43270. declare module BABYLON {
  43271. /**
  43272. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43273. * in order to better appreciate the issue one might have.
  43274. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43275. */
  43276. export class RayHelper {
  43277. /**
  43278. * Defines the ray we are currently tryin to visualize.
  43279. */
  43280. ray: Nullable<Ray>;
  43281. private _renderPoints;
  43282. private _renderLine;
  43283. private _renderFunction;
  43284. private _scene;
  43285. private _updateToMeshFunction;
  43286. private _attachedToMesh;
  43287. private _meshSpaceDirection;
  43288. private _meshSpaceOrigin;
  43289. /**
  43290. * Helper function to create a colored helper in a scene in one line.
  43291. * @param ray Defines the ray we are currently tryin to visualize
  43292. * @param scene Defines the scene the ray is used in
  43293. * @param color Defines the color we want to see the ray in
  43294. * @returns The newly created ray helper.
  43295. */
  43296. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43297. /**
  43298. * Instantiate a new ray helper.
  43299. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43300. * in order to better appreciate the issue one might have.
  43301. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43302. * @param ray Defines the ray we are currently tryin to visualize
  43303. */
  43304. constructor(ray: Ray);
  43305. /**
  43306. * Shows the ray we are willing to debug.
  43307. * @param scene Defines the scene the ray needs to be rendered in
  43308. * @param color Defines the color the ray needs to be rendered in
  43309. */
  43310. show(scene: Scene, color?: Color3): void;
  43311. /**
  43312. * Hides the ray we are debugging.
  43313. */
  43314. hide(): void;
  43315. private _render;
  43316. /**
  43317. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43318. * @param mesh Defines the mesh we want the helper attached to
  43319. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43320. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43321. * @param length Defines the length of the ray
  43322. */
  43323. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43324. /**
  43325. * Detach the ray helper from the mesh it has previously been attached to.
  43326. */
  43327. detachFromMesh(): void;
  43328. private _updateToMesh;
  43329. /**
  43330. * Dispose the helper and release its associated resources.
  43331. */
  43332. dispose(): void;
  43333. }
  43334. }
  43335. declare module BABYLON.Debug {
  43336. /**
  43337. * Class used to render a debug view of a given skeleton
  43338. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43339. */
  43340. export class SkeletonViewer {
  43341. /** defines the skeleton to render */
  43342. skeleton: Skeleton;
  43343. /** defines the mesh attached to the skeleton */
  43344. mesh: AbstractMesh;
  43345. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43346. autoUpdateBonesMatrices: boolean;
  43347. /** defines the rendering group id to use with the viewer */
  43348. renderingGroupId: number;
  43349. /** Gets or sets the color used to render the skeleton */
  43350. color: Color3;
  43351. private _scene;
  43352. private _debugLines;
  43353. private _debugMesh;
  43354. private _isEnabled;
  43355. private _renderFunction;
  43356. private _utilityLayer;
  43357. /**
  43358. * Returns the mesh used to render the bones
  43359. */
  43360. readonly debugMesh: Nullable<LinesMesh>;
  43361. /**
  43362. * Creates a new SkeletonViewer
  43363. * @param skeleton defines the skeleton to render
  43364. * @param mesh defines the mesh attached to the skeleton
  43365. * @param scene defines the hosting scene
  43366. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43367. * @param renderingGroupId defines the rendering group id to use with the viewer
  43368. */
  43369. constructor(
  43370. /** defines the skeleton to render */
  43371. skeleton: Skeleton,
  43372. /** defines the mesh attached to the skeleton */
  43373. mesh: AbstractMesh, scene: Scene,
  43374. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43375. autoUpdateBonesMatrices?: boolean,
  43376. /** defines the rendering group id to use with the viewer */
  43377. renderingGroupId?: number);
  43378. /** Gets or sets a boolean indicating if the viewer is enabled */
  43379. isEnabled: boolean;
  43380. private _getBonePosition;
  43381. private _getLinesForBonesWithLength;
  43382. private _getLinesForBonesNoLength;
  43383. /** Update the viewer to sync with current skeleton state */
  43384. update(): void;
  43385. /** Release associated resources */
  43386. dispose(): void;
  43387. }
  43388. }
  43389. declare module BABYLON {
  43390. /**
  43391. * Options to create the null engine
  43392. */
  43393. export class NullEngineOptions {
  43394. /**
  43395. * Render width (Default: 512)
  43396. */
  43397. renderWidth: number;
  43398. /**
  43399. * Render height (Default: 256)
  43400. */
  43401. renderHeight: number;
  43402. /**
  43403. * Texture size (Default: 512)
  43404. */
  43405. textureSize: number;
  43406. /**
  43407. * If delta time between frames should be constant
  43408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43409. */
  43410. deterministicLockstep: boolean;
  43411. /**
  43412. * Maximum about of steps between frames (Default: 4)
  43413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43414. */
  43415. lockstepMaxSteps: number;
  43416. }
  43417. /**
  43418. * The null engine class provides support for headless version of babylon.js.
  43419. * This can be used in server side scenario or for testing purposes
  43420. */
  43421. export class NullEngine extends Engine {
  43422. private _options;
  43423. /**
  43424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43425. */
  43426. isDeterministicLockStep(): boolean;
  43427. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43428. getLockstepMaxSteps(): number;
  43429. /**
  43430. * Sets hardware scaling, used to save performance if needed
  43431. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43432. */
  43433. getHardwareScalingLevel(): number;
  43434. constructor(options?: NullEngineOptions);
  43435. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43436. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43437. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43438. getRenderWidth(useScreen?: boolean): number;
  43439. getRenderHeight(useScreen?: boolean): number;
  43440. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43441. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43442. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43443. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43444. bindSamplers(effect: Effect): void;
  43445. enableEffect(effect: Effect): void;
  43446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43447. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43448. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43449. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43450. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43451. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43452. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43453. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43454. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43455. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43456. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43457. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43458. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43459. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43460. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43461. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43462. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43463. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43464. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43465. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43466. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43467. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43468. bindBuffers(vertexBuffers: {
  43469. [key: string]: VertexBuffer;
  43470. }, indexBuffer: DataBuffer, effect: Effect): void;
  43471. wipeCaches(bruteForce?: boolean): void;
  43472. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43473. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43474. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43475. /** @hidden */
  43476. _createTexture(): WebGLTexture;
  43477. /** @hidden */
  43478. _releaseTexture(texture: InternalTexture): void;
  43479. 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;
  43480. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43481. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43482. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43483. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43484. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43485. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43486. areAllEffectsReady(): boolean;
  43487. /**
  43488. * @hidden
  43489. * Get the current error code of the webGL context
  43490. * @returns the error code
  43491. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43492. */
  43493. getError(): number;
  43494. /** @hidden */
  43495. _getUnpackAlignement(): number;
  43496. /** @hidden */
  43497. _unpackFlipY(value: boolean): void;
  43498. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43499. /**
  43500. * Updates a dynamic vertex buffer.
  43501. * @param vertexBuffer the vertex buffer to update
  43502. * @param data the data used to update the vertex buffer
  43503. * @param byteOffset the byte offset of the data (optional)
  43504. * @param byteLength the byte length of the data (optional)
  43505. */
  43506. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43507. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43508. /** @hidden */
  43509. _bindTexture(channel: number, texture: InternalTexture): void;
  43510. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43511. releaseEffects(): void;
  43512. displayLoadingUI(): void;
  43513. hideLoadingUI(): void;
  43514. /** @hidden */
  43515. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43516. /** @hidden */
  43517. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43518. /** @hidden */
  43519. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43520. /** @hidden */
  43521. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43522. }
  43523. }
  43524. declare module BABYLON {
  43525. /** @hidden */
  43526. export class _OcclusionDataStorage {
  43527. /** @hidden */
  43528. occlusionInternalRetryCounter: number;
  43529. /** @hidden */
  43530. isOcclusionQueryInProgress: boolean;
  43531. /** @hidden */
  43532. isOccluded: boolean;
  43533. /** @hidden */
  43534. occlusionRetryCount: number;
  43535. /** @hidden */
  43536. occlusionType: number;
  43537. /** @hidden */
  43538. occlusionQueryAlgorithmType: number;
  43539. }
  43540. interface Engine {
  43541. /**
  43542. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43543. * @return the new query
  43544. */
  43545. createQuery(): WebGLQuery;
  43546. /**
  43547. * Delete and release a webGL query
  43548. * @param query defines the query to delete
  43549. * @return the current engine
  43550. */
  43551. deleteQuery(query: WebGLQuery): Engine;
  43552. /**
  43553. * Check if a given query has resolved and got its value
  43554. * @param query defines the query to check
  43555. * @returns true if the query got its value
  43556. */
  43557. isQueryResultAvailable(query: WebGLQuery): boolean;
  43558. /**
  43559. * Gets the value of a given query
  43560. * @param query defines the query to check
  43561. * @returns the value of the query
  43562. */
  43563. getQueryResult(query: WebGLQuery): number;
  43564. /**
  43565. * Initiates an occlusion query
  43566. * @param algorithmType defines the algorithm to use
  43567. * @param query defines the query to use
  43568. * @returns the current engine
  43569. * @see http://doc.babylonjs.com/features/occlusionquery
  43570. */
  43571. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43572. /**
  43573. * Ends an occlusion query
  43574. * @see http://doc.babylonjs.com/features/occlusionquery
  43575. * @param algorithmType defines the algorithm to use
  43576. * @returns the current engine
  43577. */
  43578. endOcclusionQuery(algorithmType: number): Engine;
  43579. /**
  43580. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43581. * Please note that only one query can be issued at a time
  43582. * @returns a time token used to track the time span
  43583. */
  43584. startTimeQuery(): Nullable<_TimeToken>;
  43585. /**
  43586. * Ends a time query
  43587. * @param token defines the token used to measure the time span
  43588. * @returns the time spent (in ns)
  43589. */
  43590. endTimeQuery(token: _TimeToken): int;
  43591. /** @hidden */
  43592. _currentNonTimestampToken: Nullable<_TimeToken>;
  43593. /** @hidden */
  43594. _createTimeQuery(): WebGLQuery;
  43595. /** @hidden */
  43596. _deleteTimeQuery(query: WebGLQuery): void;
  43597. /** @hidden */
  43598. _getGlAlgorithmType(algorithmType: number): number;
  43599. /** @hidden */
  43600. _getTimeQueryResult(query: WebGLQuery): any;
  43601. /** @hidden */
  43602. _getTimeQueryAvailability(query: WebGLQuery): any;
  43603. }
  43604. interface AbstractMesh {
  43605. /**
  43606. * Backing filed
  43607. * @hidden
  43608. */
  43609. __occlusionDataStorage: _OcclusionDataStorage;
  43610. /**
  43611. * Access property
  43612. * @hidden
  43613. */
  43614. _occlusionDataStorage: _OcclusionDataStorage;
  43615. /**
  43616. * 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.
  43617. * The default value is -1 which means don't break the query and wait till the result
  43618. * @see http://doc.babylonjs.com/features/occlusionquery
  43619. */
  43620. occlusionRetryCount: number;
  43621. /**
  43622. * 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:
  43623. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43624. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43625. * * 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.
  43626. * @see http://doc.babylonjs.com/features/occlusionquery
  43627. */
  43628. occlusionType: number;
  43629. /**
  43630. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43631. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43632. * * 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.
  43633. * @see http://doc.babylonjs.com/features/occlusionquery
  43634. */
  43635. occlusionQueryAlgorithmType: number;
  43636. /**
  43637. * 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
  43638. * @see http://doc.babylonjs.com/features/occlusionquery
  43639. */
  43640. isOccluded: boolean;
  43641. /**
  43642. * Flag to check the progress status of the query
  43643. * @see http://doc.babylonjs.com/features/occlusionquery
  43644. */
  43645. isOcclusionQueryInProgress: boolean;
  43646. }
  43647. }
  43648. declare module BABYLON {
  43649. /** @hidden */
  43650. export var _forceTransformFeedbackToBundle: boolean;
  43651. interface Engine {
  43652. /**
  43653. * Creates a webGL transform feedback object
  43654. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43655. * @returns the webGL transform feedback object
  43656. */
  43657. createTransformFeedback(): WebGLTransformFeedback;
  43658. /**
  43659. * Delete a webGL transform feedback object
  43660. * @param value defines the webGL transform feedback object to delete
  43661. */
  43662. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43663. /**
  43664. * Bind a webGL transform feedback object to the webgl context
  43665. * @param value defines the webGL transform feedback object to bind
  43666. */
  43667. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43668. /**
  43669. * Begins a transform feedback operation
  43670. * @param usePoints defines if points or triangles must be used
  43671. */
  43672. beginTransformFeedback(usePoints: boolean): void;
  43673. /**
  43674. * Ends a transform feedback operation
  43675. */
  43676. endTransformFeedback(): void;
  43677. /**
  43678. * Specify the varyings to use with transform feedback
  43679. * @param program defines the associated webGL program
  43680. * @param value defines the list of strings representing the varying names
  43681. */
  43682. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43683. /**
  43684. * Bind a webGL buffer for a transform feedback operation
  43685. * @param value defines the webGL buffer to bind
  43686. */
  43687. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43688. }
  43689. }
  43690. declare module BABYLON {
  43691. /**
  43692. * Creation options of the multi render target texture.
  43693. */
  43694. export interface IMultiRenderTargetOptions {
  43695. /**
  43696. * Define if the texture needs to create mip maps after render.
  43697. */
  43698. generateMipMaps?: boolean;
  43699. /**
  43700. * Define the types of all the draw buffers we want to create
  43701. */
  43702. types?: number[];
  43703. /**
  43704. * Define the sampling modes of all the draw buffers we want to create
  43705. */
  43706. samplingModes?: number[];
  43707. /**
  43708. * Define if a depth buffer is required
  43709. */
  43710. generateDepthBuffer?: boolean;
  43711. /**
  43712. * Define if a stencil buffer is required
  43713. */
  43714. generateStencilBuffer?: boolean;
  43715. /**
  43716. * Define if a depth texture is required instead of a depth buffer
  43717. */
  43718. generateDepthTexture?: boolean;
  43719. /**
  43720. * Define the number of desired draw buffers
  43721. */
  43722. textureCount?: number;
  43723. /**
  43724. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43725. */
  43726. doNotChangeAspectRatio?: boolean;
  43727. /**
  43728. * Define the default type of the buffers we are creating
  43729. */
  43730. defaultType?: number;
  43731. }
  43732. /**
  43733. * A multi render target, like a render target provides the ability to render to a texture.
  43734. * Unlike the render target, it can render to several draw buffers in one draw.
  43735. * This is specially interesting in deferred rendering or for any effects requiring more than
  43736. * just one color from a single pass.
  43737. */
  43738. export class MultiRenderTarget extends RenderTargetTexture {
  43739. private _internalTextures;
  43740. private _textures;
  43741. private _multiRenderTargetOptions;
  43742. /**
  43743. * Get if draw buffers are currently supported by the used hardware and browser.
  43744. */
  43745. readonly isSupported: boolean;
  43746. /**
  43747. * Get the list of textures generated by the multi render target.
  43748. */
  43749. readonly textures: Texture[];
  43750. /**
  43751. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43752. */
  43753. readonly depthTexture: Texture;
  43754. /**
  43755. * Set the wrapping mode on U of all the textures we are rendering to.
  43756. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43757. */
  43758. wrapU: number;
  43759. /**
  43760. * Set the wrapping mode on V of all the textures we are rendering to.
  43761. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43762. */
  43763. wrapV: number;
  43764. /**
  43765. * Instantiate a new multi render target texture.
  43766. * A multi render target, like a render target provides the ability to render to a texture.
  43767. * Unlike the render target, it can render to several draw buffers in one draw.
  43768. * This is specially interesting in deferred rendering or for any effects requiring more than
  43769. * just one color from a single pass.
  43770. * @param name Define the name of the texture
  43771. * @param size Define the size of the buffers to render to
  43772. * @param count Define the number of target we are rendering into
  43773. * @param scene Define the scene the texture belongs to
  43774. * @param options Define the options used to create the multi render target
  43775. */
  43776. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43777. /** @hidden */
  43778. _rebuild(): void;
  43779. private _createInternalTextures;
  43780. private _createTextures;
  43781. /**
  43782. * Define the number of samples used if MSAA is enabled.
  43783. */
  43784. samples: number;
  43785. /**
  43786. * Resize all the textures in the multi render target.
  43787. * Be carrefull as it will recreate all the data in the new texture.
  43788. * @param size Define the new size
  43789. */
  43790. resize(size: any): void;
  43791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43792. /**
  43793. * Dispose the render targets and their associated resources
  43794. */
  43795. dispose(): void;
  43796. /**
  43797. * Release all the underlying texture used as draw buffers.
  43798. */
  43799. releaseInternalTextures(): void;
  43800. }
  43801. }
  43802. declare module BABYLON {
  43803. interface Engine {
  43804. /**
  43805. * Unbind a list of render target textures from the webGL context
  43806. * This is used only when drawBuffer extension or webGL2 are active
  43807. * @param textures defines the render target textures to unbind
  43808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43810. */
  43811. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43812. /**
  43813. * Create a multi render target texture
  43814. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43815. * @param size defines the size of the texture
  43816. * @param options defines the creation options
  43817. * @returns the cube texture as an InternalTexture
  43818. */
  43819. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43820. /**
  43821. * Update the sample count for a given multiple render target texture
  43822. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43823. * @param textures defines the textures to update
  43824. * @param samples defines the sample count to set
  43825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43826. */
  43827. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43828. }
  43829. }
  43830. declare module BABYLON {
  43831. /** @hidden */
  43832. export var rgbdEncodePixelShader: {
  43833. name: string;
  43834. shader: string;
  43835. };
  43836. }
  43837. declare module BABYLON {
  43838. /** @hidden */
  43839. export var rgbdDecodePixelShader: {
  43840. name: string;
  43841. shader: string;
  43842. };
  43843. }
  43844. declare module BABYLON {
  43845. /**
  43846. * Raw texture data and descriptor sufficient for WebGL texture upload
  43847. */
  43848. export interface EnvironmentTextureInfo {
  43849. /**
  43850. * Version of the environment map
  43851. */
  43852. version: number;
  43853. /**
  43854. * Width of image
  43855. */
  43856. width: number;
  43857. /**
  43858. * Irradiance information stored in the file.
  43859. */
  43860. irradiance: any;
  43861. /**
  43862. * Specular information stored in the file.
  43863. */
  43864. specular: any;
  43865. }
  43866. /**
  43867. * Defines One Image in the file. It requires only the position in the file
  43868. * as well as the length.
  43869. */
  43870. interface BufferImageData {
  43871. /**
  43872. * Length of the image data.
  43873. */
  43874. length: number;
  43875. /**
  43876. * Position of the data from the null terminator delimiting the end of the JSON.
  43877. */
  43878. position: number;
  43879. }
  43880. /**
  43881. * Defines the specular data enclosed in the file.
  43882. * This corresponds to the version 1 of the data.
  43883. */
  43884. export interface EnvironmentTextureSpecularInfoV1 {
  43885. /**
  43886. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43887. */
  43888. specularDataPosition?: number;
  43889. /**
  43890. * This contains all the images data needed to reconstruct the cubemap.
  43891. */
  43892. mipmaps: Array<BufferImageData>;
  43893. /**
  43894. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43895. */
  43896. lodGenerationScale: number;
  43897. }
  43898. /**
  43899. * Sets of helpers addressing the serialization and deserialization of environment texture
  43900. * stored in a BabylonJS env file.
  43901. * Those files are usually stored as .env files.
  43902. */
  43903. export class EnvironmentTextureTools {
  43904. /**
  43905. * Magic number identifying the env file.
  43906. */
  43907. private static _MagicBytes;
  43908. /**
  43909. * Gets the environment info from an env file.
  43910. * @param data The array buffer containing the .env bytes.
  43911. * @returns the environment file info (the json header) if successfully parsed.
  43912. */
  43913. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43914. /**
  43915. * Creates an environment texture from a loaded cube texture.
  43916. * @param texture defines the cube texture to convert in env file
  43917. * @return a promise containing the environment data if succesfull.
  43918. */
  43919. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43920. /**
  43921. * Creates a JSON representation of the spherical data.
  43922. * @param texture defines the texture containing the polynomials
  43923. * @return the JSON representation of the spherical info
  43924. */
  43925. private static _CreateEnvTextureIrradiance;
  43926. /**
  43927. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43928. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43929. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43930. * @return the views described by info providing access to the underlying buffer
  43931. */
  43932. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43933. /**
  43934. * Uploads the texture info contained in the env file to the GPU.
  43935. * @param texture defines the internal texture to upload to
  43936. * @param arrayBuffer defines the buffer cotaining the data to load
  43937. * @param info defines the texture info retrieved through the GetEnvInfo method
  43938. * @returns a promise
  43939. */
  43940. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43941. /**
  43942. * Uploads the levels of image data to the GPU.
  43943. * @param texture defines the internal texture to upload to
  43944. * @param imageData defines the array buffer views of image data [mipmap][face]
  43945. * @returns a promise
  43946. */
  43947. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43948. /**
  43949. * Uploads spherical polynomials information to the texture.
  43950. * @param texture defines the texture we are trying to upload the information to
  43951. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43952. */
  43953. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43954. /** @hidden */
  43955. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43956. }
  43957. }
  43958. declare module BABYLON {
  43959. /**
  43960. * Contains position and normal vectors for a vertex
  43961. */
  43962. export class PositionNormalVertex {
  43963. /** the position of the vertex (defaut: 0,0,0) */
  43964. position: Vector3;
  43965. /** the normal of the vertex (defaut: 0,1,0) */
  43966. normal: Vector3;
  43967. /**
  43968. * Creates a PositionNormalVertex
  43969. * @param position the position of the vertex (defaut: 0,0,0)
  43970. * @param normal the normal of the vertex (defaut: 0,1,0)
  43971. */
  43972. constructor(
  43973. /** the position of the vertex (defaut: 0,0,0) */
  43974. position?: Vector3,
  43975. /** the normal of the vertex (defaut: 0,1,0) */
  43976. normal?: Vector3);
  43977. /**
  43978. * Clones the PositionNormalVertex
  43979. * @returns the cloned PositionNormalVertex
  43980. */
  43981. clone(): PositionNormalVertex;
  43982. }
  43983. /**
  43984. * Contains position, normal and uv vectors for a vertex
  43985. */
  43986. export class PositionNormalTextureVertex {
  43987. /** the position of the vertex (defaut: 0,0,0) */
  43988. position: Vector3;
  43989. /** the normal of the vertex (defaut: 0,1,0) */
  43990. normal: Vector3;
  43991. /** the uv of the vertex (default: 0,0) */
  43992. uv: Vector2;
  43993. /**
  43994. * Creates a PositionNormalTextureVertex
  43995. * @param position the position of the vertex (defaut: 0,0,0)
  43996. * @param normal the normal of the vertex (defaut: 0,1,0)
  43997. * @param uv the uv of the vertex (default: 0,0)
  43998. */
  43999. constructor(
  44000. /** the position of the vertex (defaut: 0,0,0) */
  44001. position?: Vector3,
  44002. /** the normal of the vertex (defaut: 0,1,0) */
  44003. normal?: Vector3,
  44004. /** the uv of the vertex (default: 0,0) */
  44005. uv?: Vector2);
  44006. /**
  44007. * Clones the PositionNormalTextureVertex
  44008. * @returns the cloned PositionNormalTextureVertex
  44009. */
  44010. clone(): PositionNormalTextureVertex;
  44011. }
  44012. }
  44013. declare module BABYLON {
  44014. /** @hidden */
  44015. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44016. private _genericAttributeLocation;
  44017. private _varyingLocationCount;
  44018. private _varyingLocationMap;
  44019. private _replacements;
  44020. private _textureCount;
  44021. private _uniforms;
  44022. lineProcessor(line: string): string;
  44023. attributeProcessor(attribute: string): string;
  44024. varyingProcessor(varying: string, isFragment: boolean): string;
  44025. uniformProcessor(uniform: string): string;
  44026. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44027. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44028. }
  44029. }
  44030. declare module BABYLON {
  44031. /**
  44032. * Container for accessors for natively-stored mesh data buffers.
  44033. */
  44034. class NativeDataBuffer extends DataBuffer {
  44035. /**
  44036. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44037. */
  44038. nativeIndexBuffer?: any;
  44039. /**
  44040. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44041. */
  44042. nativeVertexBuffer?: any;
  44043. }
  44044. /** @hidden */
  44045. export class NativeEngine extends Engine {
  44046. private readonly _native;
  44047. getHardwareScalingLevel(): number;
  44048. constructor();
  44049. /**
  44050. * Can be used to override the current requestAnimationFrame requester.
  44051. * @hidden
  44052. */
  44053. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44054. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44055. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44056. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44057. recordVertexArrayObject(vertexBuffers: {
  44058. [key: string]: VertexBuffer;
  44059. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44060. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44061. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44062. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44063. /**
  44064. * Draw a list of indexed primitives
  44065. * @param fillMode defines the primitive to use
  44066. * @param indexStart defines the starting index
  44067. * @param indexCount defines the number of index to draw
  44068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44069. */
  44070. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44071. /**
  44072. * Draw a list of unindexed primitives
  44073. * @param fillMode defines the primitive to use
  44074. * @param verticesStart defines the index of first vertex to draw
  44075. * @param verticesCount defines the count of vertices to draw
  44076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44077. */
  44078. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44079. createPipelineContext(): IPipelineContext;
  44080. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44081. /** @hidden */
  44082. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44083. /** @hidden */
  44084. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44086. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44087. protected _setProgram(program: WebGLProgram): void;
  44088. _releaseEffect(effect: Effect): void;
  44089. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44090. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44091. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44092. bindSamplers(effect: Effect): void;
  44093. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44094. getRenderWidth(useScreen?: boolean): number;
  44095. getRenderHeight(useScreen?: boolean): number;
  44096. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44097. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44098. /**
  44099. * Set the z offset to apply to current rendering
  44100. * @param value defines the offset to apply
  44101. */
  44102. setZOffset(value: number): void;
  44103. /**
  44104. * Gets the current value of the zOffset
  44105. * @returns the current zOffset state
  44106. */
  44107. getZOffset(): number;
  44108. /**
  44109. * Enable or disable depth buffering
  44110. * @param enable defines the state to set
  44111. */
  44112. setDepthBuffer(enable: boolean): void;
  44113. /**
  44114. * Gets a boolean indicating if depth writing is enabled
  44115. * @returns the current depth writing state
  44116. */
  44117. getDepthWrite(): boolean;
  44118. /**
  44119. * Enable or disable depth writing
  44120. * @param enable defines the state to set
  44121. */
  44122. setDepthWrite(enable: boolean): void;
  44123. /**
  44124. * Enable or disable color writing
  44125. * @param enable defines the state to set
  44126. */
  44127. setColorWrite(enable: boolean): void;
  44128. /**
  44129. * Gets a boolean indicating if color writing is enabled
  44130. * @returns the current color writing state
  44131. */
  44132. getColorWrite(): boolean;
  44133. /**
  44134. * Sets alpha constants used by some alpha blending modes
  44135. * @param r defines the red component
  44136. * @param g defines the green component
  44137. * @param b defines the blue component
  44138. * @param a defines the alpha component
  44139. */
  44140. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44141. /**
  44142. * Sets the current alpha mode
  44143. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44144. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44145. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44146. */
  44147. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44148. /**
  44149. * Gets the current alpha mode
  44150. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44151. * @returns the current alpha mode
  44152. */
  44153. getAlphaMode(): number;
  44154. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44155. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44156. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44157. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44158. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44159. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44160. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44161. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44162. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44163. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44164. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44165. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44166. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44167. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44168. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44169. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44170. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44171. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44172. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44173. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44174. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44175. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44176. wipeCaches(bruteForce?: boolean): void;
  44177. _createTexture(): WebGLTexture;
  44178. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44179. /**
  44180. * Usually called from BABYLON.Texture.ts.
  44181. * Passed information to create a WebGLTexture
  44182. * @param urlArg defines a value which contains one of the following:
  44183. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44184. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44185. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44186. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44187. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44188. * @param scene needed for loading to the correct scene
  44189. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44190. * @param onLoad optional callback to be called upon successful completion
  44191. * @param onError optional callback to be called upon failure
  44192. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44193. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44194. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44195. * @param forcedExtension defines the extension to use to pick the right loader
  44196. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44197. */
  44198. 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;
  44199. /**
  44200. * Creates a cube texture
  44201. * @param rootUrl defines the url where the files to load is located
  44202. * @param scene defines the current scene
  44203. * @param files defines the list of files to load (1 per face)
  44204. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44205. * @param onLoad defines an optional callback raised when the texture is loaded
  44206. * @param onError defines an optional callback raised if there is an issue to load the texture
  44207. * @param format defines the format of the data
  44208. * @param forcedExtension defines the extension to use to pick the right loader
  44209. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44210. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44211. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44212. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44213. * @returns the cube texture as an InternalTexture
  44214. */
  44215. 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;
  44216. private _getSamplingFilter;
  44217. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44218. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44219. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44220. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44221. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44222. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44223. /**
  44224. * Updates a dynamic vertex buffer.
  44225. * @param vertexBuffer the vertex buffer to update
  44226. * @param data the data used to update the vertex buffer
  44227. * @param byteOffset the byte offset of the data (optional)
  44228. * @param byteLength the byte length of the data (optional)
  44229. */
  44230. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44231. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44232. private _updateAnisotropicLevel;
  44233. private _getAddressMode;
  44234. /** @hidden */
  44235. _bindTexture(channel: number, texture: InternalTexture): void;
  44236. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44237. releaseEffects(): void;
  44238. /** @hidden */
  44239. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44240. /** @hidden */
  44241. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44242. /** @hidden */
  44243. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44244. /** @hidden */
  44245. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44246. }
  44247. }
  44248. declare module BABYLON {
  44249. /**
  44250. * Gather the list of clipboard event types as constants.
  44251. */
  44252. export class ClipboardEventTypes {
  44253. /**
  44254. * The clipboard event is fired when a copy command is active (pressed).
  44255. */
  44256. static readonly COPY: number;
  44257. /**
  44258. * The clipboard event is fired when a cut command is active (pressed).
  44259. */
  44260. static readonly CUT: number;
  44261. /**
  44262. * The clipboard event is fired when a paste command is active (pressed).
  44263. */
  44264. static readonly PASTE: number;
  44265. }
  44266. /**
  44267. * This class is used to store clipboard related info for the onClipboardObservable event.
  44268. */
  44269. export class ClipboardInfo {
  44270. /**
  44271. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44272. */
  44273. type: number;
  44274. /**
  44275. * Defines the related dom event
  44276. */
  44277. event: ClipboardEvent;
  44278. /**
  44279. *Creates an instance of ClipboardInfo.
  44280. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44281. * @param event Defines the related dom event
  44282. */
  44283. constructor(
  44284. /**
  44285. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44286. */
  44287. type: number,
  44288. /**
  44289. * Defines the related dom event
  44290. */
  44291. event: ClipboardEvent);
  44292. /**
  44293. * Get the clipboard event's type from the keycode.
  44294. * @param keyCode Defines the keyCode for the current keyboard event.
  44295. * @return {number}
  44296. */
  44297. static GetTypeFromCharacter(keyCode: number): number;
  44298. }
  44299. }
  44300. declare module BABYLON {
  44301. /**
  44302. * Google Daydream controller
  44303. */
  44304. export class DaydreamController extends WebVRController {
  44305. /**
  44306. * Base Url for the controller model.
  44307. */
  44308. static MODEL_BASE_URL: string;
  44309. /**
  44310. * File name for the controller model.
  44311. */
  44312. static MODEL_FILENAME: string;
  44313. /**
  44314. * Gamepad Id prefix used to identify Daydream Controller.
  44315. */
  44316. static readonly GAMEPAD_ID_PREFIX: string;
  44317. /**
  44318. * Creates a new DaydreamController from a gamepad
  44319. * @param vrGamepad the gamepad that the controller should be created from
  44320. */
  44321. constructor(vrGamepad: any);
  44322. /**
  44323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44324. * @param scene scene in which to add meshes
  44325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44326. */
  44327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44328. /**
  44329. * Called once for each button that changed state since the last frame
  44330. * @param buttonIdx Which button index changed
  44331. * @param state New state of the button
  44332. * @param changes Which properties on the state changed since last frame
  44333. */
  44334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44335. }
  44336. }
  44337. declare module BABYLON {
  44338. /**
  44339. * Gear VR Controller
  44340. */
  44341. export class GearVRController extends WebVRController {
  44342. /**
  44343. * Base Url for the controller model.
  44344. */
  44345. static MODEL_BASE_URL: string;
  44346. /**
  44347. * File name for the controller model.
  44348. */
  44349. static MODEL_FILENAME: string;
  44350. /**
  44351. * Gamepad Id prefix used to identify this controller.
  44352. */
  44353. static readonly GAMEPAD_ID_PREFIX: string;
  44354. private readonly _buttonIndexToObservableNameMap;
  44355. /**
  44356. * Creates a new GearVRController from a gamepad
  44357. * @param vrGamepad the gamepad that the controller should be created from
  44358. */
  44359. constructor(vrGamepad: any);
  44360. /**
  44361. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44362. * @param scene scene in which to add meshes
  44363. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44364. */
  44365. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44366. /**
  44367. * Called once for each button that changed state since the last frame
  44368. * @param buttonIdx Which button index changed
  44369. * @param state New state of the button
  44370. * @param changes Which properties on the state changed since last frame
  44371. */
  44372. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44373. }
  44374. }
  44375. declare module BABYLON {
  44376. /**
  44377. * Class containing static functions to help procedurally build meshes
  44378. */
  44379. export class PolyhedronBuilder {
  44380. /**
  44381. * Creates a polyhedron mesh
  44382. * * 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
  44383. * * The parameter `size` (positive float, default 1) sets the polygon size
  44384. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44385. * * 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`
  44386. * * 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
  44387. * * 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)`)
  44388. * * 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
  44389. * * 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
  44390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44391. * * 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
  44392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44393. * @param name defines the name of the mesh
  44394. * @param options defines the options used to create the mesh
  44395. * @param scene defines the hosting scene
  44396. * @returns the polyhedron mesh
  44397. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44398. */
  44399. static CreatePolyhedron(name: string, options: {
  44400. type?: number;
  44401. size?: number;
  44402. sizeX?: number;
  44403. sizeY?: number;
  44404. sizeZ?: number;
  44405. custom?: any;
  44406. faceUV?: Vector4[];
  44407. faceColors?: Color4[];
  44408. flat?: boolean;
  44409. updatable?: boolean;
  44410. sideOrientation?: number;
  44411. frontUVs?: Vector4;
  44412. backUVs?: Vector4;
  44413. }, scene?: Nullable<Scene>): Mesh;
  44414. }
  44415. }
  44416. declare module BABYLON {
  44417. /**
  44418. * Gizmo that enables scaling a mesh along 3 axis
  44419. */
  44420. export class ScaleGizmo extends Gizmo {
  44421. /**
  44422. * Internal gizmo used for interactions on the x axis
  44423. */
  44424. xGizmo: AxisScaleGizmo;
  44425. /**
  44426. * Internal gizmo used for interactions on the y axis
  44427. */
  44428. yGizmo: AxisScaleGizmo;
  44429. /**
  44430. * Internal gizmo used for interactions on the z axis
  44431. */
  44432. zGizmo: AxisScaleGizmo;
  44433. /**
  44434. * Internal gizmo used to scale all axis equally
  44435. */
  44436. uniformScaleGizmo: AxisScaleGizmo;
  44437. private _meshAttached;
  44438. private _updateGizmoRotationToMatchAttachedMesh;
  44439. private _snapDistance;
  44440. private _scaleRatio;
  44441. private _uniformScalingMesh;
  44442. private _octahedron;
  44443. /** Fires an event when any of it's sub gizmos are dragged */
  44444. onDragStartObservable: Observable<unknown>;
  44445. /** Fires an event when any of it's sub gizmos are released from dragging */
  44446. onDragEndObservable: Observable<unknown>;
  44447. attachedMesh: Nullable<AbstractMesh>;
  44448. /**
  44449. * Creates a ScaleGizmo
  44450. * @param gizmoLayer The utility layer the gizmo will be added to
  44451. */
  44452. constructor(gizmoLayer?: UtilityLayerRenderer);
  44453. updateGizmoRotationToMatchAttachedMesh: boolean;
  44454. /**
  44455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44456. */
  44457. snapDistance: number;
  44458. /**
  44459. * Ratio for the scale of the gizmo (Default: 1)
  44460. */
  44461. scaleRatio: number;
  44462. /**
  44463. * Disposes of the gizmo
  44464. */
  44465. dispose(): void;
  44466. }
  44467. }
  44468. declare module BABYLON {
  44469. /**
  44470. * Single axis scale gizmo
  44471. */
  44472. export class AxisScaleGizmo extends Gizmo {
  44473. /**
  44474. * Drag behavior responsible for the gizmos dragging interactions
  44475. */
  44476. dragBehavior: PointerDragBehavior;
  44477. private _pointerObserver;
  44478. /**
  44479. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44480. */
  44481. snapDistance: number;
  44482. /**
  44483. * Event that fires each time the gizmo snaps to a new location.
  44484. * * snapDistance is the the change in distance
  44485. */
  44486. onSnapObservable: Observable<{
  44487. snapDistance: number;
  44488. }>;
  44489. /**
  44490. * If the scaling operation should be done on all axis (default: false)
  44491. */
  44492. uniformScaling: boolean;
  44493. private _isEnabled;
  44494. private _parent;
  44495. private _arrow;
  44496. private _coloredMaterial;
  44497. private _hoverMaterial;
  44498. /**
  44499. * Creates an AxisScaleGizmo
  44500. * @param gizmoLayer The utility layer the gizmo will be added to
  44501. * @param dragAxis The axis which the gizmo will be able to scale on
  44502. * @param color The color of the gizmo
  44503. */
  44504. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44505. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44506. /**
  44507. * If the gizmo is enabled
  44508. */
  44509. isEnabled: boolean;
  44510. /**
  44511. * Disposes of the gizmo
  44512. */
  44513. dispose(): void;
  44514. /**
  44515. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44516. * @param mesh The mesh to replace the default mesh of the gizmo
  44517. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44518. */
  44519. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44520. }
  44521. }
  44522. declare module BABYLON {
  44523. /**
  44524. * Bounding box gizmo
  44525. */
  44526. export class BoundingBoxGizmo extends Gizmo {
  44527. private _lineBoundingBox;
  44528. private _rotateSpheresParent;
  44529. private _scaleBoxesParent;
  44530. private _boundingDimensions;
  44531. private _renderObserver;
  44532. private _pointerObserver;
  44533. private _scaleDragSpeed;
  44534. private _tmpQuaternion;
  44535. private _tmpVector;
  44536. private _tmpRotationMatrix;
  44537. /**
  44538. * 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)
  44539. */
  44540. ignoreChildren: boolean;
  44541. /**
  44542. * 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)
  44543. */
  44544. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44545. /**
  44546. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44547. */
  44548. rotationSphereSize: number;
  44549. /**
  44550. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44551. */
  44552. scaleBoxSize: number;
  44553. /**
  44554. * 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)
  44555. */
  44556. fixedDragMeshScreenSize: boolean;
  44557. /**
  44558. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44559. */
  44560. fixedDragMeshScreenSizeDistanceFactor: number;
  44561. /**
  44562. * Fired when a rotation sphere or scale box is dragged
  44563. */
  44564. onDragStartObservable: Observable<{}>;
  44565. /**
  44566. * Fired when a scale box is dragged
  44567. */
  44568. onScaleBoxDragObservable: Observable<{}>;
  44569. /**
  44570. * Fired when a scale box drag is ended
  44571. */
  44572. onScaleBoxDragEndObservable: Observable<{}>;
  44573. /**
  44574. * Fired when a rotation sphere is dragged
  44575. */
  44576. onRotationSphereDragObservable: Observable<{}>;
  44577. /**
  44578. * Fired when a rotation sphere drag is ended
  44579. */
  44580. onRotationSphereDragEndObservable: Observable<{}>;
  44581. /**
  44582. * 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)
  44583. */
  44584. scalePivot: Nullable<Vector3>;
  44585. /**
  44586. * Mesh used as a pivot to rotate the attached mesh
  44587. */
  44588. private _anchorMesh;
  44589. private _existingMeshScale;
  44590. private _dragMesh;
  44591. private pointerDragBehavior;
  44592. private coloredMaterial;
  44593. private hoverColoredMaterial;
  44594. /**
  44595. * Sets the color of the bounding box gizmo
  44596. * @param color the color to set
  44597. */
  44598. setColor(color: Color3): void;
  44599. /**
  44600. * Creates an BoundingBoxGizmo
  44601. * @param gizmoLayer The utility layer the gizmo will be added to
  44602. * @param color The color of the gizmo
  44603. */
  44604. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44606. private _selectNode;
  44607. /**
  44608. * Updates the bounding box information for the Gizmo
  44609. */
  44610. updateBoundingBox(): void;
  44611. private _updateRotationSpheres;
  44612. private _updateScaleBoxes;
  44613. /**
  44614. * Enables rotation on the specified axis and disables rotation on the others
  44615. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44616. */
  44617. setEnabledRotationAxis(axis: string): void;
  44618. /**
  44619. * Enables/disables scaling
  44620. * @param enable if scaling should be enabled
  44621. */
  44622. setEnabledScaling(enable: boolean): void;
  44623. private _updateDummy;
  44624. /**
  44625. * Enables a pointer drag behavior on the bounding box of the gizmo
  44626. */
  44627. enableDragBehavior(): void;
  44628. /**
  44629. * Disposes of the gizmo
  44630. */
  44631. dispose(): void;
  44632. /**
  44633. * 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)
  44634. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44635. * @returns the bounding box mesh with the passed in mesh as a child
  44636. */
  44637. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44638. /**
  44639. * CustomMeshes are not supported by this gizmo
  44640. * @param mesh The mesh to replace the default mesh of the gizmo
  44641. */
  44642. setCustomMesh(mesh: Mesh): void;
  44643. }
  44644. }
  44645. declare module BABYLON {
  44646. /**
  44647. * Single plane rotation gizmo
  44648. */
  44649. export class PlaneRotationGizmo extends Gizmo {
  44650. /**
  44651. * Drag behavior responsible for the gizmos dragging interactions
  44652. */
  44653. dragBehavior: PointerDragBehavior;
  44654. private _pointerObserver;
  44655. /**
  44656. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44657. */
  44658. snapDistance: number;
  44659. /**
  44660. * Event that fires each time the gizmo snaps to a new location.
  44661. * * snapDistance is the the change in distance
  44662. */
  44663. onSnapObservable: Observable<{
  44664. snapDistance: number;
  44665. }>;
  44666. private _isEnabled;
  44667. private _parent;
  44668. /**
  44669. * Creates a PlaneRotationGizmo
  44670. * @param gizmoLayer The utility layer the gizmo will be added to
  44671. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44672. * @param color The color of the gizmo
  44673. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44674. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44675. */
  44676. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44677. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44678. /**
  44679. * If the gizmo is enabled
  44680. */
  44681. isEnabled: boolean;
  44682. /**
  44683. * Disposes of the gizmo
  44684. */
  44685. dispose(): void;
  44686. }
  44687. }
  44688. declare module BABYLON {
  44689. /**
  44690. * Gizmo that enables rotating a mesh along 3 axis
  44691. */
  44692. export class RotationGizmo extends Gizmo {
  44693. /**
  44694. * Internal gizmo used for interactions on the x axis
  44695. */
  44696. xGizmo: PlaneRotationGizmo;
  44697. /**
  44698. * Internal gizmo used for interactions on the y axis
  44699. */
  44700. yGizmo: PlaneRotationGizmo;
  44701. /**
  44702. * Internal gizmo used for interactions on the z axis
  44703. */
  44704. zGizmo: PlaneRotationGizmo;
  44705. /** Fires an event when any of it's sub gizmos are dragged */
  44706. onDragStartObservable: Observable<unknown>;
  44707. /** Fires an event when any of it's sub gizmos are released from dragging */
  44708. onDragEndObservable: Observable<unknown>;
  44709. private _meshAttached;
  44710. attachedMesh: Nullable<AbstractMesh>;
  44711. /**
  44712. * Creates a RotationGizmo
  44713. * @param gizmoLayer The utility layer the gizmo will be added to
  44714. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44715. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44716. */
  44717. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44718. updateGizmoRotationToMatchAttachedMesh: boolean;
  44719. /**
  44720. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44721. */
  44722. snapDistance: number;
  44723. /**
  44724. * Ratio for the scale of the gizmo (Default: 1)
  44725. */
  44726. scaleRatio: number;
  44727. /**
  44728. * Disposes of the gizmo
  44729. */
  44730. dispose(): void;
  44731. /**
  44732. * CustomMeshes are not supported by this gizmo
  44733. * @param mesh The mesh to replace the default mesh of the gizmo
  44734. */
  44735. setCustomMesh(mesh: Mesh): void;
  44736. }
  44737. }
  44738. declare module BABYLON {
  44739. /**
  44740. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44741. */
  44742. export class GizmoManager implements IDisposable {
  44743. private scene;
  44744. /**
  44745. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44746. */
  44747. gizmos: {
  44748. positionGizmo: Nullable<PositionGizmo>;
  44749. rotationGizmo: Nullable<RotationGizmo>;
  44750. scaleGizmo: Nullable<ScaleGizmo>;
  44751. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44752. };
  44753. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44754. clearGizmoOnEmptyPointerEvent: boolean;
  44755. /** Fires an event when the manager is attached to a mesh */
  44756. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44757. private _gizmosEnabled;
  44758. private _pointerObserver;
  44759. private _attachedMesh;
  44760. private _boundingBoxColor;
  44761. private _defaultUtilityLayer;
  44762. private _defaultKeepDepthUtilityLayer;
  44763. /**
  44764. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44765. */
  44766. boundingBoxDragBehavior: SixDofDragBehavior;
  44767. /**
  44768. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44769. */
  44770. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44771. /**
  44772. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44773. */
  44774. usePointerToAttachGizmos: boolean;
  44775. /**
  44776. * Utility layer that the bounding box gizmo belongs to
  44777. */
  44778. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44779. /**
  44780. * Utility layer that all gizmos besides bounding box belong to
  44781. */
  44782. readonly utilityLayer: UtilityLayerRenderer;
  44783. /**
  44784. * Instatiates a gizmo manager
  44785. * @param scene the scene to overlay the gizmos on top of
  44786. */
  44787. constructor(scene: Scene);
  44788. /**
  44789. * Attaches a set of gizmos to the specified mesh
  44790. * @param mesh The mesh the gizmo's should be attached to
  44791. */
  44792. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44793. /**
  44794. * If the position gizmo is enabled
  44795. */
  44796. positionGizmoEnabled: boolean;
  44797. /**
  44798. * If the rotation gizmo is enabled
  44799. */
  44800. rotationGizmoEnabled: boolean;
  44801. /**
  44802. * If the scale gizmo is enabled
  44803. */
  44804. scaleGizmoEnabled: boolean;
  44805. /**
  44806. * If the boundingBox gizmo is enabled
  44807. */
  44808. boundingBoxGizmoEnabled: boolean;
  44809. /**
  44810. * Disposes of the gizmo manager
  44811. */
  44812. dispose(): void;
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * A directional light is defined by a direction (what a surprise!).
  44818. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44819. * 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.
  44820. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44821. */
  44822. export class DirectionalLight extends ShadowLight {
  44823. private _shadowFrustumSize;
  44824. /**
  44825. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44826. */
  44827. /**
  44828. * Specifies a fix frustum size for the shadow generation.
  44829. */
  44830. shadowFrustumSize: number;
  44831. private _shadowOrthoScale;
  44832. /**
  44833. * Gets the shadow projection scale against the optimal computed one.
  44834. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44835. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44836. */
  44837. /**
  44838. * Sets the shadow projection scale against the optimal computed one.
  44839. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44840. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44841. */
  44842. shadowOrthoScale: number;
  44843. /**
  44844. * Automatically compute the projection matrix to best fit (including all the casters)
  44845. * on each frame.
  44846. */
  44847. autoUpdateExtends: boolean;
  44848. private _orthoLeft;
  44849. private _orthoRight;
  44850. private _orthoTop;
  44851. private _orthoBottom;
  44852. /**
  44853. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44854. * The directional light is emitted from everywhere in the given direction.
  44855. * It can cast shadows.
  44856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44857. * @param name The friendly name of the light
  44858. * @param direction The direction of the light
  44859. * @param scene The scene the light belongs to
  44860. */
  44861. constructor(name: string, direction: Vector3, scene: Scene);
  44862. /**
  44863. * Returns the string "DirectionalLight".
  44864. * @return The class name
  44865. */
  44866. getClassName(): string;
  44867. /**
  44868. * Returns the integer 1.
  44869. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44870. */
  44871. getTypeID(): number;
  44872. /**
  44873. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44874. * Returns the DirectionalLight Shadow projection matrix.
  44875. */
  44876. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44877. /**
  44878. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44879. * Returns the DirectionalLight Shadow projection matrix.
  44880. */
  44881. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44882. /**
  44883. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44884. * Returns the DirectionalLight Shadow projection matrix.
  44885. */
  44886. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44887. protected _buildUniformLayout(): void;
  44888. /**
  44889. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44890. * @param effect The effect to update
  44891. * @param lightIndex The index of the light in the effect to update
  44892. * @returns The directional light
  44893. */
  44894. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44895. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44896. /**
  44897. * Gets the minZ used for shadow according to both the scene and the light.
  44898. *
  44899. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44900. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44901. * @param activeCamera The camera we are returning the min for
  44902. * @returns the depth min z
  44903. */
  44904. getDepthMinZ(activeCamera: Camera): number;
  44905. /**
  44906. * Gets the maxZ used for shadow according to both the scene and the light.
  44907. *
  44908. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44909. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44910. * @param activeCamera The camera we are returning the max for
  44911. * @returns the depth max z
  44912. */
  44913. getDepthMaxZ(activeCamera: Camera): number;
  44914. /**
  44915. * Prepares the list of defines specific to the light type.
  44916. * @param defines the list of defines
  44917. * @param lightIndex defines the index of the light for the effect
  44918. */
  44919. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44920. }
  44921. }
  44922. declare module BABYLON {
  44923. /**
  44924. * Class containing static functions to help procedurally build meshes
  44925. */
  44926. export class HemisphereBuilder {
  44927. /**
  44928. * Creates a hemisphere mesh
  44929. * @param name defines the name of the mesh
  44930. * @param options defines the options used to create the mesh
  44931. * @param scene defines the hosting scene
  44932. * @returns the hemisphere mesh
  44933. */
  44934. static CreateHemisphere(name: string, options: {
  44935. segments?: number;
  44936. diameter?: number;
  44937. sideOrientation?: number;
  44938. }, scene: any): Mesh;
  44939. }
  44940. }
  44941. declare module BABYLON {
  44942. /**
  44943. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44944. * These values define a cone of light starting from the position, emitting toward the direction.
  44945. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44946. * and the exponent defines the speed of the decay of the light with distance (reach).
  44947. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44948. */
  44949. export class SpotLight extends ShadowLight {
  44950. private _angle;
  44951. private _innerAngle;
  44952. private _cosHalfAngle;
  44953. private _lightAngleScale;
  44954. private _lightAngleOffset;
  44955. /**
  44956. * Gets the cone angle of the spot light in Radians.
  44957. */
  44958. /**
  44959. * Sets the cone angle of the spot light in Radians.
  44960. */
  44961. angle: number;
  44962. /**
  44963. * Only used in gltf falloff mode, this defines the angle where
  44964. * the directional falloff will start before cutting at angle which could be seen
  44965. * as outer angle.
  44966. */
  44967. /**
  44968. * Only used in gltf falloff mode, this defines the angle where
  44969. * the directional falloff will start before cutting at angle which could be seen
  44970. * as outer angle.
  44971. */
  44972. innerAngle: number;
  44973. private _shadowAngleScale;
  44974. /**
  44975. * Allows scaling the angle of the light for shadow generation only.
  44976. */
  44977. /**
  44978. * Allows scaling the angle of the light for shadow generation only.
  44979. */
  44980. shadowAngleScale: number;
  44981. /**
  44982. * The light decay speed with the distance from the emission spot.
  44983. */
  44984. exponent: number;
  44985. private _projectionTextureMatrix;
  44986. /**
  44987. * Allows reading the projecton texture
  44988. */
  44989. readonly projectionTextureMatrix: Matrix;
  44990. protected _projectionTextureLightNear: number;
  44991. /**
  44992. * Gets the near clip of the Spotlight for texture projection.
  44993. */
  44994. /**
  44995. * Sets the near clip of the Spotlight for texture projection.
  44996. */
  44997. projectionTextureLightNear: number;
  44998. protected _projectionTextureLightFar: number;
  44999. /**
  45000. * Gets the far clip of the Spotlight for texture projection.
  45001. */
  45002. /**
  45003. * Sets the far clip of the Spotlight for texture projection.
  45004. */
  45005. projectionTextureLightFar: number;
  45006. protected _projectionTextureUpDirection: Vector3;
  45007. /**
  45008. * Gets the Up vector of the Spotlight for texture projection.
  45009. */
  45010. /**
  45011. * Sets the Up vector of the Spotlight for texture projection.
  45012. */
  45013. projectionTextureUpDirection: Vector3;
  45014. private _projectionTexture;
  45015. /**
  45016. * Gets the projection texture of the light.
  45017. */
  45018. /**
  45019. * Sets the projection texture of the light.
  45020. */
  45021. projectionTexture: Nullable<BaseTexture>;
  45022. private _projectionTextureViewLightDirty;
  45023. private _projectionTextureProjectionLightDirty;
  45024. private _projectionTextureDirty;
  45025. private _projectionTextureViewTargetVector;
  45026. private _projectionTextureViewLightMatrix;
  45027. private _projectionTextureProjectionLightMatrix;
  45028. private _projectionTextureScalingMatrix;
  45029. /**
  45030. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45031. * It can cast shadows.
  45032. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45033. * @param name The light friendly name
  45034. * @param position The position of the spot light in the scene
  45035. * @param direction The direction of the light in the scene
  45036. * @param angle The cone angle of the light in Radians
  45037. * @param exponent The light decay speed with the distance from the emission spot
  45038. * @param scene The scene the lights belongs to
  45039. */
  45040. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45041. /**
  45042. * Returns the string "SpotLight".
  45043. * @returns the class name
  45044. */
  45045. getClassName(): string;
  45046. /**
  45047. * Returns the integer 2.
  45048. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45049. */
  45050. getTypeID(): number;
  45051. /**
  45052. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45053. */
  45054. protected _setDirection(value: Vector3): void;
  45055. /**
  45056. * Overrides the position setter to recompute the projection texture view light Matrix.
  45057. */
  45058. protected _setPosition(value: Vector3): void;
  45059. /**
  45060. * 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.
  45061. * Returns the SpotLight.
  45062. */
  45063. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45064. protected _computeProjectionTextureViewLightMatrix(): void;
  45065. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45066. /**
  45067. * Main function for light texture projection matrix computing.
  45068. */
  45069. protected _computeProjectionTextureMatrix(): void;
  45070. protected _buildUniformLayout(): void;
  45071. private _computeAngleValues;
  45072. /**
  45073. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45074. * @param effect The effect to update
  45075. * @param lightIndex The index of the light in the effect to update
  45076. * @returns The spot light
  45077. */
  45078. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45080. /**
  45081. * Disposes the light and the associated resources.
  45082. */
  45083. dispose(): void;
  45084. /**
  45085. * Prepares the list of defines specific to the light type.
  45086. * @param defines the list of defines
  45087. * @param lightIndex defines the index of the light for the effect
  45088. */
  45089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45090. }
  45091. }
  45092. declare module BABYLON {
  45093. /**
  45094. * Gizmo that enables viewing a light
  45095. */
  45096. export class LightGizmo extends Gizmo {
  45097. private _lightMesh;
  45098. private _material;
  45099. private cachedPosition;
  45100. private cachedForward;
  45101. /**
  45102. * Creates a LightGizmo
  45103. * @param gizmoLayer The utility layer the gizmo will be added to
  45104. */
  45105. constructor(gizmoLayer?: UtilityLayerRenderer);
  45106. private _light;
  45107. /**
  45108. * The light that the gizmo is attached to
  45109. */
  45110. light: Nullable<Light>;
  45111. /**
  45112. * Gets the material used to render the light gizmo
  45113. */
  45114. readonly material: StandardMaterial;
  45115. /**
  45116. * @hidden
  45117. * Updates the gizmo to match the attached mesh's position/rotation
  45118. */
  45119. protected _update(): void;
  45120. private static _Scale;
  45121. /**
  45122. * Creates the lines for a light mesh
  45123. */
  45124. private static _createLightLines;
  45125. /**
  45126. * Disposes of the light gizmo
  45127. */
  45128. dispose(): void;
  45129. private static _CreateHemisphericLightMesh;
  45130. private static _CreatePointLightMesh;
  45131. private static _CreateSpotLightMesh;
  45132. private static _CreateDirectionalLightMesh;
  45133. }
  45134. }
  45135. declare module BABYLON {
  45136. /** @hidden */
  45137. export var backgroundFragmentDeclaration: {
  45138. name: string;
  45139. shader: string;
  45140. };
  45141. }
  45142. declare module BABYLON {
  45143. /** @hidden */
  45144. export var backgroundUboDeclaration: {
  45145. name: string;
  45146. shader: string;
  45147. };
  45148. }
  45149. declare module BABYLON {
  45150. /** @hidden */
  45151. export var backgroundPixelShader: {
  45152. name: string;
  45153. shader: string;
  45154. };
  45155. }
  45156. declare module BABYLON {
  45157. /** @hidden */
  45158. export var backgroundVertexDeclaration: {
  45159. name: string;
  45160. shader: string;
  45161. };
  45162. }
  45163. declare module BABYLON {
  45164. /** @hidden */
  45165. export var backgroundVertexShader: {
  45166. name: string;
  45167. shader: string;
  45168. };
  45169. }
  45170. declare module BABYLON {
  45171. /**
  45172. * Background material used to create an efficient environement around your scene.
  45173. */
  45174. export class BackgroundMaterial extends PushMaterial {
  45175. /**
  45176. * Standard reflectance value at parallel view angle.
  45177. */
  45178. static StandardReflectance0: number;
  45179. /**
  45180. * Standard reflectance value at grazing angle.
  45181. */
  45182. static StandardReflectance90: number;
  45183. protected _primaryColor: Color3;
  45184. /**
  45185. * Key light Color (multiply against the environement texture)
  45186. */
  45187. primaryColor: Color3;
  45188. protected __perceptualColor: Nullable<Color3>;
  45189. /**
  45190. * Experimental Internal Use Only.
  45191. *
  45192. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45193. * This acts as a helper to set the primary color to a more "human friendly" value.
  45194. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45195. * output color as close as possible from the chosen value.
  45196. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45197. * part of lighting setup.)
  45198. */
  45199. _perceptualColor: Nullable<Color3>;
  45200. protected _primaryColorShadowLevel: float;
  45201. /**
  45202. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45203. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45204. */
  45205. primaryColorShadowLevel: float;
  45206. protected _primaryColorHighlightLevel: float;
  45207. /**
  45208. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45209. * The primary color is used at the level chosen to define what the white area would look.
  45210. */
  45211. primaryColorHighlightLevel: float;
  45212. protected _reflectionTexture: Nullable<BaseTexture>;
  45213. /**
  45214. * Reflection Texture used in the material.
  45215. * Should be author in a specific way for the best result (refer to the documentation).
  45216. */
  45217. reflectionTexture: Nullable<BaseTexture>;
  45218. protected _reflectionBlur: float;
  45219. /**
  45220. * Reflection Texture level of blur.
  45221. *
  45222. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45223. * texture twice.
  45224. */
  45225. reflectionBlur: float;
  45226. protected _diffuseTexture: Nullable<BaseTexture>;
  45227. /**
  45228. * Diffuse Texture used in the material.
  45229. * Should be author in a specific way for the best result (refer to the documentation).
  45230. */
  45231. diffuseTexture: Nullable<BaseTexture>;
  45232. protected _shadowLights: Nullable<IShadowLight[]>;
  45233. /**
  45234. * Specify the list of lights casting shadow on the material.
  45235. * All scene shadow lights will be included if null.
  45236. */
  45237. shadowLights: Nullable<IShadowLight[]>;
  45238. protected _shadowLevel: float;
  45239. /**
  45240. * Helps adjusting the shadow to a softer level if required.
  45241. * 0 means black shadows and 1 means no shadows.
  45242. */
  45243. shadowLevel: float;
  45244. protected _sceneCenter: Vector3;
  45245. /**
  45246. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45247. * It is usually zero but might be interesting to modify according to your setup.
  45248. */
  45249. sceneCenter: Vector3;
  45250. protected _opacityFresnel: boolean;
  45251. /**
  45252. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45253. * This helps ensuring a nice transition when the camera goes under the ground.
  45254. */
  45255. opacityFresnel: boolean;
  45256. protected _reflectionFresnel: boolean;
  45257. /**
  45258. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45259. * This helps adding a mirror texture on the ground.
  45260. */
  45261. reflectionFresnel: boolean;
  45262. protected _reflectionFalloffDistance: number;
  45263. /**
  45264. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45265. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45266. */
  45267. reflectionFalloffDistance: number;
  45268. protected _reflectionAmount: number;
  45269. /**
  45270. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45271. */
  45272. reflectionAmount: number;
  45273. protected _reflectionReflectance0: number;
  45274. /**
  45275. * This specifies the weight of the reflection at grazing angle.
  45276. */
  45277. reflectionReflectance0: number;
  45278. protected _reflectionReflectance90: number;
  45279. /**
  45280. * This specifies the weight of the reflection at a perpendicular point of view.
  45281. */
  45282. reflectionReflectance90: number;
  45283. /**
  45284. * Sets the reflection reflectance fresnel values according to the default standard
  45285. * empirically know to work well :-)
  45286. */
  45287. reflectionStandardFresnelWeight: number;
  45288. protected _useRGBColor: boolean;
  45289. /**
  45290. * Helps to directly use the maps channels instead of their level.
  45291. */
  45292. useRGBColor: boolean;
  45293. protected _enableNoise: boolean;
  45294. /**
  45295. * This helps reducing the banding effect that could occur on the background.
  45296. */
  45297. enableNoise: boolean;
  45298. /**
  45299. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45300. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45301. * Recommended to be keep at 1.0 except for special cases.
  45302. */
  45303. fovMultiplier: number;
  45304. private _fovMultiplier;
  45305. /**
  45306. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45307. */
  45308. useEquirectangularFOV: boolean;
  45309. private _maxSimultaneousLights;
  45310. /**
  45311. * Number of Simultaneous lights allowed on the material.
  45312. */
  45313. maxSimultaneousLights: int;
  45314. /**
  45315. * Default configuration related to image processing available in the Background Material.
  45316. */
  45317. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45318. /**
  45319. * Keep track of the image processing observer to allow dispose and replace.
  45320. */
  45321. private _imageProcessingObserver;
  45322. /**
  45323. * Attaches a new image processing configuration to the PBR Material.
  45324. * @param configuration (if null the scene configuration will be use)
  45325. */
  45326. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45327. /**
  45328. * Gets the image processing configuration used either in this material.
  45329. */
  45330. /**
  45331. * Sets the Default image processing configuration used either in the this material.
  45332. *
  45333. * If sets to null, the scene one is in use.
  45334. */
  45335. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45336. /**
  45337. * Gets wether the color curves effect is enabled.
  45338. */
  45339. /**
  45340. * Sets wether the color curves effect is enabled.
  45341. */
  45342. cameraColorCurvesEnabled: boolean;
  45343. /**
  45344. * Gets wether the color grading effect is enabled.
  45345. */
  45346. /**
  45347. * Gets wether the color grading effect is enabled.
  45348. */
  45349. cameraColorGradingEnabled: boolean;
  45350. /**
  45351. * Gets wether tonemapping is enabled or not.
  45352. */
  45353. /**
  45354. * Sets wether tonemapping is enabled or not
  45355. */
  45356. cameraToneMappingEnabled: boolean;
  45357. /**
  45358. * The camera exposure used on this material.
  45359. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45360. * This corresponds to a photographic exposure.
  45361. */
  45362. /**
  45363. * The camera exposure used on this material.
  45364. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45365. * This corresponds to a photographic exposure.
  45366. */
  45367. cameraExposure: float;
  45368. /**
  45369. * Gets The camera contrast used on this material.
  45370. */
  45371. /**
  45372. * Sets The camera contrast used on this material.
  45373. */
  45374. cameraContrast: float;
  45375. /**
  45376. * Gets the Color Grading 2D Lookup Texture.
  45377. */
  45378. /**
  45379. * Sets the Color Grading 2D Lookup Texture.
  45380. */
  45381. cameraColorGradingTexture: Nullable<BaseTexture>;
  45382. /**
  45383. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45384. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45385. * 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;
  45386. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45387. */
  45388. /**
  45389. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45390. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45391. * 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;
  45392. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45393. */
  45394. cameraColorCurves: Nullable<ColorCurves>;
  45395. /**
  45396. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45397. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45398. */
  45399. switchToBGR: boolean;
  45400. private _renderTargets;
  45401. private _reflectionControls;
  45402. private _white;
  45403. private _primaryShadowColor;
  45404. private _primaryHighlightColor;
  45405. /**
  45406. * Instantiates a Background Material in the given scene
  45407. * @param name The friendly name of the material
  45408. * @param scene The scene to add the material to
  45409. */
  45410. constructor(name: string, scene: Scene);
  45411. /**
  45412. * Gets a boolean indicating that current material needs to register RTT
  45413. */
  45414. readonly hasRenderTargetTextures: boolean;
  45415. /**
  45416. * The entire material has been created in order to prevent overdraw.
  45417. * @returns false
  45418. */
  45419. needAlphaTesting(): boolean;
  45420. /**
  45421. * The entire material has been created in order to prevent overdraw.
  45422. * @returns true if blending is enable
  45423. */
  45424. needAlphaBlending(): boolean;
  45425. /**
  45426. * Checks wether the material is ready to be rendered for a given mesh.
  45427. * @param mesh The mesh to render
  45428. * @param subMesh The submesh to check against
  45429. * @param useInstances Specify wether or not the material is used with instances
  45430. * @returns true if all the dependencies are ready (Textures, Effects...)
  45431. */
  45432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45433. /**
  45434. * Compute the primary color according to the chosen perceptual color.
  45435. */
  45436. private _computePrimaryColorFromPerceptualColor;
  45437. /**
  45438. * Compute the highlights and shadow colors according to their chosen levels.
  45439. */
  45440. private _computePrimaryColors;
  45441. /**
  45442. * Build the uniform buffer used in the material.
  45443. */
  45444. buildUniformLayout(): void;
  45445. /**
  45446. * Unbind the material.
  45447. */
  45448. unbind(): void;
  45449. /**
  45450. * Bind only the world matrix to the material.
  45451. * @param world The world matrix to bind.
  45452. */
  45453. bindOnlyWorldMatrix(world: Matrix): void;
  45454. /**
  45455. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45456. * @param world The world matrix to bind.
  45457. * @param subMesh The submesh to bind for.
  45458. */
  45459. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45460. /**
  45461. * Checks to see if a texture is used in the material.
  45462. * @param texture - Base texture to use.
  45463. * @returns - Boolean specifying if a texture is used in the material.
  45464. */
  45465. hasTexture(texture: BaseTexture): boolean;
  45466. /**
  45467. * Dispose the material.
  45468. * @param forceDisposeEffect Force disposal of the associated effect.
  45469. * @param forceDisposeTextures Force disposal of the associated textures.
  45470. */
  45471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45472. /**
  45473. * Clones the material.
  45474. * @param name The cloned name.
  45475. * @returns The cloned material.
  45476. */
  45477. clone(name: string): BackgroundMaterial;
  45478. /**
  45479. * Serializes the current material to its JSON representation.
  45480. * @returns The JSON representation.
  45481. */
  45482. serialize(): any;
  45483. /**
  45484. * Gets the class name of the material
  45485. * @returns "BackgroundMaterial"
  45486. */
  45487. getClassName(): string;
  45488. /**
  45489. * Parse a JSON input to create back a background material.
  45490. * @param source The JSON data to parse
  45491. * @param scene The scene to create the parsed material in
  45492. * @param rootUrl The root url of the assets the material depends upon
  45493. * @returns the instantiated BackgroundMaterial.
  45494. */
  45495. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45496. }
  45497. }
  45498. declare module BABYLON {
  45499. /**
  45500. * Represents the different options available during the creation of
  45501. * a Environment helper.
  45502. *
  45503. * This can control the default ground, skybox and image processing setup of your scene.
  45504. */
  45505. export interface IEnvironmentHelperOptions {
  45506. /**
  45507. * Specifies wether or not to create a ground.
  45508. * True by default.
  45509. */
  45510. createGround: boolean;
  45511. /**
  45512. * Specifies the ground size.
  45513. * 15 by default.
  45514. */
  45515. groundSize: number;
  45516. /**
  45517. * The texture used on the ground for the main color.
  45518. * Comes from the BabylonJS CDN by default.
  45519. *
  45520. * Remarks: Can be either a texture or a url.
  45521. */
  45522. groundTexture: string | BaseTexture;
  45523. /**
  45524. * The color mixed in the ground texture by default.
  45525. * BabylonJS clearColor by default.
  45526. */
  45527. groundColor: Color3;
  45528. /**
  45529. * Specifies the ground opacity.
  45530. * 1 by default.
  45531. */
  45532. groundOpacity: number;
  45533. /**
  45534. * Enables the ground to receive shadows.
  45535. * True by default.
  45536. */
  45537. enableGroundShadow: boolean;
  45538. /**
  45539. * Helps preventing the shadow to be fully black on the ground.
  45540. * 0.5 by default.
  45541. */
  45542. groundShadowLevel: number;
  45543. /**
  45544. * Creates a mirror texture attach to the ground.
  45545. * false by default.
  45546. */
  45547. enableGroundMirror: boolean;
  45548. /**
  45549. * Specifies the ground mirror size ratio.
  45550. * 0.3 by default as the default kernel is 64.
  45551. */
  45552. groundMirrorSizeRatio: number;
  45553. /**
  45554. * Specifies the ground mirror blur kernel size.
  45555. * 64 by default.
  45556. */
  45557. groundMirrorBlurKernel: number;
  45558. /**
  45559. * Specifies the ground mirror visibility amount.
  45560. * 1 by default
  45561. */
  45562. groundMirrorAmount: number;
  45563. /**
  45564. * Specifies the ground mirror reflectance weight.
  45565. * This uses the standard weight of the background material to setup the fresnel effect
  45566. * of the mirror.
  45567. * 1 by default.
  45568. */
  45569. groundMirrorFresnelWeight: number;
  45570. /**
  45571. * Specifies the ground mirror Falloff distance.
  45572. * This can helps reducing the size of the reflection.
  45573. * 0 by Default.
  45574. */
  45575. groundMirrorFallOffDistance: number;
  45576. /**
  45577. * Specifies the ground mirror texture type.
  45578. * Unsigned Int by Default.
  45579. */
  45580. groundMirrorTextureType: number;
  45581. /**
  45582. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45583. * the shown objects.
  45584. */
  45585. groundYBias: number;
  45586. /**
  45587. * Specifies wether or not to create a skybox.
  45588. * True by default.
  45589. */
  45590. createSkybox: boolean;
  45591. /**
  45592. * Specifies the skybox size.
  45593. * 20 by default.
  45594. */
  45595. skyboxSize: number;
  45596. /**
  45597. * The texture used on the skybox for the main color.
  45598. * Comes from the BabylonJS CDN by default.
  45599. *
  45600. * Remarks: Can be either a texture or a url.
  45601. */
  45602. skyboxTexture: string | BaseTexture;
  45603. /**
  45604. * The color mixed in the skybox texture by default.
  45605. * BabylonJS clearColor by default.
  45606. */
  45607. skyboxColor: Color3;
  45608. /**
  45609. * The background rotation around the Y axis of the scene.
  45610. * This helps aligning the key lights of your scene with the background.
  45611. * 0 by default.
  45612. */
  45613. backgroundYRotation: number;
  45614. /**
  45615. * Compute automatically the size of the elements to best fit with the scene.
  45616. */
  45617. sizeAuto: boolean;
  45618. /**
  45619. * Default position of the rootMesh if autoSize is not true.
  45620. */
  45621. rootPosition: Vector3;
  45622. /**
  45623. * Sets up the image processing in the scene.
  45624. * true by default.
  45625. */
  45626. setupImageProcessing: boolean;
  45627. /**
  45628. * The texture used as your environment texture in the scene.
  45629. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45630. *
  45631. * Remarks: Can be either a texture or a url.
  45632. */
  45633. environmentTexture: string | BaseTexture;
  45634. /**
  45635. * The value of the exposure to apply to the scene.
  45636. * 0.6 by default if setupImageProcessing is true.
  45637. */
  45638. cameraExposure: number;
  45639. /**
  45640. * The value of the contrast to apply to the scene.
  45641. * 1.6 by default if setupImageProcessing is true.
  45642. */
  45643. cameraContrast: number;
  45644. /**
  45645. * Specifies wether or not tonemapping should be enabled in the scene.
  45646. * true by default if setupImageProcessing is true.
  45647. */
  45648. toneMappingEnabled: boolean;
  45649. }
  45650. /**
  45651. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45652. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45653. * It also helps with the default setup of your imageProcessing configuration.
  45654. */
  45655. export class EnvironmentHelper {
  45656. /**
  45657. * Default ground texture URL.
  45658. */
  45659. private static _groundTextureCDNUrl;
  45660. /**
  45661. * Default skybox texture URL.
  45662. */
  45663. private static _skyboxTextureCDNUrl;
  45664. /**
  45665. * Default environment texture URL.
  45666. */
  45667. private static _environmentTextureCDNUrl;
  45668. /**
  45669. * Creates the default options for the helper.
  45670. */
  45671. private static _getDefaultOptions;
  45672. private _rootMesh;
  45673. /**
  45674. * Gets the root mesh created by the helper.
  45675. */
  45676. readonly rootMesh: Mesh;
  45677. private _skybox;
  45678. /**
  45679. * Gets the skybox created by the helper.
  45680. */
  45681. readonly skybox: Nullable<Mesh>;
  45682. private _skyboxTexture;
  45683. /**
  45684. * Gets the skybox texture created by the helper.
  45685. */
  45686. readonly skyboxTexture: Nullable<BaseTexture>;
  45687. private _skyboxMaterial;
  45688. /**
  45689. * Gets the skybox material created by the helper.
  45690. */
  45691. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45692. private _ground;
  45693. /**
  45694. * Gets the ground mesh created by the helper.
  45695. */
  45696. readonly ground: Nullable<Mesh>;
  45697. private _groundTexture;
  45698. /**
  45699. * Gets the ground texture created by the helper.
  45700. */
  45701. readonly groundTexture: Nullable<BaseTexture>;
  45702. private _groundMirror;
  45703. /**
  45704. * Gets the ground mirror created by the helper.
  45705. */
  45706. readonly groundMirror: Nullable<MirrorTexture>;
  45707. /**
  45708. * Gets the ground mirror render list to helps pushing the meshes
  45709. * you wish in the ground reflection.
  45710. */
  45711. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45712. private _groundMaterial;
  45713. /**
  45714. * Gets the ground material created by the helper.
  45715. */
  45716. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45717. /**
  45718. * Stores the creation options.
  45719. */
  45720. private readonly _scene;
  45721. private _options;
  45722. /**
  45723. * This observable will be notified with any error during the creation of the environment,
  45724. * mainly texture creation errors.
  45725. */
  45726. onErrorObservable: Observable<{
  45727. message?: string;
  45728. exception?: any;
  45729. }>;
  45730. /**
  45731. * constructor
  45732. * @param options Defines the options we want to customize the helper
  45733. * @param scene The scene to add the material to
  45734. */
  45735. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45736. /**
  45737. * Updates the background according to the new options
  45738. * @param options
  45739. */
  45740. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45741. /**
  45742. * Sets the primary color of all the available elements.
  45743. * @param color the main color to affect to the ground and the background
  45744. */
  45745. setMainColor(color: Color3): void;
  45746. /**
  45747. * Setup the image processing according to the specified options.
  45748. */
  45749. private _setupImageProcessing;
  45750. /**
  45751. * Setup the environment texture according to the specified options.
  45752. */
  45753. private _setupEnvironmentTexture;
  45754. /**
  45755. * Setup the background according to the specified options.
  45756. */
  45757. private _setupBackground;
  45758. /**
  45759. * Get the scene sizes according to the setup.
  45760. */
  45761. private _getSceneSize;
  45762. /**
  45763. * Setup the ground according to the specified options.
  45764. */
  45765. private _setupGround;
  45766. /**
  45767. * Setup the ground material according to the specified options.
  45768. */
  45769. private _setupGroundMaterial;
  45770. /**
  45771. * Setup the ground diffuse texture according to the specified options.
  45772. */
  45773. private _setupGroundDiffuseTexture;
  45774. /**
  45775. * Setup the ground mirror texture according to the specified options.
  45776. */
  45777. private _setupGroundMirrorTexture;
  45778. /**
  45779. * Setup the ground to receive the mirror texture.
  45780. */
  45781. private _setupMirrorInGroundMaterial;
  45782. /**
  45783. * Setup the skybox according to the specified options.
  45784. */
  45785. private _setupSkybox;
  45786. /**
  45787. * Setup the skybox material according to the specified options.
  45788. */
  45789. private _setupSkyboxMaterial;
  45790. /**
  45791. * Setup the skybox reflection texture according to the specified options.
  45792. */
  45793. private _setupSkyboxReflectionTexture;
  45794. private _errorHandler;
  45795. /**
  45796. * Dispose all the elements created by the Helper.
  45797. */
  45798. dispose(): void;
  45799. }
  45800. }
  45801. declare module BABYLON {
  45802. /**
  45803. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45804. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45805. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45806. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45807. */
  45808. export class PhotoDome extends TransformNode {
  45809. /**
  45810. * Define the image as a Monoscopic panoramic 360 image.
  45811. */
  45812. static readonly MODE_MONOSCOPIC: number;
  45813. /**
  45814. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45815. */
  45816. static readonly MODE_TOPBOTTOM: number;
  45817. /**
  45818. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45819. */
  45820. static readonly MODE_SIDEBYSIDE: number;
  45821. private _useDirectMapping;
  45822. /**
  45823. * The texture being displayed on the sphere
  45824. */
  45825. protected _photoTexture: Texture;
  45826. /**
  45827. * Gets or sets the texture being displayed on the sphere
  45828. */
  45829. photoTexture: Texture;
  45830. /**
  45831. * Observable raised when an error occured while loading the 360 image
  45832. */
  45833. onLoadErrorObservable: Observable<string>;
  45834. /**
  45835. * The skybox material
  45836. */
  45837. protected _material: BackgroundMaterial;
  45838. /**
  45839. * The surface used for the skybox
  45840. */
  45841. protected _mesh: Mesh;
  45842. /**
  45843. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45844. * Also see the options.resolution property.
  45845. */
  45846. fovMultiplier: number;
  45847. private _imageMode;
  45848. /**
  45849. * Gets or set the current video mode for the video. It can be:
  45850. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45851. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45852. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45853. */
  45854. imageMode: number;
  45855. /**
  45856. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45857. * @param name Element's name, child elements will append suffixes for their own names.
  45858. * @param urlsOfPhoto defines the url of the photo to display
  45859. * @param options defines an object containing optional or exposed sub element properties
  45860. * @param onError defines a callback called when an error occured while loading the texture
  45861. */
  45862. constructor(name: string, urlOfPhoto: string, options: {
  45863. resolution?: number;
  45864. size?: number;
  45865. useDirectMapping?: boolean;
  45866. faceForward?: boolean;
  45867. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45868. private _onBeforeCameraRenderObserver;
  45869. private _changeImageMode;
  45870. /**
  45871. * Releases resources associated with this node.
  45872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45874. */
  45875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * Class used to host texture specific utilities
  45881. */
  45882. export class BRDFTextureTools {
  45883. /**
  45884. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45885. * @param texture the texture to expand.
  45886. */
  45887. private static _ExpandDefaultBRDFTexture;
  45888. /**
  45889. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45890. * @param scene defines the hosting scene
  45891. * @returns the environment BRDF texture
  45892. */
  45893. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45894. private static _environmentBRDFBase64Texture;
  45895. }
  45896. }
  45897. declare module BABYLON {
  45898. /**
  45899. * @hidden
  45900. */
  45901. export interface IMaterialClearCoatDefines {
  45902. CLEARCOAT: boolean;
  45903. CLEARCOAT_DEFAULTIOR: boolean;
  45904. CLEARCOAT_TEXTURE: boolean;
  45905. CLEARCOAT_TEXTUREDIRECTUV: number;
  45906. CLEARCOAT_BUMP: boolean;
  45907. CLEARCOAT_BUMPDIRECTUV: number;
  45908. CLEARCOAT_TINT: boolean;
  45909. CLEARCOAT_TINT_TEXTURE: boolean;
  45910. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45911. /** @hidden */
  45912. _areTexturesDirty: boolean;
  45913. }
  45914. /**
  45915. * Define the code related to the clear coat parameters of the pbr material.
  45916. */
  45917. export class PBRClearCoatConfiguration {
  45918. /**
  45919. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45920. * The default fits with a polyurethane material.
  45921. */
  45922. private static readonly _DefaultIndexOfRefraction;
  45923. private _isEnabled;
  45924. /**
  45925. * Defines if the clear coat is enabled in the material.
  45926. */
  45927. isEnabled: boolean;
  45928. /**
  45929. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45930. */
  45931. intensity: number;
  45932. /**
  45933. * Defines the clear coat layer roughness.
  45934. */
  45935. roughness: number;
  45936. private _indexOfRefraction;
  45937. /**
  45938. * Defines the index of refraction of the clear coat.
  45939. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45940. * The default fits with a polyurethane material.
  45941. * Changing the default value is more performance intensive.
  45942. */
  45943. indexOfRefraction: number;
  45944. private _texture;
  45945. /**
  45946. * Stores the clear coat values in a texture.
  45947. */
  45948. texture: Nullable<BaseTexture>;
  45949. private _bumpTexture;
  45950. /**
  45951. * Define the clear coat specific bump texture.
  45952. */
  45953. bumpTexture: Nullable<BaseTexture>;
  45954. private _isTintEnabled;
  45955. /**
  45956. * Defines if the clear coat tint is enabled in the material.
  45957. */
  45958. isTintEnabled: boolean;
  45959. /**
  45960. * Defines the clear coat tint of the material.
  45961. * This is only use if tint is enabled
  45962. */
  45963. tintColor: Color3;
  45964. /**
  45965. * Defines the distance at which the tint color should be found in the
  45966. * clear coat media.
  45967. * This is only use if tint is enabled
  45968. */
  45969. tintColorAtDistance: number;
  45970. /**
  45971. * Defines the clear coat layer thickness.
  45972. * This is only use if tint is enabled
  45973. */
  45974. tintThickness: number;
  45975. private _tintTexture;
  45976. /**
  45977. * Stores the clear tint values in a texture.
  45978. * rgb is tint
  45979. * a is a thickness factor
  45980. */
  45981. tintTexture: Nullable<BaseTexture>;
  45982. /** @hidden */
  45983. private _internalMarkAllSubMeshesAsTexturesDirty;
  45984. /** @hidden */
  45985. _markAllSubMeshesAsTexturesDirty(): void;
  45986. /**
  45987. * Instantiate a new istance of clear coat configuration.
  45988. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45989. */
  45990. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45991. /**
  45992. * Gets wehter the submesh is ready to be used or not.
  45993. * @param defines the list of "defines" to update.
  45994. * @param scene defines the scene the material belongs to.
  45995. * @param engine defines the engine the material belongs to.
  45996. * @param disableBumpMap defines wether the material disables bump or not.
  45997. * @returns - boolean indicating that the submesh is ready or not.
  45998. */
  45999. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46000. /**
  46001. * Checks to see if a texture is used in the material.
  46002. * @param defines the list of "defines" to update.
  46003. * @param scene defines the scene to the material belongs to.
  46004. */
  46005. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46006. /**
  46007. * Binds the material data.
  46008. * @param uniformBuffer defines the Uniform buffer to fill in.
  46009. * @param scene defines the scene the material belongs to.
  46010. * @param engine defines the engine the material belongs to.
  46011. * @param disableBumpMap defines wether the material disables bump or not.
  46012. * @param isFrozen defines wether the material is frozen or not.
  46013. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46014. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46015. */
  46016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46017. /**
  46018. * Checks to see if a texture is used in the material.
  46019. * @param texture - Base texture to use.
  46020. * @returns - Boolean specifying if a texture is used in the material.
  46021. */
  46022. hasTexture(texture: BaseTexture): boolean;
  46023. /**
  46024. * Returns an array of the actively used textures.
  46025. * @param activeTextures Array of BaseTextures
  46026. */
  46027. getActiveTextures(activeTextures: BaseTexture[]): void;
  46028. /**
  46029. * Returns the animatable textures.
  46030. * @param animatables Array of animatable textures.
  46031. */
  46032. getAnimatables(animatables: IAnimatable[]): void;
  46033. /**
  46034. * Disposes the resources of the material.
  46035. * @param forceDisposeTextures - Forces the disposal of all textures.
  46036. */
  46037. dispose(forceDisposeTextures?: boolean): void;
  46038. /**
  46039. * Get the current class name of the texture useful for serialization or dynamic coding.
  46040. * @returns "PBRClearCoatConfiguration"
  46041. */
  46042. getClassName(): string;
  46043. /**
  46044. * Add fallbacks to the effect fallbacks list.
  46045. * @param defines defines the Base texture to use.
  46046. * @param fallbacks defines the current fallback list.
  46047. * @param currentRank defines the current fallback rank.
  46048. * @returns the new fallback rank.
  46049. */
  46050. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46051. /**
  46052. * Add the required uniforms to the current list.
  46053. * @param uniforms defines the current uniform list.
  46054. */
  46055. static AddUniforms(uniforms: string[]): void;
  46056. /**
  46057. * Add the required samplers to the current list.
  46058. * @param samplers defines the current sampler list.
  46059. */
  46060. static AddSamplers(samplers: string[]): void;
  46061. /**
  46062. * Add the required uniforms to the current buffer.
  46063. * @param uniformBuffer defines the current uniform buffer.
  46064. */
  46065. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46066. /**
  46067. * Makes a duplicate of the current configuration into another one.
  46068. * @param clearCoatConfiguration define the config where to copy the info
  46069. */
  46070. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46071. /**
  46072. * Serializes this clear coat configuration.
  46073. * @returns - An object with the serialized config.
  46074. */
  46075. serialize(): any;
  46076. /**
  46077. * Parses a anisotropy Configuration from a serialized object.
  46078. * @param source - Serialized object.
  46079. * @param scene Defines the scene we are parsing for
  46080. * @param rootUrl Defines the rootUrl to load from
  46081. */
  46082. parse(source: any, scene: Scene, rootUrl: string): void;
  46083. }
  46084. }
  46085. declare module BABYLON {
  46086. /**
  46087. * @hidden
  46088. */
  46089. export interface IMaterialAnisotropicDefines {
  46090. ANISOTROPIC: boolean;
  46091. ANISOTROPIC_TEXTURE: boolean;
  46092. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46093. MAINUV1: boolean;
  46094. _areTexturesDirty: boolean;
  46095. _needUVs: boolean;
  46096. }
  46097. /**
  46098. * Define the code related to the anisotropic parameters of the pbr material.
  46099. */
  46100. export class PBRAnisotropicConfiguration {
  46101. private _isEnabled;
  46102. /**
  46103. * Defines if the anisotropy is enabled in the material.
  46104. */
  46105. isEnabled: boolean;
  46106. /**
  46107. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46108. */
  46109. intensity: number;
  46110. /**
  46111. * Defines if the effect is along the tangents, bitangents or in between.
  46112. * By default, the effect is "strectching" the highlights along the tangents.
  46113. */
  46114. direction: Vector2;
  46115. private _texture;
  46116. /**
  46117. * Stores the anisotropy values in a texture.
  46118. * rg is direction (like normal from -1 to 1)
  46119. * b is a intensity
  46120. */
  46121. texture: Nullable<BaseTexture>;
  46122. /** @hidden */
  46123. private _internalMarkAllSubMeshesAsTexturesDirty;
  46124. /** @hidden */
  46125. _markAllSubMeshesAsTexturesDirty(): void;
  46126. /**
  46127. * Instantiate a new istance of anisotropy configuration.
  46128. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46129. */
  46130. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46131. /**
  46132. * Specifies that the submesh is ready to be used.
  46133. * @param defines the list of "defines" to update.
  46134. * @param scene defines the scene the material belongs to.
  46135. * @returns - boolean indicating that the submesh is ready or not.
  46136. */
  46137. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46138. /**
  46139. * Checks to see if a texture is used in the material.
  46140. * @param defines the list of "defines" to update.
  46141. * @param mesh the mesh we are preparing the defines for.
  46142. * @param scene defines the scene the material belongs to.
  46143. */
  46144. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46145. /**
  46146. * Binds the material data.
  46147. * @param uniformBuffer defines the Uniform buffer to fill in.
  46148. * @param scene defines the scene the material belongs to.
  46149. * @param isFrozen defines wether the material is frozen or not.
  46150. */
  46151. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46152. /**
  46153. * Checks to see if a texture is used in the material.
  46154. * @param texture - Base texture to use.
  46155. * @returns - Boolean specifying if a texture is used in the material.
  46156. */
  46157. hasTexture(texture: BaseTexture): boolean;
  46158. /**
  46159. * Returns an array of the actively used textures.
  46160. * @param activeTextures Array of BaseTextures
  46161. */
  46162. getActiveTextures(activeTextures: BaseTexture[]): void;
  46163. /**
  46164. * Returns the animatable textures.
  46165. * @param animatables Array of animatable textures.
  46166. */
  46167. getAnimatables(animatables: IAnimatable[]): void;
  46168. /**
  46169. * Disposes the resources of the material.
  46170. * @param forceDisposeTextures - Forces the disposal of all textures.
  46171. */
  46172. dispose(forceDisposeTextures?: boolean): void;
  46173. /**
  46174. * Get the current class name of the texture useful for serialization or dynamic coding.
  46175. * @returns "PBRAnisotropicConfiguration"
  46176. */
  46177. getClassName(): string;
  46178. /**
  46179. * Add fallbacks to the effect fallbacks list.
  46180. * @param defines defines the Base texture to use.
  46181. * @param fallbacks defines the current fallback list.
  46182. * @param currentRank defines the current fallback rank.
  46183. * @returns the new fallback rank.
  46184. */
  46185. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46186. /**
  46187. * Add the required uniforms to the current list.
  46188. * @param uniforms defines the current uniform list.
  46189. */
  46190. static AddUniforms(uniforms: string[]): void;
  46191. /**
  46192. * Add the required uniforms to the current buffer.
  46193. * @param uniformBuffer defines the current uniform buffer.
  46194. */
  46195. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46196. /**
  46197. * Add the required samplers to the current list.
  46198. * @param samplers defines the current sampler list.
  46199. */
  46200. static AddSamplers(samplers: string[]): void;
  46201. /**
  46202. * Makes a duplicate of the current configuration into another one.
  46203. * @param anisotropicConfiguration define the config where to copy the info
  46204. */
  46205. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46206. /**
  46207. * Serializes this anisotropy configuration.
  46208. * @returns - An object with the serialized config.
  46209. */
  46210. serialize(): any;
  46211. /**
  46212. * Parses a anisotropy Configuration from a serialized object.
  46213. * @param source - Serialized object.
  46214. * @param scene Defines the scene we are parsing for
  46215. * @param rootUrl Defines the rootUrl to load from
  46216. */
  46217. parse(source: any, scene: Scene, rootUrl: string): void;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * @hidden
  46223. */
  46224. export interface IMaterialBRDFDefines {
  46225. BRDF_V_HEIGHT_CORRELATED: boolean;
  46226. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46227. SPHERICAL_HARMONICS: boolean;
  46228. /** @hidden */
  46229. _areMiscDirty: boolean;
  46230. }
  46231. /**
  46232. * Define the code related to the BRDF parameters of the pbr material.
  46233. */
  46234. export class PBRBRDFConfiguration {
  46235. /**
  46236. * Default value used for the energy conservation.
  46237. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46238. */
  46239. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46240. /**
  46241. * Default value used for the Smith Visibility Height Correlated mode.
  46242. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46243. */
  46244. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46245. /**
  46246. * Default value used for the IBL diffuse part.
  46247. * This can help switching back to the polynomials mode globally which is a tiny bit
  46248. * less GPU intensive at the drawback of a lower quality.
  46249. */
  46250. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46251. private _useEnergyConservation;
  46252. /**
  46253. * Defines if the material uses energy conservation.
  46254. */
  46255. useEnergyConservation: boolean;
  46256. private _useSmithVisibilityHeightCorrelated;
  46257. /**
  46258. * LEGACY Mode set to false
  46259. * Defines if the material uses height smith correlated visibility term.
  46260. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46261. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46262. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46263. * Not relying on height correlated will also disable energy conservation.
  46264. */
  46265. useSmithVisibilityHeightCorrelated: boolean;
  46266. private _useSphericalHarmonics;
  46267. /**
  46268. * LEGACY Mode set to false
  46269. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46270. * diffuse part of the IBL.
  46271. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46272. * to the ground truth.
  46273. */
  46274. useSphericalHarmonics: boolean;
  46275. /** @hidden */
  46276. private _internalMarkAllSubMeshesAsMiscDirty;
  46277. /** @hidden */
  46278. _markAllSubMeshesAsMiscDirty(): void;
  46279. /**
  46280. * Instantiate a new istance of clear coat configuration.
  46281. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46282. */
  46283. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46284. /**
  46285. * Checks to see if a texture is used in the material.
  46286. * @param defines the list of "defines" to update.
  46287. */
  46288. prepareDefines(defines: IMaterialBRDFDefines): void;
  46289. /**
  46290. * Get the current class name of the texture useful for serialization or dynamic coding.
  46291. * @returns "PBRClearCoatConfiguration"
  46292. */
  46293. getClassName(): string;
  46294. /**
  46295. * Makes a duplicate of the current configuration into another one.
  46296. * @param brdfConfiguration define the config where to copy the info
  46297. */
  46298. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46299. /**
  46300. * Serializes this BRDF configuration.
  46301. * @returns - An object with the serialized config.
  46302. */
  46303. serialize(): any;
  46304. /**
  46305. * Parses a anisotropy Configuration from a serialized object.
  46306. * @param source - Serialized object.
  46307. * @param scene Defines the scene we are parsing for
  46308. * @param rootUrl Defines the rootUrl to load from
  46309. */
  46310. parse(source: any, scene: Scene, rootUrl: string): void;
  46311. }
  46312. }
  46313. declare module BABYLON {
  46314. /**
  46315. * @hidden
  46316. */
  46317. export interface IMaterialSheenDefines {
  46318. SHEEN: boolean;
  46319. SHEEN_TEXTURE: boolean;
  46320. SHEEN_TEXTUREDIRECTUV: number;
  46321. SHEEN_LINKWITHALBEDO: boolean;
  46322. /** @hidden */
  46323. _areTexturesDirty: boolean;
  46324. }
  46325. /**
  46326. * Define the code related to the Sheen parameters of the pbr material.
  46327. */
  46328. export class PBRSheenConfiguration {
  46329. private _isEnabled;
  46330. /**
  46331. * Defines if the material uses sheen.
  46332. */
  46333. isEnabled: boolean;
  46334. private _linkSheenWithAlbedo;
  46335. /**
  46336. * Defines if the sheen is linked to the sheen color.
  46337. */
  46338. linkSheenWithAlbedo: boolean;
  46339. /**
  46340. * Defines the sheen intensity.
  46341. */
  46342. intensity: number;
  46343. /**
  46344. * Defines the sheen color.
  46345. */
  46346. color: Color3;
  46347. private _texture;
  46348. /**
  46349. * Stores the sheen tint values in a texture.
  46350. * rgb is tint
  46351. * a is a intensity
  46352. */
  46353. texture: Nullable<BaseTexture>;
  46354. /** @hidden */
  46355. private _internalMarkAllSubMeshesAsTexturesDirty;
  46356. /** @hidden */
  46357. _markAllSubMeshesAsTexturesDirty(): void;
  46358. /**
  46359. * Instantiate a new istance of clear coat configuration.
  46360. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46361. */
  46362. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46363. /**
  46364. * Specifies that the submesh is ready to be used.
  46365. * @param defines the list of "defines" to update.
  46366. * @param scene defines the scene the material belongs to.
  46367. * @returns - boolean indicating that the submesh is ready or not.
  46368. */
  46369. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46370. /**
  46371. * Checks to see if a texture is used in the material.
  46372. * @param defines the list of "defines" to update.
  46373. * @param scene defines the scene the material belongs to.
  46374. */
  46375. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46376. /**
  46377. * Binds the material data.
  46378. * @param uniformBuffer defines the Uniform buffer to fill in.
  46379. * @param scene defines the scene the material belongs to.
  46380. * @param isFrozen defines wether the material is frozen or not.
  46381. */
  46382. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46383. /**
  46384. * Checks to see if a texture is used in the material.
  46385. * @param texture - Base texture to use.
  46386. * @returns - Boolean specifying if a texture is used in the material.
  46387. */
  46388. hasTexture(texture: BaseTexture): boolean;
  46389. /**
  46390. * Returns an array of the actively used textures.
  46391. * @param activeTextures Array of BaseTextures
  46392. */
  46393. getActiveTextures(activeTextures: BaseTexture[]): void;
  46394. /**
  46395. * Returns the animatable textures.
  46396. * @param animatables Array of animatable textures.
  46397. */
  46398. getAnimatables(animatables: IAnimatable[]): void;
  46399. /**
  46400. * Disposes the resources of the material.
  46401. * @param forceDisposeTextures - Forces the disposal of all textures.
  46402. */
  46403. dispose(forceDisposeTextures?: boolean): void;
  46404. /**
  46405. * Get the current class name of the texture useful for serialization or dynamic coding.
  46406. * @returns "PBRSheenConfiguration"
  46407. */
  46408. getClassName(): string;
  46409. /**
  46410. * Add fallbacks to the effect fallbacks list.
  46411. * @param defines defines the Base texture to use.
  46412. * @param fallbacks defines the current fallback list.
  46413. * @param currentRank defines the current fallback rank.
  46414. * @returns the new fallback rank.
  46415. */
  46416. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46417. /**
  46418. * Add the required uniforms to the current list.
  46419. * @param uniforms defines the current uniform list.
  46420. */
  46421. static AddUniforms(uniforms: string[]): void;
  46422. /**
  46423. * Add the required uniforms to the current buffer.
  46424. * @param uniformBuffer defines the current uniform buffer.
  46425. */
  46426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46427. /**
  46428. * Add the required samplers to the current list.
  46429. * @param samplers defines the current sampler list.
  46430. */
  46431. static AddSamplers(samplers: string[]): void;
  46432. /**
  46433. * Makes a duplicate of the current configuration into another one.
  46434. * @param sheenConfiguration define the config where to copy the info
  46435. */
  46436. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46437. /**
  46438. * Serializes this BRDF configuration.
  46439. * @returns - An object with the serialized config.
  46440. */
  46441. serialize(): any;
  46442. /**
  46443. * Parses a anisotropy Configuration from a serialized object.
  46444. * @param source - Serialized object.
  46445. * @param scene Defines the scene we are parsing for
  46446. * @param rootUrl Defines the rootUrl to load from
  46447. */
  46448. parse(source: any, scene: Scene, rootUrl: string): void;
  46449. }
  46450. }
  46451. declare module BABYLON {
  46452. /**
  46453. * @hidden
  46454. */
  46455. export interface IMaterialSubSurfaceDefines {
  46456. SUBSURFACE: boolean;
  46457. SS_REFRACTION: boolean;
  46458. SS_TRANSLUCENCY: boolean;
  46459. SS_SCATERRING: boolean;
  46460. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46461. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46462. SS_REFRACTIONMAP_3D: boolean;
  46463. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46464. SS_LODINREFRACTIONALPHA: boolean;
  46465. SS_GAMMAREFRACTION: boolean;
  46466. SS_RGBDREFRACTION: boolean;
  46467. SS_LINEARSPECULARREFRACTION: boolean;
  46468. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46469. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46470. /** @hidden */
  46471. _areTexturesDirty: boolean;
  46472. }
  46473. /**
  46474. * Define the code related to the sub surface parameters of the pbr material.
  46475. */
  46476. export class PBRSubSurfaceConfiguration {
  46477. private _isRefractionEnabled;
  46478. /**
  46479. * Defines if the refraction is enabled in the material.
  46480. */
  46481. isRefractionEnabled: boolean;
  46482. private _isTranslucencyEnabled;
  46483. /**
  46484. * Defines if the translucency is enabled in the material.
  46485. */
  46486. isTranslucencyEnabled: boolean;
  46487. private _isScatteringEnabled;
  46488. /**
  46489. * Defines the refraction intensity of the material.
  46490. * The refraction when enabled replaces the Diffuse part of the material.
  46491. * The intensity helps transitionning between diffuse and refraction.
  46492. */
  46493. refractionIntensity: number;
  46494. /**
  46495. * Defines the translucency intensity of the material.
  46496. * When translucency has been enabled, this defines how much of the "translucency"
  46497. * is addded to the diffuse part of the material.
  46498. */
  46499. translucencyIntensity: number;
  46500. /**
  46501. * Defines the scattering intensity of the material.
  46502. * When scattering has been enabled, this defines how much of the "scattered light"
  46503. * is addded to the diffuse part of the material.
  46504. */
  46505. scatteringIntensity: number;
  46506. private _thicknessTexture;
  46507. /**
  46508. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46509. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46510. * 0 would mean minimumThickness
  46511. * 1 would mean maximumThickness
  46512. * The other channels might be use as a mask to vary the different effects intensity.
  46513. */
  46514. thicknessTexture: Nullable<BaseTexture>;
  46515. private _refractionTexture;
  46516. /**
  46517. * Defines the texture to use for refraction.
  46518. */
  46519. refractionTexture: Nullable<BaseTexture>;
  46520. private _indexOfRefraction;
  46521. /**
  46522. * Defines the index of refraction used in the material.
  46523. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46524. */
  46525. indexOfRefraction: number;
  46526. private _invertRefractionY;
  46527. /**
  46528. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46529. */
  46530. invertRefractionY: boolean;
  46531. private _linkRefractionWithTransparency;
  46532. /**
  46533. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46534. * Materials half opaque for instance using refraction could benefit from this control.
  46535. */
  46536. linkRefractionWithTransparency: boolean;
  46537. /**
  46538. * Defines the minimum thickness stored in the thickness map.
  46539. * If no thickness map is defined, this value will be used to simulate thickness.
  46540. */
  46541. minimumThickness: number;
  46542. /**
  46543. * Defines the maximum thickness stored in the thickness map.
  46544. */
  46545. maximumThickness: number;
  46546. /**
  46547. * Defines the volume tint of the material.
  46548. * This is used for both translucency and scattering.
  46549. */
  46550. tintColor: Color3;
  46551. /**
  46552. * Defines the distance at which the tint color should be found in the media.
  46553. * This is used for refraction only.
  46554. */
  46555. tintColorAtDistance: number;
  46556. /**
  46557. * Defines how far each channel transmit through the media.
  46558. * It is defined as a color to simplify it selection.
  46559. */
  46560. diffusionDistance: Color3;
  46561. private _useMaskFromThicknessTexture;
  46562. /**
  46563. * Stores the intensity of the different subsurface effects in the thickness texture.
  46564. * * the green channel is the translucency intensity.
  46565. * * the blue channel is the scattering intensity.
  46566. * * the alpha channel is the refraction intensity.
  46567. */
  46568. useMaskFromThicknessTexture: boolean;
  46569. /** @hidden */
  46570. private _internalMarkAllSubMeshesAsTexturesDirty;
  46571. /** @hidden */
  46572. _markAllSubMeshesAsTexturesDirty(): void;
  46573. /**
  46574. * Instantiate a new istance of sub surface configuration.
  46575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46576. */
  46577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46578. /**
  46579. * Gets wehter the submesh is ready to be used or not.
  46580. * @param defines the list of "defines" to update.
  46581. * @param scene defines the scene the material belongs to.
  46582. * @returns - boolean indicating that the submesh is ready or not.
  46583. */
  46584. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46585. /**
  46586. * Checks to see if a texture is used in the material.
  46587. * @param defines the list of "defines" to update.
  46588. * @param scene defines the scene to the material belongs to.
  46589. */
  46590. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46591. /**
  46592. * Binds the material data.
  46593. * @param uniformBuffer defines the Uniform buffer to fill in.
  46594. * @param scene defines the scene the material belongs to.
  46595. * @param engine defines the engine the material belongs to.
  46596. * @param isFrozen defines wether the material is frozen or not.
  46597. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46598. */
  46599. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46600. /**
  46601. * Unbinds the material from the mesh.
  46602. * @param activeEffect defines the effect that should be unbound from.
  46603. * @returns true if unbound, otherwise false
  46604. */
  46605. unbind(activeEffect: Effect): boolean;
  46606. /**
  46607. * Returns the texture used for refraction or null if none is used.
  46608. * @param scene defines the scene the material belongs to.
  46609. * @returns - Refraction texture if present. If no refraction texture and refraction
  46610. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46611. */
  46612. private _getRefractionTexture;
  46613. /**
  46614. * Returns true if alpha blending should be disabled.
  46615. */
  46616. readonly disableAlphaBlending: boolean;
  46617. /**
  46618. * Fills the list of render target textures.
  46619. * @param renderTargets the list of render targets to update
  46620. */
  46621. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46622. /**
  46623. * Checks to see if a texture is used in the material.
  46624. * @param texture - Base texture to use.
  46625. * @returns - Boolean specifying if a texture is used in the material.
  46626. */
  46627. hasTexture(texture: BaseTexture): boolean;
  46628. /**
  46629. * Gets a boolean indicating that current material needs to register RTT
  46630. * @returns true if this uses a render target otherwise false.
  46631. */
  46632. hasRenderTargetTextures(): boolean;
  46633. /**
  46634. * Returns an array of the actively used textures.
  46635. * @param activeTextures Array of BaseTextures
  46636. */
  46637. getActiveTextures(activeTextures: BaseTexture[]): void;
  46638. /**
  46639. * Returns the animatable textures.
  46640. * @param animatables Array of animatable textures.
  46641. */
  46642. getAnimatables(animatables: IAnimatable[]): void;
  46643. /**
  46644. * Disposes the resources of the material.
  46645. * @param forceDisposeTextures - Forces the disposal of all textures.
  46646. */
  46647. dispose(forceDisposeTextures?: boolean): void;
  46648. /**
  46649. * Get the current class name of the texture useful for serialization or dynamic coding.
  46650. * @returns "PBRSubSurfaceConfiguration"
  46651. */
  46652. getClassName(): string;
  46653. /**
  46654. * Add fallbacks to the effect fallbacks list.
  46655. * @param defines defines the Base texture to use.
  46656. * @param fallbacks defines the current fallback list.
  46657. * @param currentRank defines the current fallback rank.
  46658. * @returns the new fallback rank.
  46659. */
  46660. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46661. /**
  46662. * Add the required uniforms to the current list.
  46663. * @param uniforms defines the current uniform list.
  46664. */
  46665. static AddUniforms(uniforms: string[]): void;
  46666. /**
  46667. * Add the required samplers to the current list.
  46668. * @param samplers defines the current sampler list.
  46669. */
  46670. static AddSamplers(samplers: string[]): void;
  46671. /**
  46672. * Add the required uniforms to the current buffer.
  46673. * @param uniformBuffer defines the current uniform buffer.
  46674. */
  46675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46676. /**
  46677. * Makes a duplicate of the current configuration into another one.
  46678. * @param configuration define the config where to copy the info
  46679. */
  46680. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46681. /**
  46682. * Serializes this Sub Surface configuration.
  46683. * @returns - An object with the serialized config.
  46684. */
  46685. serialize(): any;
  46686. /**
  46687. * Parses a anisotropy Configuration from a serialized object.
  46688. * @param source - Serialized object.
  46689. * @param scene Defines the scene we are parsing for
  46690. * @param rootUrl Defines the rootUrl to load from
  46691. */
  46692. parse(source: any, scene: Scene, rootUrl: string): void;
  46693. }
  46694. }
  46695. declare module BABYLON {
  46696. /** @hidden */
  46697. export var pbrFragmentDeclaration: {
  46698. name: string;
  46699. shader: string;
  46700. };
  46701. }
  46702. declare module BABYLON {
  46703. /** @hidden */
  46704. export var pbrUboDeclaration: {
  46705. name: string;
  46706. shader: string;
  46707. };
  46708. }
  46709. declare module BABYLON {
  46710. /** @hidden */
  46711. export var pbrFragmentExtraDeclaration: {
  46712. name: string;
  46713. shader: string;
  46714. };
  46715. }
  46716. declare module BABYLON {
  46717. /** @hidden */
  46718. export var pbrFragmentSamplersDeclaration: {
  46719. name: string;
  46720. shader: string;
  46721. };
  46722. }
  46723. declare module BABYLON {
  46724. /** @hidden */
  46725. export var pbrHelperFunctions: {
  46726. name: string;
  46727. shader: string;
  46728. };
  46729. }
  46730. declare module BABYLON {
  46731. /** @hidden */
  46732. export var harmonicsFunctions: {
  46733. name: string;
  46734. shader: string;
  46735. };
  46736. }
  46737. declare module BABYLON {
  46738. /** @hidden */
  46739. export var pbrDirectLightingSetupFunctions: {
  46740. name: string;
  46741. shader: string;
  46742. };
  46743. }
  46744. declare module BABYLON {
  46745. /** @hidden */
  46746. export var pbrDirectLightingFalloffFunctions: {
  46747. name: string;
  46748. shader: string;
  46749. };
  46750. }
  46751. declare module BABYLON {
  46752. /** @hidden */
  46753. export var pbrBRDFFunctions: {
  46754. name: string;
  46755. shader: string;
  46756. };
  46757. }
  46758. declare module BABYLON {
  46759. /** @hidden */
  46760. export var pbrDirectLightingFunctions: {
  46761. name: string;
  46762. shader: string;
  46763. };
  46764. }
  46765. declare module BABYLON {
  46766. /** @hidden */
  46767. export var pbrIBLFunctions: {
  46768. name: string;
  46769. shader: string;
  46770. };
  46771. }
  46772. declare module BABYLON {
  46773. /** @hidden */
  46774. export var pbrDebug: {
  46775. name: string;
  46776. shader: string;
  46777. };
  46778. }
  46779. declare module BABYLON {
  46780. /** @hidden */
  46781. export var pbrPixelShader: {
  46782. name: string;
  46783. shader: string;
  46784. };
  46785. }
  46786. declare module BABYLON {
  46787. /** @hidden */
  46788. export var pbrVertexDeclaration: {
  46789. name: string;
  46790. shader: string;
  46791. };
  46792. }
  46793. declare module BABYLON {
  46794. /** @hidden */
  46795. export var pbrVertexShader: {
  46796. name: string;
  46797. shader: string;
  46798. };
  46799. }
  46800. declare module BABYLON {
  46801. /**
  46802. * Manages the defines for the PBR Material.
  46803. * @hidden
  46804. */
  46805. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46806. PBR: boolean;
  46807. MAINUV1: boolean;
  46808. MAINUV2: boolean;
  46809. UV1: boolean;
  46810. UV2: boolean;
  46811. ALBEDO: boolean;
  46812. ALBEDODIRECTUV: number;
  46813. VERTEXCOLOR: boolean;
  46814. AMBIENT: boolean;
  46815. AMBIENTDIRECTUV: number;
  46816. AMBIENTINGRAYSCALE: boolean;
  46817. OPACITY: boolean;
  46818. VERTEXALPHA: boolean;
  46819. OPACITYDIRECTUV: number;
  46820. OPACITYRGB: boolean;
  46821. ALPHATEST: boolean;
  46822. DEPTHPREPASS: boolean;
  46823. ALPHABLEND: boolean;
  46824. ALPHAFROMALBEDO: boolean;
  46825. ALPHATESTVALUE: string;
  46826. SPECULAROVERALPHA: boolean;
  46827. RADIANCEOVERALPHA: boolean;
  46828. ALPHAFRESNEL: boolean;
  46829. LINEARALPHAFRESNEL: boolean;
  46830. PREMULTIPLYALPHA: boolean;
  46831. EMISSIVE: boolean;
  46832. EMISSIVEDIRECTUV: number;
  46833. REFLECTIVITY: boolean;
  46834. REFLECTIVITYDIRECTUV: number;
  46835. SPECULARTERM: boolean;
  46836. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46837. MICROSURFACEAUTOMATIC: boolean;
  46838. LODBASEDMICROSFURACE: boolean;
  46839. MICROSURFACEMAP: boolean;
  46840. MICROSURFACEMAPDIRECTUV: number;
  46841. METALLICWORKFLOW: boolean;
  46842. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46843. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46844. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46845. AOSTOREINMETALMAPRED: boolean;
  46846. ENVIRONMENTBRDF: boolean;
  46847. ENVIRONMENTBRDF_RGBD: boolean;
  46848. NORMAL: boolean;
  46849. TANGENT: boolean;
  46850. BUMP: boolean;
  46851. BUMPDIRECTUV: number;
  46852. OBJECTSPACE_NORMALMAP: boolean;
  46853. PARALLAX: boolean;
  46854. PARALLAXOCCLUSION: boolean;
  46855. NORMALXYSCALE: boolean;
  46856. LIGHTMAP: boolean;
  46857. LIGHTMAPDIRECTUV: number;
  46858. USELIGHTMAPASSHADOWMAP: boolean;
  46859. GAMMALIGHTMAP: boolean;
  46860. REFLECTION: boolean;
  46861. REFLECTIONMAP_3D: boolean;
  46862. REFLECTIONMAP_SPHERICAL: boolean;
  46863. REFLECTIONMAP_PLANAR: boolean;
  46864. REFLECTIONMAP_CUBIC: boolean;
  46865. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46866. REFLECTIONMAP_PROJECTION: boolean;
  46867. REFLECTIONMAP_SKYBOX: boolean;
  46868. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46869. REFLECTIONMAP_EXPLICIT: boolean;
  46870. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46871. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46872. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46873. INVERTCUBICMAP: boolean;
  46874. USESPHERICALFROMREFLECTIONMAP: boolean;
  46875. USEIRRADIANCEMAP: boolean;
  46876. SPHERICAL_HARMONICS: boolean;
  46877. USESPHERICALINVERTEX: boolean;
  46878. REFLECTIONMAP_OPPOSITEZ: boolean;
  46879. LODINREFLECTIONALPHA: boolean;
  46880. GAMMAREFLECTION: boolean;
  46881. RGBDREFLECTION: boolean;
  46882. LINEARSPECULARREFLECTION: boolean;
  46883. RADIANCEOCCLUSION: boolean;
  46884. HORIZONOCCLUSION: boolean;
  46885. INSTANCES: boolean;
  46886. NUM_BONE_INFLUENCERS: number;
  46887. BonesPerMesh: number;
  46888. BONETEXTURE: boolean;
  46889. NONUNIFORMSCALING: boolean;
  46890. MORPHTARGETS: boolean;
  46891. MORPHTARGETS_NORMAL: boolean;
  46892. MORPHTARGETS_TANGENT: boolean;
  46893. MORPHTARGETS_UV: boolean;
  46894. NUM_MORPH_INFLUENCERS: number;
  46895. IMAGEPROCESSING: boolean;
  46896. VIGNETTE: boolean;
  46897. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46898. VIGNETTEBLENDMODEOPAQUE: boolean;
  46899. TONEMAPPING: boolean;
  46900. TONEMAPPING_ACES: boolean;
  46901. CONTRAST: boolean;
  46902. COLORCURVES: boolean;
  46903. COLORGRADING: boolean;
  46904. COLORGRADING3D: boolean;
  46905. SAMPLER3DGREENDEPTH: boolean;
  46906. SAMPLER3DBGRMAP: boolean;
  46907. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46908. EXPOSURE: boolean;
  46909. MULTIVIEW: boolean;
  46910. USEPHYSICALLIGHTFALLOFF: boolean;
  46911. USEGLTFLIGHTFALLOFF: boolean;
  46912. TWOSIDEDLIGHTING: boolean;
  46913. SHADOWFLOAT: boolean;
  46914. CLIPPLANE: boolean;
  46915. CLIPPLANE2: boolean;
  46916. CLIPPLANE3: boolean;
  46917. CLIPPLANE4: boolean;
  46918. POINTSIZE: boolean;
  46919. FOG: boolean;
  46920. LOGARITHMICDEPTH: boolean;
  46921. FORCENORMALFORWARD: boolean;
  46922. SPECULARAA: boolean;
  46923. CLEARCOAT: boolean;
  46924. CLEARCOAT_DEFAULTIOR: boolean;
  46925. CLEARCOAT_TEXTURE: boolean;
  46926. CLEARCOAT_TEXTUREDIRECTUV: number;
  46927. CLEARCOAT_BUMP: boolean;
  46928. CLEARCOAT_BUMPDIRECTUV: number;
  46929. CLEARCOAT_TINT: boolean;
  46930. CLEARCOAT_TINT_TEXTURE: boolean;
  46931. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46932. ANISOTROPIC: boolean;
  46933. ANISOTROPIC_TEXTURE: boolean;
  46934. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46935. BRDF_V_HEIGHT_CORRELATED: boolean;
  46936. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46937. SHEEN: boolean;
  46938. SHEEN_TEXTURE: boolean;
  46939. SHEEN_TEXTUREDIRECTUV: number;
  46940. SHEEN_LINKWITHALBEDO: boolean;
  46941. SUBSURFACE: boolean;
  46942. SS_REFRACTION: boolean;
  46943. SS_TRANSLUCENCY: boolean;
  46944. SS_SCATERRING: boolean;
  46945. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46946. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46947. SS_REFRACTIONMAP_3D: boolean;
  46948. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46949. SS_LODINREFRACTIONALPHA: boolean;
  46950. SS_GAMMAREFRACTION: boolean;
  46951. SS_RGBDREFRACTION: boolean;
  46952. SS_LINEARSPECULARREFRACTION: boolean;
  46953. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46954. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46955. UNLIT: boolean;
  46956. DEBUGMODE: number;
  46957. /**
  46958. * Initializes the PBR Material defines.
  46959. */
  46960. constructor();
  46961. /**
  46962. * Resets the PBR Material defines.
  46963. */
  46964. reset(): void;
  46965. }
  46966. /**
  46967. * The Physically based material base class of BJS.
  46968. *
  46969. * This offers the main features of a standard PBR material.
  46970. * For more information, please refer to the documentation :
  46971. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46972. */
  46973. export abstract class PBRBaseMaterial extends PushMaterial {
  46974. /**
  46975. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46976. */
  46977. static readonly PBRMATERIAL_OPAQUE: number;
  46978. /**
  46979. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46980. */
  46981. static readonly PBRMATERIAL_ALPHATEST: number;
  46982. /**
  46983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46984. */
  46985. static readonly PBRMATERIAL_ALPHABLEND: number;
  46986. /**
  46987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46988. * They are also discarded below the alpha cutoff threshold to improve performances.
  46989. */
  46990. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46991. /**
  46992. * Defines the default value of how much AO map is occluding the analytical lights
  46993. * (point spot...).
  46994. */
  46995. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46996. /**
  46997. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46998. */
  46999. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47000. /**
  47001. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47002. * to enhance interoperability with other engines.
  47003. */
  47004. static readonly LIGHTFALLOFF_GLTF: number;
  47005. /**
  47006. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47007. * to enhance interoperability with other materials.
  47008. */
  47009. static readonly LIGHTFALLOFF_STANDARD: number;
  47010. /**
  47011. * Intensity of the direct lights e.g. the four lights available in your scene.
  47012. * This impacts both the direct diffuse and specular highlights.
  47013. */
  47014. protected _directIntensity: number;
  47015. /**
  47016. * Intensity of the emissive part of the material.
  47017. * This helps controlling the emissive effect without modifying the emissive color.
  47018. */
  47019. protected _emissiveIntensity: number;
  47020. /**
  47021. * Intensity of the environment e.g. how much the environment will light the object
  47022. * either through harmonics for rough material or through the refelction for shiny ones.
  47023. */
  47024. protected _environmentIntensity: number;
  47025. /**
  47026. * This is a special control allowing the reduction of the specular highlights coming from the
  47027. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47028. */
  47029. protected _specularIntensity: number;
  47030. /**
  47031. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47032. */
  47033. private _lightingInfos;
  47034. /**
  47035. * Debug Control allowing disabling the bump map on this material.
  47036. */
  47037. protected _disableBumpMap: boolean;
  47038. /**
  47039. * AKA Diffuse Texture in standard nomenclature.
  47040. */
  47041. protected _albedoTexture: Nullable<BaseTexture>;
  47042. /**
  47043. * AKA Occlusion Texture in other nomenclature.
  47044. */
  47045. protected _ambientTexture: Nullable<BaseTexture>;
  47046. /**
  47047. * AKA Occlusion Texture Intensity in other nomenclature.
  47048. */
  47049. protected _ambientTextureStrength: number;
  47050. /**
  47051. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47052. * 1 means it completely occludes it
  47053. * 0 mean it has no impact
  47054. */
  47055. protected _ambientTextureImpactOnAnalyticalLights: number;
  47056. /**
  47057. * Stores the alpha values in a texture.
  47058. */
  47059. protected _opacityTexture: Nullable<BaseTexture>;
  47060. /**
  47061. * Stores the reflection values in a texture.
  47062. */
  47063. protected _reflectionTexture: Nullable<BaseTexture>;
  47064. /**
  47065. * Stores the emissive values in a texture.
  47066. */
  47067. protected _emissiveTexture: Nullable<BaseTexture>;
  47068. /**
  47069. * AKA Specular texture in other nomenclature.
  47070. */
  47071. protected _reflectivityTexture: Nullable<BaseTexture>;
  47072. /**
  47073. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47074. */
  47075. protected _metallicTexture: Nullable<BaseTexture>;
  47076. /**
  47077. * Specifies the metallic scalar of the metallic/roughness workflow.
  47078. * Can also be used to scale the metalness values of the metallic texture.
  47079. */
  47080. protected _metallic: Nullable<number>;
  47081. /**
  47082. * Specifies the roughness scalar of the metallic/roughness workflow.
  47083. * Can also be used to scale the roughness values of the metallic texture.
  47084. */
  47085. protected _roughness: Nullable<number>;
  47086. /**
  47087. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47088. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47089. */
  47090. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47091. /**
  47092. * Stores surface normal data used to displace a mesh in a texture.
  47093. */
  47094. protected _bumpTexture: Nullable<BaseTexture>;
  47095. /**
  47096. * Stores the pre-calculated light information of a mesh in a texture.
  47097. */
  47098. protected _lightmapTexture: Nullable<BaseTexture>;
  47099. /**
  47100. * The color of a material in ambient lighting.
  47101. */
  47102. protected _ambientColor: Color3;
  47103. /**
  47104. * AKA Diffuse Color in other nomenclature.
  47105. */
  47106. protected _albedoColor: Color3;
  47107. /**
  47108. * AKA Specular Color in other nomenclature.
  47109. */
  47110. protected _reflectivityColor: Color3;
  47111. /**
  47112. * The color applied when light is reflected from a material.
  47113. */
  47114. protected _reflectionColor: Color3;
  47115. /**
  47116. * The color applied when light is emitted from a material.
  47117. */
  47118. protected _emissiveColor: Color3;
  47119. /**
  47120. * AKA Glossiness in other nomenclature.
  47121. */
  47122. protected _microSurface: number;
  47123. /**
  47124. * Specifies that the material will use the light map as a show map.
  47125. */
  47126. protected _useLightmapAsShadowmap: boolean;
  47127. /**
  47128. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47129. * makes the reflect vector face the model (under horizon).
  47130. */
  47131. protected _useHorizonOcclusion: boolean;
  47132. /**
  47133. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47134. * too much the area relying on ambient texture to define their ambient occlusion.
  47135. */
  47136. protected _useRadianceOcclusion: boolean;
  47137. /**
  47138. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47139. */
  47140. protected _useAlphaFromAlbedoTexture: boolean;
  47141. /**
  47142. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47143. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47144. */
  47145. protected _useSpecularOverAlpha: boolean;
  47146. /**
  47147. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47148. */
  47149. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47150. /**
  47151. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47152. */
  47153. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47154. /**
  47155. * Specifies if the metallic texture contains the roughness information in its green channel.
  47156. */
  47157. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47158. /**
  47159. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47160. */
  47161. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47162. /**
  47163. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47164. */
  47165. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47166. /**
  47167. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47168. */
  47169. protected _useAmbientInGrayScale: boolean;
  47170. /**
  47171. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47172. * The material will try to infer what glossiness each pixel should be.
  47173. */
  47174. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47175. /**
  47176. * Defines the falloff type used in this material.
  47177. * It by default is Physical.
  47178. */
  47179. protected _lightFalloff: number;
  47180. /**
  47181. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47182. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47183. */
  47184. protected _useRadianceOverAlpha: boolean;
  47185. /**
  47186. * Allows using an object space normal map (instead of tangent space).
  47187. */
  47188. protected _useObjectSpaceNormalMap: boolean;
  47189. /**
  47190. * Allows using the bump map in parallax mode.
  47191. */
  47192. protected _useParallax: boolean;
  47193. /**
  47194. * Allows using the bump map in parallax occlusion mode.
  47195. */
  47196. protected _useParallaxOcclusion: boolean;
  47197. /**
  47198. * Controls the scale bias of the parallax mode.
  47199. */
  47200. protected _parallaxScaleBias: number;
  47201. /**
  47202. * If sets to true, disables all the lights affecting the material.
  47203. */
  47204. protected _disableLighting: boolean;
  47205. /**
  47206. * Number of Simultaneous lights allowed on the material.
  47207. */
  47208. protected _maxSimultaneousLights: number;
  47209. /**
  47210. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47211. */
  47212. protected _invertNormalMapX: boolean;
  47213. /**
  47214. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47215. */
  47216. protected _invertNormalMapY: boolean;
  47217. /**
  47218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47219. */
  47220. protected _twoSidedLighting: boolean;
  47221. /**
  47222. * Defines the alpha limits in alpha test mode.
  47223. */
  47224. protected _alphaCutOff: number;
  47225. /**
  47226. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47227. */
  47228. protected _forceAlphaTest: boolean;
  47229. /**
  47230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47231. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47232. */
  47233. protected _useAlphaFresnel: boolean;
  47234. /**
  47235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47236. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47237. */
  47238. protected _useLinearAlphaFresnel: boolean;
  47239. /**
  47240. * The transparency mode of the material.
  47241. */
  47242. protected _transparencyMode: Nullable<number>;
  47243. /**
  47244. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47245. * from cos thetav and roughness:
  47246. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47247. */
  47248. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47249. /**
  47250. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47251. */
  47252. protected _forceIrradianceInFragment: boolean;
  47253. /**
  47254. * Force normal to face away from face.
  47255. */
  47256. protected _forceNormalForward: boolean;
  47257. /**
  47258. * Enables specular anti aliasing in the PBR shader.
  47259. * It will both interacts on the Geometry for analytical and IBL lighting.
  47260. * It also prefilter the roughness map based on the bump values.
  47261. */
  47262. protected _enableSpecularAntiAliasing: boolean;
  47263. /**
  47264. * Default configuration related to image processing available in the PBR Material.
  47265. */
  47266. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47267. /**
  47268. * Keep track of the image processing observer to allow dispose and replace.
  47269. */
  47270. private _imageProcessingObserver;
  47271. /**
  47272. * Attaches a new image processing configuration to the PBR Material.
  47273. * @param configuration
  47274. */
  47275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47276. /**
  47277. * Stores the available render targets.
  47278. */
  47279. private _renderTargets;
  47280. /**
  47281. * Sets the global ambient color for the material used in lighting calculations.
  47282. */
  47283. private _globalAmbientColor;
  47284. /**
  47285. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47286. */
  47287. private _useLogarithmicDepth;
  47288. /**
  47289. * If set to true, no lighting calculations will be applied.
  47290. */
  47291. private _unlit;
  47292. private _debugMode;
  47293. /**
  47294. * @hidden
  47295. * This is reserved for the inspector.
  47296. * Defines the material debug mode.
  47297. * It helps seeing only some components of the material while troubleshooting.
  47298. */
  47299. debugMode: number;
  47300. /**
  47301. * @hidden
  47302. * This is reserved for the inspector.
  47303. * Specify from where on screen the debug mode should start.
  47304. * The value goes from -1 (full screen) to 1 (not visible)
  47305. * It helps with side by side comparison against the final render
  47306. * This defaults to -1
  47307. */
  47308. private debugLimit;
  47309. /**
  47310. * @hidden
  47311. * This is reserved for the inspector.
  47312. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47313. * You can use the factor to better multiply the final value.
  47314. */
  47315. private debugFactor;
  47316. /**
  47317. * Defines the clear coat layer parameters for the material.
  47318. */
  47319. readonly clearCoat: PBRClearCoatConfiguration;
  47320. /**
  47321. * Defines the anisotropic parameters for the material.
  47322. */
  47323. readonly anisotropy: PBRAnisotropicConfiguration;
  47324. /**
  47325. * Defines the BRDF parameters for the material.
  47326. */
  47327. readonly brdf: PBRBRDFConfiguration;
  47328. /**
  47329. * Defines the Sheen parameters for the material.
  47330. */
  47331. readonly sheen: PBRSheenConfiguration;
  47332. /**
  47333. * Defines the SubSurface parameters for the material.
  47334. */
  47335. readonly subSurface: PBRSubSurfaceConfiguration;
  47336. /**
  47337. * Custom callback helping to override the default shader used in the material.
  47338. */
  47339. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47340. protected _rebuildInParallel: boolean;
  47341. /**
  47342. * Instantiates a new PBRMaterial instance.
  47343. *
  47344. * @param name The material name
  47345. * @param scene The scene the material will be use in.
  47346. */
  47347. constructor(name: string, scene: Scene);
  47348. /**
  47349. * Gets a boolean indicating that current material needs to register RTT
  47350. */
  47351. readonly hasRenderTargetTextures: boolean;
  47352. /**
  47353. * Gets the name of the material class.
  47354. */
  47355. getClassName(): string;
  47356. /**
  47357. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47358. */
  47359. /**
  47360. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47361. */
  47362. useLogarithmicDepth: boolean;
  47363. /**
  47364. * Gets the current transparency mode.
  47365. */
  47366. /**
  47367. * Sets the transparency mode of the material.
  47368. *
  47369. * | Value | Type | Description |
  47370. * | ----- | ----------------------------------- | ----------- |
  47371. * | 0 | OPAQUE | |
  47372. * | 1 | ALPHATEST | |
  47373. * | 2 | ALPHABLEND | |
  47374. * | 3 | ALPHATESTANDBLEND | |
  47375. *
  47376. */
  47377. transparencyMode: Nullable<number>;
  47378. /**
  47379. * Returns true if alpha blending should be disabled.
  47380. */
  47381. private readonly _disableAlphaBlending;
  47382. /**
  47383. * Specifies whether or not this material should be rendered in alpha blend mode.
  47384. */
  47385. needAlphaBlending(): boolean;
  47386. /**
  47387. * Specifies if the mesh will require alpha blending.
  47388. * @param mesh - BJS mesh.
  47389. */
  47390. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47391. /**
  47392. * Specifies whether or not this material should be rendered in alpha test mode.
  47393. */
  47394. needAlphaTesting(): boolean;
  47395. /**
  47396. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47397. */
  47398. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47399. /**
  47400. * Gets the texture used for the alpha test.
  47401. */
  47402. getAlphaTestTexture(): Nullable<BaseTexture>;
  47403. /**
  47404. * Specifies that the submesh is ready to be used.
  47405. * @param mesh - BJS mesh.
  47406. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47407. * @param useInstances - Specifies that instances should be used.
  47408. * @returns - boolean indicating that the submesh is ready or not.
  47409. */
  47410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47411. /**
  47412. * Specifies if the material uses metallic roughness workflow.
  47413. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47414. */
  47415. isMetallicWorkflow(): boolean;
  47416. private _prepareEffect;
  47417. private _prepareDefines;
  47418. /**
  47419. * Force shader compilation
  47420. */
  47421. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47422. clipPlane: boolean;
  47423. }>): void;
  47424. /**
  47425. * Initializes the uniform buffer layout for the shader.
  47426. */
  47427. buildUniformLayout(): void;
  47428. /**
  47429. * Unbinds the material from the mesh
  47430. */
  47431. unbind(): void;
  47432. /**
  47433. * Binds the submesh data.
  47434. * @param world - The world matrix.
  47435. * @param mesh - The BJS mesh.
  47436. * @param subMesh - A submesh of the BJS mesh.
  47437. */
  47438. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47439. /**
  47440. * Returns the animatable textures.
  47441. * @returns - Array of animatable textures.
  47442. */
  47443. getAnimatables(): IAnimatable[];
  47444. /**
  47445. * Returns the texture used for reflections.
  47446. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47447. */
  47448. private _getReflectionTexture;
  47449. /**
  47450. * Returns an array of the actively used textures.
  47451. * @returns - Array of BaseTextures
  47452. */
  47453. getActiveTextures(): BaseTexture[];
  47454. /**
  47455. * Checks to see if a texture is used in the material.
  47456. * @param texture - Base texture to use.
  47457. * @returns - Boolean specifying if a texture is used in the material.
  47458. */
  47459. hasTexture(texture: BaseTexture): boolean;
  47460. /**
  47461. * Disposes the resources of the material.
  47462. * @param forceDisposeEffect - Forces the disposal of effects.
  47463. * @param forceDisposeTextures - Forces the disposal of all textures.
  47464. */
  47465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * The Physically based material of BJS.
  47471. *
  47472. * This offers the main features of a standard PBR material.
  47473. * For more information, please refer to the documentation :
  47474. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47475. */
  47476. export class PBRMaterial extends PBRBaseMaterial {
  47477. /**
  47478. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47479. */
  47480. static readonly PBRMATERIAL_OPAQUE: number;
  47481. /**
  47482. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47483. */
  47484. static readonly PBRMATERIAL_ALPHATEST: number;
  47485. /**
  47486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47487. */
  47488. static readonly PBRMATERIAL_ALPHABLEND: number;
  47489. /**
  47490. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47491. * They are also discarded below the alpha cutoff threshold to improve performances.
  47492. */
  47493. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47494. /**
  47495. * Defines the default value of how much AO map is occluding the analytical lights
  47496. * (point spot...).
  47497. */
  47498. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47499. /**
  47500. * Intensity of the direct lights e.g. the four lights available in your scene.
  47501. * This impacts both the direct diffuse and specular highlights.
  47502. */
  47503. directIntensity: number;
  47504. /**
  47505. * Intensity of the emissive part of the material.
  47506. * This helps controlling the emissive effect without modifying the emissive color.
  47507. */
  47508. emissiveIntensity: number;
  47509. /**
  47510. * Intensity of the environment e.g. how much the environment will light the object
  47511. * either through harmonics for rough material or through the refelction for shiny ones.
  47512. */
  47513. environmentIntensity: number;
  47514. /**
  47515. * This is a special control allowing the reduction of the specular highlights coming from the
  47516. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47517. */
  47518. specularIntensity: number;
  47519. /**
  47520. * Debug Control allowing disabling the bump map on this material.
  47521. */
  47522. disableBumpMap: boolean;
  47523. /**
  47524. * AKA Diffuse Texture in standard nomenclature.
  47525. */
  47526. albedoTexture: BaseTexture;
  47527. /**
  47528. * AKA Occlusion Texture in other nomenclature.
  47529. */
  47530. ambientTexture: BaseTexture;
  47531. /**
  47532. * AKA Occlusion Texture Intensity in other nomenclature.
  47533. */
  47534. ambientTextureStrength: number;
  47535. /**
  47536. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47537. * 1 means it completely occludes it
  47538. * 0 mean it has no impact
  47539. */
  47540. ambientTextureImpactOnAnalyticalLights: number;
  47541. /**
  47542. * Stores the alpha values in a texture.
  47543. */
  47544. opacityTexture: BaseTexture;
  47545. /**
  47546. * Stores the reflection values in a texture.
  47547. */
  47548. reflectionTexture: Nullable<BaseTexture>;
  47549. /**
  47550. * Stores the emissive values in a texture.
  47551. */
  47552. emissiveTexture: BaseTexture;
  47553. /**
  47554. * AKA Specular texture in other nomenclature.
  47555. */
  47556. reflectivityTexture: BaseTexture;
  47557. /**
  47558. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47559. */
  47560. metallicTexture: BaseTexture;
  47561. /**
  47562. * Specifies the metallic scalar of the metallic/roughness workflow.
  47563. * Can also be used to scale the metalness values of the metallic texture.
  47564. */
  47565. metallic: Nullable<number>;
  47566. /**
  47567. * Specifies the roughness scalar of the metallic/roughness workflow.
  47568. * Can also be used to scale the roughness values of the metallic texture.
  47569. */
  47570. roughness: Nullable<number>;
  47571. /**
  47572. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47573. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47574. */
  47575. microSurfaceTexture: BaseTexture;
  47576. /**
  47577. * Stores surface normal data used to displace a mesh in a texture.
  47578. */
  47579. bumpTexture: BaseTexture;
  47580. /**
  47581. * Stores the pre-calculated light information of a mesh in a texture.
  47582. */
  47583. lightmapTexture: BaseTexture;
  47584. /**
  47585. * Stores the refracted light information in a texture.
  47586. */
  47587. refractionTexture: Nullable<BaseTexture>;
  47588. /**
  47589. * The color of a material in ambient lighting.
  47590. */
  47591. ambientColor: Color3;
  47592. /**
  47593. * AKA Diffuse Color in other nomenclature.
  47594. */
  47595. albedoColor: Color3;
  47596. /**
  47597. * AKA Specular Color in other nomenclature.
  47598. */
  47599. reflectivityColor: Color3;
  47600. /**
  47601. * The color reflected from the material.
  47602. */
  47603. reflectionColor: Color3;
  47604. /**
  47605. * The color emitted from the material.
  47606. */
  47607. emissiveColor: Color3;
  47608. /**
  47609. * AKA Glossiness in other nomenclature.
  47610. */
  47611. microSurface: number;
  47612. /**
  47613. * source material index of refraction (IOR)' / 'destination material IOR.
  47614. */
  47615. indexOfRefraction: number;
  47616. /**
  47617. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47618. */
  47619. invertRefractionY: boolean;
  47620. /**
  47621. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47622. * Materials half opaque for instance using refraction could benefit from this control.
  47623. */
  47624. linkRefractionWithTransparency: boolean;
  47625. /**
  47626. * If true, the light map contains occlusion information instead of lighting info.
  47627. */
  47628. useLightmapAsShadowmap: boolean;
  47629. /**
  47630. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47631. */
  47632. useAlphaFromAlbedoTexture: boolean;
  47633. /**
  47634. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47635. */
  47636. forceAlphaTest: boolean;
  47637. /**
  47638. * Defines the alpha limits in alpha test mode.
  47639. */
  47640. alphaCutOff: number;
  47641. /**
  47642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47644. */
  47645. useSpecularOverAlpha: boolean;
  47646. /**
  47647. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47648. */
  47649. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47650. /**
  47651. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47652. */
  47653. useRoughnessFromMetallicTextureAlpha: boolean;
  47654. /**
  47655. * Specifies if the metallic texture contains the roughness information in its green channel.
  47656. */
  47657. useRoughnessFromMetallicTextureGreen: boolean;
  47658. /**
  47659. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47660. */
  47661. useMetallnessFromMetallicTextureBlue: boolean;
  47662. /**
  47663. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47664. */
  47665. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47666. /**
  47667. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47668. */
  47669. useAmbientInGrayScale: boolean;
  47670. /**
  47671. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47672. * The material will try to infer what glossiness each pixel should be.
  47673. */
  47674. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47675. /**
  47676. * BJS is using an harcoded light falloff based on a manually sets up range.
  47677. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47678. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47679. */
  47680. /**
  47681. * BJS is using an harcoded light falloff based on a manually sets up range.
  47682. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47683. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47684. */
  47685. usePhysicalLightFalloff: boolean;
  47686. /**
  47687. * In order to support the falloff compatibility with gltf, a special mode has been added
  47688. * to reproduce the gltf light falloff.
  47689. */
  47690. /**
  47691. * In order to support the falloff compatibility with gltf, a special mode has been added
  47692. * to reproduce the gltf light falloff.
  47693. */
  47694. useGLTFLightFalloff: boolean;
  47695. /**
  47696. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47697. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47698. */
  47699. useRadianceOverAlpha: boolean;
  47700. /**
  47701. * Allows using an object space normal map (instead of tangent space).
  47702. */
  47703. useObjectSpaceNormalMap: boolean;
  47704. /**
  47705. * Allows using the bump map in parallax mode.
  47706. */
  47707. useParallax: boolean;
  47708. /**
  47709. * Allows using the bump map in parallax occlusion mode.
  47710. */
  47711. useParallaxOcclusion: boolean;
  47712. /**
  47713. * Controls the scale bias of the parallax mode.
  47714. */
  47715. parallaxScaleBias: number;
  47716. /**
  47717. * If sets to true, disables all the lights affecting the material.
  47718. */
  47719. disableLighting: boolean;
  47720. /**
  47721. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47722. */
  47723. forceIrradianceInFragment: boolean;
  47724. /**
  47725. * Number of Simultaneous lights allowed on the material.
  47726. */
  47727. maxSimultaneousLights: number;
  47728. /**
  47729. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47730. */
  47731. invertNormalMapX: boolean;
  47732. /**
  47733. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47734. */
  47735. invertNormalMapY: boolean;
  47736. /**
  47737. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47738. */
  47739. twoSidedLighting: boolean;
  47740. /**
  47741. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47742. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47743. */
  47744. useAlphaFresnel: boolean;
  47745. /**
  47746. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47747. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47748. */
  47749. useLinearAlphaFresnel: boolean;
  47750. /**
  47751. * Let user defines the brdf lookup texture used for IBL.
  47752. * A default 8bit version is embedded but you could point at :
  47753. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47754. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47755. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47756. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47757. */
  47758. environmentBRDFTexture: Nullable<BaseTexture>;
  47759. /**
  47760. * Force normal to face away from face.
  47761. */
  47762. forceNormalForward: boolean;
  47763. /**
  47764. * Enables specular anti aliasing in the PBR shader.
  47765. * It will both interacts on the Geometry for analytical and IBL lighting.
  47766. * It also prefilter the roughness map based on the bump values.
  47767. */
  47768. enableSpecularAntiAliasing: boolean;
  47769. /**
  47770. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47771. * makes the reflect vector face the model (under horizon).
  47772. */
  47773. useHorizonOcclusion: boolean;
  47774. /**
  47775. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47776. * too much the area relying on ambient texture to define their ambient occlusion.
  47777. */
  47778. useRadianceOcclusion: boolean;
  47779. /**
  47780. * If set to true, no lighting calculations will be applied.
  47781. */
  47782. unlit: boolean;
  47783. /**
  47784. * Gets the image processing configuration used either in this material.
  47785. */
  47786. /**
  47787. * Sets the Default image processing configuration used either in the this material.
  47788. *
  47789. * If sets to null, the scene one is in use.
  47790. */
  47791. imageProcessingConfiguration: ImageProcessingConfiguration;
  47792. /**
  47793. * Gets wether the color curves effect is enabled.
  47794. */
  47795. /**
  47796. * Sets wether the color curves effect is enabled.
  47797. */
  47798. cameraColorCurvesEnabled: boolean;
  47799. /**
  47800. * Gets wether the color grading effect is enabled.
  47801. */
  47802. /**
  47803. * Gets wether the color grading effect is enabled.
  47804. */
  47805. cameraColorGradingEnabled: boolean;
  47806. /**
  47807. * Gets wether tonemapping is enabled or not.
  47808. */
  47809. /**
  47810. * Sets wether tonemapping is enabled or not
  47811. */
  47812. cameraToneMappingEnabled: boolean;
  47813. /**
  47814. * The camera exposure used on this material.
  47815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47816. * This corresponds to a photographic exposure.
  47817. */
  47818. /**
  47819. * The camera exposure used on this material.
  47820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47821. * This corresponds to a photographic exposure.
  47822. */
  47823. cameraExposure: number;
  47824. /**
  47825. * Gets The camera contrast used on this material.
  47826. */
  47827. /**
  47828. * Sets The camera contrast used on this material.
  47829. */
  47830. cameraContrast: number;
  47831. /**
  47832. * Gets the Color Grading 2D Lookup Texture.
  47833. */
  47834. /**
  47835. * Sets the Color Grading 2D Lookup Texture.
  47836. */
  47837. cameraColorGradingTexture: Nullable<BaseTexture>;
  47838. /**
  47839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47841. * 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;
  47842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47843. */
  47844. /**
  47845. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47846. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47847. * 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;
  47848. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47849. */
  47850. cameraColorCurves: Nullable<ColorCurves>;
  47851. /**
  47852. * Instantiates a new PBRMaterial instance.
  47853. *
  47854. * @param name The material name
  47855. * @param scene The scene the material will be use in.
  47856. */
  47857. constructor(name: string, scene: Scene);
  47858. /**
  47859. * Returns the name of this material class.
  47860. */
  47861. getClassName(): string;
  47862. /**
  47863. * Makes a duplicate of the current material.
  47864. * @param name - name to use for the new material.
  47865. */
  47866. clone(name: string): PBRMaterial;
  47867. /**
  47868. * Serializes this PBR Material.
  47869. * @returns - An object with the serialized material.
  47870. */
  47871. serialize(): any;
  47872. /**
  47873. * Parses a PBR Material from a serialized object.
  47874. * @param source - Serialized object.
  47875. * @param scene - BJS scene instance.
  47876. * @param rootUrl - url for the scene object
  47877. * @returns - PBRMaterial
  47878. */
  47879. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47880. }
  47881. }
  47882. declare module BABYLON {
  47883. /**
  47884. * Direct draw surface info
  47885. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47886. */
  47887. export interface DDSInfo {
  47888. /**
  47889. * Width of the texture
  47890. */
  47891. width: number;
  47892. /**
  47893. * Width of the texture
  47894. */
  47895. height: number;
  47896. /**
  47897. * Number of Mipmaps for the texture
  47898. * @see https://en.wikipedia.org/wiki/Mipmap
  47899. */
  47900. mipmapCount: number;
  47901. /**
  47902. * If the textures format is a known fourCC format
  47903. * @see https://www.fourcc.org/
  47904. */
  47905. isFourCC: boolean;
  47906. /**
  47907. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47908. */
  47909. isRGB: boolean;
  47910. /**
  47911. * If the texture is a lumincance format
  47912. */
  47913. isLuminance: boolean;
  47914. /**
  47915. * If this is a cube texture
  47916. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47917. */
  47918. isCube: boolean;
  47919. /**
  47920. * If the texture is a compressed format eg. FOURCC_DXT1
  47921. */
  47922. isCompressed: boolean;
  47923. /**
  47924. * The dxgiFormat of the texture
  47925. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47926. */
  47927. dxgiFormat: number;
  47928. /**
  47929. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47930. */
  47931. textureType: number;
  47932. /**
  47933. * Sphericle polynomial created for the dds texture
  47934. */
  47935. sphericalPolynomial?: SphericalPolynomial;
  47936. }
  47937. /**
  47938. * Class used to provide DDS decompression tools
  47939. */
  47940. export class DDSTools {
  47941. /**
  47942. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47943. */
  47944. static StoreLODInAlphaChannel: boolean;
  47945. /**
  47946. * Gets DDS information from an array buffer
  47947. * @param arrayBuffer defines the array buffer to read data from
  47948. * @returns the DDS information
  47949. */
  47950. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47951. private static _FloatView;
  47952. private static _Int32View;
  47953. private static _ToHalfFloat;
  47954. private static _FromHalfFloat;
  47955. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47956. private static _GetHalfFloatRGBAArrayBuffer;
  47957. private static _GetFloatRGBAArrayBuffer;
  47958. private static _GetFloatAsUIntRGBAArrayBuffer;
  47959. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47960. private static _GetRGBAArrayBuffer;
  47961. private static _ExtractLongWordOrder;
  47962. private static _GetRGBArrayBuffer;
  47963. private static _GetLuminanceArrayBuffer;
  47964. /**
  47965. * Uploads DDS Levels to a Babylon Texture
  47966. * @hidden
  47967. */
  47968. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47969. }
  47970. interface Engine {
  47971. /**
  47972. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47973. * @param rootUrl defines the url where the file to load is located
  47974. * @param scene defines the current scene
  47975. * @param lodScale defines scale to apply to the mip map selection
  47976. * @param lodOffset defines offset to apply to the mip map selection
  47977. * @param onLoad defines an optional callback raised when the texture is loaded
  47978. * @param onError defines an optional callback raised if there is an issue to load the texture
  47979. * @param format defines the format of the data
  47980. * @param forcedExtension defines the extension to use to pick the right loader
  47981. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47982. * @returns the cube texture as an InternalTexture
  47983. */
  47984. 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;
  47985. }
  47986. }
  47987. declare module BABYLON {
  47988. /**
  47989. * Implementation of the DDS Texture Loader.
  47990. * @hidden
  47991. */
  47992. export class _DDSTextureLoader implements IInternalTextureLoader {
  47993. /**
  47994. * Defines wether the loader supports cascade loading the different faces.
  47995. */
  47996. readonly supportCascades: boolean;
  47997. /**
  47998. * This returns if the loader support the current file information.
  47999. * @param extension defines the file extension of the file being loaded
  48000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48001. * @param fallback defines the fallback internal texture if any
  48002. * @param isBase64 defines whether the texture is encoded as a base64
  48003. * @param isBuffer defines whether the texture data are stored as a buffer
  48004. * @returns true if the loader can load the specified file
  48005. */
  48006. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48007. /**
  48008. * Transform the url before loading if required.
  48009. * @param rootUrl the url of the texture
  48010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48011. * @returns the transformed texture
  48012. */
  48013. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48014. /**
  48015. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48016. * @param rootUrl the url of the texture
  48017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48018. * @returns the fallback texture
  48019. */
  48020. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48021. /**
  48022. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48023. * @param data contains the texture data
  48024. * @param texture defines the BabylonJS internal texture
  48025. * @param createPolynomials will be true if polynomials have been requested
  48026. * @param onLoad defines the callback to trigger once the texture is ready
  48027. * @param onError defines the callback to trigger in case of error
  48028. */
  48029. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48030. /**
  48031. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48032. * @param data contains the texture data
  48033. * @param texture defines the BabylonJS internal texture
  48034. * @param callback defines the method to call once ready to upload
  48035. */
  48036. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48037. }
  48038. }
  48039. declare module BABYLON {
  48040. /**
  48041. * Implementation of the ENV Texture Loader.
  48042. * @hidden
  48043. */
  48044. export class _ENVTextureLoader implements IInternalTextureLoader {
  48045. /**
  48046. * Defines wether the loader supports cascade loading the different faces.
  48047. */
  48048. readonly supportCascades: boolean;
  48049. /**
  48050. * This returns if the loader support the current file information.
  48051. * @param extension defines the file extension of the file being loaded
  48052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48053. * @param fallback defines the fallback internal texture if any
  48054. * @param isBase64 defines whether the texture is encoded as a base64
  48055. * @param isBuffer defines whether the texture data are stored as a buffer
  48056. * @returns true if the loader can load the specified file
  48057. */
  48058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48059. /**
  48060. * Transform the url before loading if required.
  48061. * @param rootUrl the url of the texture
  48062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48063. * @returns the transformed texture
  48064. */
  48065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48066. /**
  48067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48068. * @param rootUrl the url of the texture
  48069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48070. * @returns the fallback texture
  48071. */
  48072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48073. /**
  48074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48075. * @param data contains the texture data
  48076. * @param texture defines the BabylonJS internal texture
  48077. * @param createPolynomials will be true if polynomials have been requested
  48078. * @param onLoad defines the callback to trigger once the texture is ready
  48079. * @param onError defines the callback to trigger in case of error
  48080. */
  48081. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48082. /**
  48083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48084. * @param data contains the texture data
  48085. * @param texture defines the BabylonJS internal texture
  48086. * @param callback defines the method to call once ready to upload
  48087. */
  48088. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48089. }
  48090. }
  48091. declare module BABYLON {
  48092. /**
  48093. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48094. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48095. */
  48096. export class KhronosTextureContainer {
  48097. /** contents of the KTX container file */
  48098. arrayBuffer: any;
  48099. private static HEADER_LEN;
  48100. private static COMPRESSED_2D;
  48101. private static COMPRESSED_3D;
  48102. private static TEX_2D;
  48103. private static TEX_3D;
  48104. /**
  48105. * Gets the openGL type
  48106. */
  48107. glType: number;
  48108. /**
  48109. * Gets the openGL type size
  48110. */
  48111. glTypeSize: number;
  48112. /**
  48113. * Gets the openGL format
  48114. */
  48115. glFormat: number;
  48116. /**
  48117. * Gets the openGL internal format
  48118. */
  48119. glInternalFormat: number;
  48120. /**
  48121. * Gets the base internal format
  48122. */
  48123. glBaseInternalFormat: number;
  48124. /**
  48125. * Gets image width in pixel
  48126. */
  48127. pixelWidth: number;
  48128. /**
  48129. * Gets image height in pixel
  48130. */
  48131. pixelHeight: number;
  48132. /**
  48133. * Gets image depth in pixels
  48134. */
  48135. pixelDepth: number;
  48136. /**
  48137. * Gets the number of array elements
  48138. */
  48139. numberOfArrayElements: number;
  48140. /**
  48141. * Gets the number of faces
  48142. */
  48143. numberOfFaces: number;
  48144. /**
  48145. * Gets the number of mipmap levels
  48146. */
  48147. numberOfMipmapLevels: number;
  48148. /**
  48149. * Gets the bytes of key value data
  48150. */
  48151. bytesOfKeyValueData: number;
  48152. /**
  48153. * Gets the load type
  48154. */
  48155. loadType: number;
  48156. /**
  48157. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48158. */
  48159. isInvalid: boolean;
  48160. /**
  48161. * Creates a new KhronosTextureContainer
  48162. * @param arrayBuffer contents of the KTX container file
  48163. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48164. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48165. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48166. */
  48167. constructor(
  48168. /** contents of the KTX container file */
  48169. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48170. /**
  48171. * Uploads KTX content to a Babylon Texture.
  48172. * It is assumed that the texture has already been created & is currently bound
  48173. * @hidden
  48174. */
  48175. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48176. private _upload2DCompressedLevels;
  48177. }
  48178. }
  48179. declare module BABYLON {
  48180. /**
  48181. * Implementation of the KTX Texture Loader.
  48182. * @hidden
  48183. */
  48184. export class _KTXTextureLoader implements IInternalTextureLoader {
  48185. /**
  48186. * Defines wether the loader supports cascade loading the different faces.
  48187. */
  48188. readonly supportCascades: boolean;
  48189. /**
  48190. * This returns if the loader support the current file information.
  48191. * @param extension defines the file extension of the file being loaded
  48192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48193. * @param fallback defines the fallback internal texture if any
  48194. * @param isBase64 defines whether the texture is encoded as a base64
  48195. * @param isBuffer defines whether the texture data are stored as a buffer
  48196. * @returns true if the loader can load the specified file
  48197. */
  48198. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48199. /**
  48200. * Transform the url before loading if required.
  48201. * @param rootUrl the url of the texture
  48202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48203. * @returns the transformed texture
  48204. */
  48205. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48206. /**
  48207. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48208. * @param rootUrl the url of the texture
  48209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48210. * @returns the fallback texture
  48211. */
  48212. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48213. /**
  48214. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48215. * @param data contains the texture data
  48216. * @param texture defines the BabylonJS internal texture
  48217. * @param createPolynomials will be true if polynomials have been requested
  48218. * @param onLoad defines the callback to trigger once the texture is ready
  48219. * @param onError defines the callback to trigger in case of error
  48220. */
  48221. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48222. /**
  48223. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48224. * @param data contains the texture data
  48225. * @param texture defines the BabylonJS internal texture
  48226. * @param callback defines the method to call once ready to upload
  48227. */
  48228. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48229. }
  48230. }
  48231. declare module BABYLON {
  48232. /**
  48233. * Options for the default xr helper
  48234. */
  48235. export class WebXRDefaultExperienceOptions {
  48236. /**
  48237. * Floor meshes that should be used for teleporting
  48238. */
  48239. floorMeshes: Array<AbstractMesh>;
  48240. }
  48241. /**
  48242. * Default experience which provides a similar setup to the previous webVRExperience
  48243. */
  48244. export class WebXRDefaultExperience {
  48245. /**
  48246. * Base experience
  48247. */
  48248. baseExperience: WebXRExperienceHelper;
  48249. /**
  48250. * Input experience extension
  48251. */
  48252. input: WebXRInput;
  48253. /**
  48254. * Loads the controller models
  48255. */
  48256. controllerModelLoader: WebXRControllerModelLoader;
  48257. /**
  48258. * Enables laser pointer and selection
  48259. */
  48260. pointerSelection: WebXRControllerPointerSelection;
  48261. /**
  48262. * Enables teleportation
  48263. */
  48264. teleportation: WebXRControllerTeleportation;
  48265. /**
  48266. * Enables ui for enetering/exiting xr
  48267. */
  48268. enterExitUI: WebXREnterExitUI;
  48269. /**
  48270. * Default output canvas xr should render to
  48271. */
  48272. outputCanvas: WebXRManagedOutputCanvas;
  48273. /**
  48274. * Creates the default xr experience
  48275. * @param scene scene
  48276. * @param options options for basic configuration
  48277. * @returns resulting WebXRDefaultExperience
  48278. */
  48279. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48280. private constructor();
  48281. /**
  48282. * DIsposes of the experience helper
  48283. */
  48284. dispose(): void;
  48285. }
  48286. }
  48287. declare module BABYLON {
  48288. /** @hidden */
  48289. export var _forceSceneHelpersToBundle: boolean;
  48290. interface Scene {
  48291. /**
  48292. * Creates a default light for the scene.
  48293. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48294. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48295. */
  48296. createDefaultLight(replace?: boolean): void;
  48297. /**
  48298. * Creates a default camera for the scene.
  48299. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48300. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48301. * @param replace has default false, when true replaces the active camera in the scene
  48302. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48303. */
  48304. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48305. /**
  48306. * Creates a default camera and a default light.
  48307. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48308. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48309. * @param replace has the default false, when true replaces the active camera/light in the scene
  48310. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48311. */
  48312. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48313. /**
  48314. * Creates a new sky box
  48315. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48316. * @param environmentTexture defines the texture to use as environment texture
  48317. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48318. * @param scale defines the overall scale of the skybox
  48319. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48320. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48321. * @returns a new mesh holding the sky box
  48322. */
  48323. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48324. /**
  48325. * Creates a new environment
  48326. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48327. * @param options defines the options you can use to configure the environment
  48328. * @returns the new EnvironmentHelper
  48329. */
  48330. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48331. /**
  48332. * Creates a new VREXperienceHelper
  48333. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48334. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48335. * @returns a new VREXperienceHelper
  48336. */
  48337. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48338. /**
  48339. * Creates a new WebXRDefaultExperience
  48340. * @see http://doc.babylonjs.com/how_to/webxr
  48341. * @param options experience options
  48342. * @returns a promise for a new WebXRDefaultExperience
  48343. */
  48344. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48345. }
  48346. }
  48347. declare module BABYLON {
  48348. /**
  48349. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48350. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48351. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48352. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48353. */
  48354. export class VideoDome extends TransformNode {
  48355. /**
  48356. * Define the video source as a Monoscopic panoramic 360 video.
  48357. */
  48358. static readonly MODE_MONOSCOPIC: number;
  48359. /**
  48360. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48361. */
  48362. static readonly MODE_TOPBOTTOM: number;
  48363. /**
  48364. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48365. */
  48366. static readonly MODE_SIDEBYSIDE: number;
  48367. private _halfDome;
  48368. private _useDirectMapping;
  48369. /**
  48370. * The video texture being displayed on the sphere
  48371. */
  48372. protected _videoTexture: VideoTexture;
  48373. /**
  48374. * Gets the video texture being displayed on the sphere
  48375. */
  48376. readonly videoTexture: VideoTexture;
  48377. /**
  48378. * The skybox material
  48379. */
  48380. protected _material: BackgroundMaterial;
  48381. /**
  48382. * The surface used for the skybox
  48383. */
  48384. protected _mesh: Mesh;
  48385. /**
  48386. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48387. */
  48388. private _halfDomeMask;
  48389. /**
  48390. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48391. * Also see the options.resolution property.
  48392. */
  48393. fovMultiplier: number;
  48394. private _videoMode;
  48395. /**
  48396. * Gets or set the current video mode for the video. It can be:
  48397. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48398. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48399. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48400. */
  48401. videoMode: number;
  48402. /**
  48403. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48404. *
  48405. */
  48406. /**
  48407. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48408. */
  48409. halfDome: boolean;
  48410. /**
  48411. * Oberserver used in Stereoscopic VR Mode.
  48412. */
  48413. private _onBeforeCameraRenderObserver;
  48414. /**
  48415. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48416. * @param name Element's name, child elements will append suffixes for their own names.
  48417. * @param urlsOrVideo defines the url(s) or the video element to use
  48418. * @param options An object containing optional or exposed sub element properties
  48419. */
  48420. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48421. resolution?: number;
  48422. clickToPlay?: boolean;
  48423. autoPlay?: boolean;
  48424. loop?: boolean;
  48425. size?: number;
  48426. poster?: string;
  48427. faceForward?: boolean;
  48428. useDirectMapping?: boolean;
  48429. halfDomeMode?: boolean;
  48430. }, scene: Scene);
  48431. private _changeVideoMode;
  48432. /**
  48433. * Releases resources associated with this node.
  48434. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48435. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48436. */
  48437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48438. }
  48439. }
  48440. declare module BABYLON {
  48441. /**
  48442. * This class can be used to get instrumentation data from a Babylon engine
  48443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48444. */
  48445. export class EngineInstrumentation implements IDisposable {
  48446. /**
  48447. * Define the instrumented engine.
  48448. */
  48449. engine: Engine;
  48450. private _captureGPUFrameTime;
  48451. private _gpuFrameTimeToken;
  48452. private _gpuFrameTime;
  48453. private _captureShaderCompilationTime;
  48454. private _shaderCompilationTime;
  48455. private _onBeginFrameObserver;
  48456. private _onEndFrameObserver;
  48457. private _onBeforeShaderCompilationObserver;
  48458. private _onAfterShaderCompilationObserver;
  48459. /**
  48460. * Gets the perf counter used for GPU frame time
  48461. */
  48462. readonly gpuFrameTimeCounter: PerfCounter;
  48463. /**
  48464. * Gets the GPU frame time capture status
  48465. */
  48466. /**
  48467. * Enable or disable the GPU frame time capture
  48468. */
  48469. captureGPUFrameTime: boolean;
  48470. /**
  48471. * Gets the perf counter used for shader compilation time
  48472. */
  48473. readonly shaderCompilationTimeCounter: PerfCounter;
  48474. /**
  48475. * Gets the shader compilation time capture status
  48476. */
  48477. /**
  48478. * Enable or disable the shader compilation time capture
  48479. */
  48480. captureShaderCompilationTime: boolean;
  48481. /**
  48482. * Instantiates a new engine instrumentation.
  48483. * This class can be used to get instrumentation data from a Babylon engine
  48484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48485. * @param engine Defines the engine to instrument
  48486. */
  48487. constructor(
  48488. /**
  48489. * Define the instrumented engine.
  48490. */
  48491. engine: Engine);
  48492. /**
  48493. * Dispose and release associated resources.
  48494. */
  48495. dispose(): void;
  48496. }
  48497. }
  48498. declare module BABYLON {
  48499. /**
  48500. * This class can be used to get instrumentation data from a Babylon engine
  48501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48502. */
  48503. export class SceneInstrumentation implements IDisposable {
  48504. /**
  48505. * Defines the scene to instrument
  48506. */
  48507. scene: Scene;
  48508. private _captureActiveMeshesEvaluationTime;
  48509. private _activeMeshesEvaluationTime;
  48510. private _captureRenderTargetsRenderTime;
  48511. private _renderTargetsRenderTime;
  48512. private _captureFrameTime;
  48513. private _frameTime;
  48514. private _captureRenderTime;
  48515. private _renderTime;
  48516. private _captureInterFrameTime;
  48517. private _interFrameTime;
  48518. private _captureParticlesRenderTime;
  48519. private _particlesRenderTime;
  48520. private _captureSpritesRenderTime;
  48521. private _spritesRenderTime;
  48522. private _capturePhysicsTime;
  48523. private _physicsTime;
  48524. private _captureAnimationsTime;
  48525. private _animationsTime;
  48526. private _captureCameraRenderTime;
  48527. private _cameraRenderTime;
  48528. private _onBeforeActiveMeshesEvaluationObserver;
  48529. private _onAfterActiveMeshesEvaluationObserver;
  48530. private _onBeforeRenderTargetsRenderObserver;
  48531. private _onAfterRenderTargetsRenderObserver;
  48532. private _onAfterRenderObserver;
  48533. private _onBeforeDrawPhaseObserver;
  48534. private _onAfterDrawPhaseObserver;
  48535. private _onBeforeAnimationsObserver;
  48536. private _onBeforeParticlesRenderingObserver;
  48537. private _onAfterParticlesRenderingObserver;
  48538. private _onBeforeSpritesRenderingObserver;
  48539. private _onAfterSpritesRenderingObserver;
  48540. private _onBeforePhysicsObserver;
  48541. private _onAfterPhysicsObserver;
  48542. private _onAfterAnimationsObserver;
  48543. private _onBeforeCameraRenderObserver;
  48544. private _onAfterCameraRenderObserver;
  48545. /**
  48546. * Gets the perf counter used for active meshes evaluation time
  48547. */
  48548. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48549. /**
  48550. * Gets the active meshes evaluation time capture status
  48551. */
  48552. /**
  48553. * Enable or disable the active meshes evaluation time capture
  48554. */
  48555. captureActiveMeshesEvaluationTime: boolean;
  48556. /**
  48557. * Gets the perf counter used for render targets render time
  48558. */
  48559. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48560. /**
  48561. * Gets the render targets render time capture status
  48562. */
  48563. /**
  48564. * Enable or disable the render targets render time capture
  48565. */
  48566. captureRenderTargetsRenderTime: boolean;
  48567. /**
  48568. * Gets the perf counter used for particles render time
  48569. */
  48570. readonly particlesRenderTimeCounter: PerfCounter;
  48571. /**
  48572. * Gets the particles render time capture status
  48573. */
  48574. /**
  48575. * Enable or disable the particles render time capture
  48576. */
  48577. captureParticlesRenderTime: boolean;
  48578. /**
  48579. * Gets the perf counter used for sprites render time
  48580. */
  48581. readonly spritesRenderTimeCounter: PerfCounter;
  48582. /**
  48583. * Gets the sprites render time capture status
  48584. */
  48585. /**
  48586. * Enable or disable the sprites render time capture
  48587. */
  48588. captureSpritesRenderTime: boolean;
  48589. /**
  48590. * Gets the perf counter used for physics time
  48591. */
  48592. readonly physicsTimeCounter: PerfCounter;
  48593. /**
  48594. * Gets the physics time capture status
  48595. */
  48596. /**
  48597. * Enable or disable the physics time capture
  48598. */
  48599. capturePhysicsTime: boolean;
  48600. /**
  48601. * Gets the perf counter used for animations time
  48602. */
  48603. readonly animationsTimeCounter: PerfCounter;
  48604. /**
  48605. * Gets the animations time capture status
  48606. */
  48607. /**
  48608. * Enable or disable the animations time capture
  48609. */
  48610. captureAnimationsTime: boolean;
  48611. /**
  48612. * Gets the perf counter used for frame time capture
  48613. */
  48614. readonly frameTimeCounter: PerfCounter;
  48615. /**
  48616. * Gets the frame time capture status
  48617. */
  48618. /**
  48619. * Enable or disable the frame time capture
  48620. */
  48621. captureFrameTime: boolean;
  48622. /**
  48623. * Gets the perf counter used for inter-frames time capture
  48624. */
  48625. readonly interFrameTimeCounter: PerfCounter;
  48626. /**
  48627. * Gets the inter-frames time capture status
  48628. */
  48629. /**
  48630. * Enable or disable the inter-frames time capture
  48631. */
  48632. captureInterFrameTime: boolean;
  48633. /**
  48634. * Gets the perf counter used for render time capture
  48635. */
  48636. readonly renderTimeCounter: PerfCounter;
  48637. /**
  48638. * Gets the render time capture status
  48639. */
  48640. /**
  48641. * Enable or disable the render time capture
  48642. */
  48643. captureRenderTime: boolean;
  48644. /**
  48645. * Gets the perf counter used for camera render time capture
  48646. */
  48647. readonly cameraRenderTimeCounter: PerfCounter;
  48648. /**
  48649. * Gets the camera render time capture status
  48650. */
  48651. /**
  48652. * Enable or disable the camera render time capture
  48653. */
  48654. captureCameraRenderTime: boolean;
  48655. /**
  48656. * Gets the perf counter used for draw calls
  48657. */
  48658. readonly drawCallsCounter: PerfCounter;
  48659. /**
  48660. * Instantiates a new scene instrumentation.
  48661. * This class can be used to get instrumentation data from a Babylon engine
  48662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48663. * @param scene Defines the scene to instrument
  48664. */
  48665. constructor(
  48666. /**
  48667. * Defines the scene to instrument
  48668. */
  48669. scene: Scene);
  48670. /**
  48671. * Dispose and release associated resources.
  48672. */
  48673. dispose(): void;
  48674. }
  48675. }
  48676. declare module BABYLON {
  48677. /** @hidden */
  48678. export var glowMapGenerationPixelShader: {
  48679. name: string;
  48680. shader: string;
  48681. };
  48682. }
  48683. declare module BABYLON {
  48684. /** @hidden */
  48685. export var glowMapGenerationVertexShader: {
  48686. name: string;
  48687. shader: string;
  48688. };
  48689. }
  48690. declare module BABYLON {
  48691. /**
  48692. * Effect layer options. This helps customizing the behaviour
  48693. * of the effect layer.
  48694. */
  48695. export interface IEffectLayerOptions {
  48696. /**
  48697. * Multiplication factor apply to the canvas size to compute the render target size
  48698. * used to generated the objects (the smaller the faster).
  48699. */
  48700. mainTextureRatio: number;
  48701. /**
  48702. * Enforces a fixed size texture to ensure effect stability across devices.
  48703. */
  48704. mainTextureFixedSize?: number;
  48705. /**
  48706. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48707. */
  48708. alphaBlendingMode: number;
  48709. /**
  48710. * The camera attached to the layer.
  48711. */
  48712. camera: Nullable<Camera>;
  48713. /**
  48714. * The rendering group to draw the layer in.
  48715. */
  48716. renderingGroupId: number;
  48717. }
  48718. /**
  48719. * The effect layer Helps adding post process effect blended with the main pass.
  48720. *
  48721. * This can be for instance use to generate glow or higlight effects on the scene.
  48722. *
  48723. * The effect layer class can not be used directly and is intented to inherited from to be
  48724. * customized per effects.
  48725. */
  48726. export abstract class EffectLayer {
  48727. private _vertexBuffers;
  48728. private _indexBuffer;
  48729. private _cachedDefines;
  48730. private _effectLayerMapGenerationEffect;
  48731. private _effectLayerOptions;
  48732. private _mergeEffect;
  48733. protected _scene: Scene;
  48734. protected _engine: Engine;
  48735. protected _maxSize: number;
  48736. protected _mainTextureDesiredSize: ISize;
  48737. protected _mainTexture: RenderTargetTexture;
  48738. protected _shouldRender: boolean;
  48739. protected _postProcesses: PostProcess[];
  48740. protected _textures: BaseTexture[];
  48741. protected _emissiveTextureAndColor: {
  48742. texture: Nullable<BaseTexture>;
  48743. color: Color4;
  48744. };
  48745. /**
  48746. * The name of the layer
  48747. */
  48748. name: string;
  48749. /**
  48750. * The clear color of the texture used to generate the glow map.
  48751. */
  48752. neutralColor: Color4;
  48753. /**
  48754. * Specifies wether the highlight layer is enabled or not.
  48755. */
  48756. isEnabled: boolean;
  48757. /**
  48758. * Gets the camera attached to the layer.
  48759. */
  48760. readonly camera: Nullable<Camera>;
  48761. /**
  48762. * Gets the rendering group id the layer should render in.
  48763. */
  48764. renderingGroupId: number;
  48765. /**
  48766. * An event triggered when the effect layer has been disposed.
  48767. */
  48768. onDisposeObservable: Observable<EffectLayer>;
  48769. /**
  48770. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48771. */
  48772. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48773. /**
  48774. * An event triggered when the generated texture is being merged in the scene.
  48775. */
  48776. onBeforeComposeObservable: Observable<EffectLayer>;
  48777. /**
  48778. * An event triggered when the generated texture has been merged in the scene.
  48779. */
  48780. onAfterComposeObservable: Observable<EffectLayer>;
  48781. /**
  48782. * An event triggered when the efffect layer changes its size.
  48783. */
  48784. onSizeChangedObservable: Observable<EffectLayer>;
  48785. /** @hidden */
  48786. static _SceneComponentInitialization: (scene: Scene) => void;
  48787. /**
  48788. * Instantiates a new effect Layer and references it in the scene.
  48789. * @param name The name of the layer
  48790. * @param scene The scene to use the layer in
  48791. */
  48792. constructor(
  48793. /** The Friendly of the effect in the scene */
  48794. name: string, scene: Scene);
  48795. /**
  48796. * Get the effect name of the layer.
  48797. * @return The effect name
  48798. */
  48799. abstract getEffectName(): string;
  48800. /**
  48801. * Checks for the readiness of the element composing the layer.
  48802. * @param subMesh the mesh to check for
  48803. * @param useInstances specify wether or not to use instances to render the mesh
  48804. * @return true if ready otherwise, false
  48805. */
  48806. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48807. /**
  48808. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48809. * @returns true if the effect requires stencil during the main canvas render pass.
  48810. */
  48811. abstract needStencil(): boolean;
  48812. /**
  48813. * Create the merge effect. This is the shader use to blit the information back
  48814. * to the main canvas at the end of the scene rendering.
  48815. * @returns The effect containing the shader used to merge the effect on the main canvas
  48816. */
  48817. protected abstract _createMergeEffect(): Effect;
  48818. /**
  48819. * Creates the render target textures and post processes used in the effect layer.
  48820. */
  48821. protected abstract _createTextureAndPostProcesses(): void;
  48822. /**
  48823. * Implementation specific of rendering the generating effect on the main canvas.
  48824. * @param effect The effect used to render through
  48825. */
  48826. protected abstract _internalRender(effect: Effect): void;
  48827. /**
  48828. * Sets the required values for both the emissive texture and and the main color.
  48829. */
  48830. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48831. /**
  48832. * Free any resources and references associated to a mesh.
  48833. * Internal use
  48834. * @param mesh The mesh to free.
  48835. */
  48836. abstract _disposeMesh(mesh: Mesh): void;
  48837. /**
  48838. * Serializes this layer (Glow or Highlight for example)
  48839. * @returns a serialized layer object
  48840. */
  48841. abstract serialize?(): any;
  48842. /**
  48843. * Initializes the effect layer with the required options.
  48844. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48845. */
  48846. protected _init(options: Partial<IEffectLayerOptions>): void;
  48847. /**
  48848. * Generates the index buffer of the full screen quad blending to the main canvas.
  48849. */
  48850. private _generateIndexBuffer;
  48851. /**
  48852. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48853. */
  48854. private _generateVertexBuffer;
  48855. /**
  48856. * Sets the main texture desired size which is the closest power of two
  48857. * of the engine canvas size.
  48858. */
  48859. private _setMainTextureSize;
  48860. /**
  48861. * Creates the main texture for the effect layer.
  48862. */
  48863. protected _createMainTexture(): void;
  48864. /**
  48865. * Adds specific effects defines.
  48866. * @param defines The defines to add specifics to.
  48867. */
  48868. protected _addCustomEffectDefines(defines: string[]): void;
  48869. /**
  48870. * Checks for the readiness of the element composing the layer.
  48871. * @param subMesh the mesh to check for
  48872. * @param useInstances specify wether or not to use instances to render the mesh
  48873. * @param emissiveTexture the associated emissive texture used to generate the glow
  48874. * @return true if ready otherwise, false
  48875. */
  48876. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48877. /**
  48878. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48879. */
  48880. render(): void;
  48881. /**
  48882. * Determine if a given mesh will be used in the current effect.
  48883. * @param mesh mesh to test
  48884. * @returns true if the mesh will be used
  48885. */
  48886. hasMesh(mesh: AbstractMesh): boolean;
  48887. /**
  48888. * Returns true if the layer contains information to display, otherwise false.
  48889. * @returns true if the glow layer should be rendered
  48890. */
  48891. shouldRender(): boolean;
  48892. /**
  48893. * Returns true if the mesh should render, otherwise false.
  48894. * @param mesh The mesh to render
  48895. * @returns true if it should render otherwise false
  48896. */
  48897. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48898. /**
  48899. * Returns true if the mesh can be rendered, otherwise false.
  48900. * @param mesh The mesh to render
  48901. * @param material The material used on the mesh
  48902. * @returns true if it can be rendered otherwise false
  48903. */
  48904. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48905. /**
  48906. * Returns true if the mesh should render, otherwise false.
  48907. * @param mesh The mesh to render
  48908. * @returns true if it should render otherwise false
  48909. */
  48910. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48911. /**
  48912. * Renders the submesh passed in parameter to the generation map.
  48913. */
  48914. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48915. /**
  48916. * Rebuild the required buffers.
  48917. * @hidden Internal use only.
  48918. */
  48919. _rebuild(): void;
  48920. /**
  48921. * Dispose only the render target textures and post process.
  48922. */
  48923. private _disposeTextureAndPostProcesses;
  48924. /**
  48925. * Dispose the highlight layer and free resources.
  48926. */
  48927. dispose(): void;
  48928. /**
  48929. * Gets the class name of the effect layer
  48930. * @returns the string with the class name of the effect layer
  48931. */
  48932. getClassName(): string;
  48933. /**
  48934. * Creates an effect layer from parsed effect layer data
  48935. * @param parsedEffectLayer defines effect layer data
  48936. * @param scene defines the current scene
  48937. * @param rootUrl defines the root URL containing the effect layer information
  48938. * @returns a parsed effect Layer
  48939. */
  48940. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48941. }
  48942. }
  48943. declare module BABYLON {
  48944. interface AbstractScene {
  48945. /**
  48946. * The list of effect layers (highlights/glow) added to the scene
  48947. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48948. * @see http://doc.babylonjs.com/how_to/glow_layer
  48949. */
  48950. effectLayers: Array<EffectLayer>;
  48951. /**
  48952. * Removes the given effect layer from this scene.
  48953. * @param toRemove defines the effect layer to remove
  48954. * @returns the index of the removed effect layer
  48955. */
  48956. removeEffectLayer(toRemove: EffectLayer): number;
  48957. /**
  48958. * Adds the given effect layer to this scene
  48959. * @param newEffectLayer defines the effect layer to add
  48960. */
  48961. addEffectLayer(newEffectLayer: EffectLayer): void;
  48962. }
  48963. /**
  48964. * Defines the layer scene component responsible to manage any effect layers
  48965. * in a given scene.
  48966. */
  48967. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48968. /**
  48969. * The component name helpfull to identify the component in the list of scene components.
  48970. */
  48971. readonly name: string;
  48972. /**
  48973. * The scene the component belongs to.
  48974. */
  48975. scene: Scene;
  48976. private _engine;
  48977. private _renderEffects;
  48978. private _needStencil;
  48979. private _previousStencilState;
  48980. /**
  48981. * Creates a new instance of the component for the given scene
  48982. * @param scene Defines the scene to register the component in
  48983. */
  48984. constructor(scene: Scene);
  48985. /**
  48986. * Registers the component in a given scene
  48987. */
  48988. register(): void;
  48989. /**
  48990. * Rebuilds the elements related to this component in case of
  48991. * context lost for instance.
  48992. */
  48993. rebuild(): void;
  48994. /**
  48995. * Serializes the component data to the specified json object
  48996. * @param serializationObject The object to serialize to
  48997. */
  48998. serialize(serializationObject: any): void;
  48999. /**
  49000. * Adds all the elements from the container to the scene
  49001. * @param container the container holding the elements
  49002. */
  49003. addFromContainer(container: AbstractScene): void;
  49004. /**
  49005. * Removes all the elements in the container from the scene
  49006. * @param container contains the elements to remove
  49007. * @param dispose if the removed element should be disposed (default: false)
  49008. */
  49009. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49010. /**
  49011. * Disposes the component and the associated ressources.
  49012. */
  49013. dispose(): void;
  49014. private _isReadyForMesh;
  49015. private _renderMainTexture;
  49016. private _setStencil;
  49017. private _setStencilBack;
  49018. private _draw;
  49019. private _drawCamera;
  49020. private _drawRenderingGroup;
  49021. }
  49022. }
  49023. declare module BABYLON {
  49024. /** @hidden */
  49025. export var glowMapMergePixelShader: {
  49026. name: string;
  49027. shader: string;
  49028. };
  49029. }
  49030. declare module BABYLON {
  49031. /** @hidden */
  49032. export var glowMapMergeVertexShader: {
  49033. name: string;
  49034. shader: string;
  49035. };
  49036. }
  49037. declare module BABYLON {
  49038. interface AbstractScene {
  49039. /**
  49040. * Return a the first highlight layer of the scene with a given name.
  49041. * @param name The name of the highlight layer to look for.
  49042. * @return The highlight layer if found otherwise null.
  49043. */
  49044. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49045. }
  49046. /**
  49047. * Glow layer options. This helps customizing the behaviour
  49048. * of the glow layer.
  49049. */
  49050. export interface IGlowLayerOptions {
  49051. /**
  49052. * Multiplication factor apply to the canvas size to compute the render target size
  49053. * used to generated the glowing objects (the smaller the faster).
  49054. */
  49055. mainTextureRatio: number;
  49056. /**
  49057. * Enforces a fixed size texture to ensure resize independant blur.
  49058. */
  49059. mainTextureFixedSize?: number;
  49060. /**
  49061. * How big is the kernel of the blur texture.
  49062. */
  49063. blurKernelSize: number;
  49064. /**
  49065. * The camera attached to the layer.
  49066. */
  49067. camera: Nullable<Camera>;
  49068. /**
  49069. * Enable MSAA by chosing the number of samples.
  49070. */
  49071. mainTextureSamples?: number;
  49072. /**
  49073. * The rendering group to draw the layer in.
  49074. */
  49075. renderingGroupId: number;
  49076. }
  49077. /**
  49078. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49079. *
  49080. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49081. * glowy meshes to your scene.
  49082. *
  49083. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49084. */
  49085. export class GlowLayer extends EffectLayer {
  49086. /**
  49087. * Effect Name of the layer.
  49088. */
  49089. static readonly EffectName: string;
  49090. /**
  49091. * The default blur kernel size used for the glow.
  49092. */
  49093. static DefaultBlurKernelSize: number;
  49094. /**
  49095. * The default texture size ratio used for the glow.
  49096. */
  49097. static DefaultTextureRatio: number;
  49098. /**
  49099. * Sets the kernel size of the blur.
  49100. */
  49101. /**
  49102. * Gets the kernel size of the blur.
  49103. */
  49104. blurKernelSize: number;
  49105. /**
  49106. * Sets the glow intensity.
  49107. */
  49108. /**
  49109. * Gets the glow intensity.
  49110. */
  49111. intensity: number;
  49112. private _options;
  49113. private _intensity;
  49114. private _horizontalBlurPostprocess1;
  49115. private _verticalBlurPostprocess1;
  49116. private _horizontalBlurPostprocess2;
  49117. private _verticalBlurPostprocess2;
  49118. private _blurTexture1;
  49119. private _blurTexture2;
  49120. private _postProcesses1;
  49121. private _postProcesses2;
  49122. private _includedOnlyMeshes;
  49123. private _excludedMeshes;
  49124. /**
  49125. * Callback used to let the user override the color selection on a per mesh basis
  49126. */
  49127. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49128. /**
  49129. * Callback used to let the user override the texture selection on a per mesh basis
  49130. */
  49131. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49132. /**
  49133. * Instantiates a new glow Layer and references it to the scene.
  49134. * @param name The name of the layer
  49135. * @param scene The scene to use the layer in
  49136. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49137. */
  49138. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49139. /**
  49140. * Get the effect name of the layer.
  49141. * @return The effect name
  49142. */
  49143. getEffectName(): string;
  49144. /**
  49145. * Create the merge effect. This is the shader use to blit the information back
  49146. * to the main canvas at the end of the scene rendering.
  49147. */
  49148. protected _createMergeEffect(): Effect;
  49149. /**
  49150. * Creates the render target textures and post processes used in the glow layer.
  49151. */
  49152. protected _createTextureAndPostProcesses(): void;
  49153. /**
  49154. * Checks for the readiness of the element composing the layer.
  49155. * @param subMesh the mesh to check for
  49156. * @param useInstances specify wether or not to use instances to render the mesh
  49157. * @param emissiveTexture the associated emissive texture used to generate the glow
  49158. * @return true if ready otherwise, false
  49159. */
  49160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49161. /**
  49162. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49163. */
  49164. needStencil(): boolean;
  49165. /**
  49166. * Returns true if the mesh can be rendered, otherwise false.
  49167. * @param mesh The mesh to render
  49168. * @param material The material used on the mesh
  49169. * @returns true if it can be rendered otherwise false
  49170. */
  49171. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49172. /**
  49173. * Implementation specific of rendering the generating effect on the main canvas.
  49174. * @param effect The effect used to render through
  49175. */
  49176. protected _internalRender(effect: Effect): void;
  49177. /**
  49178. * Sets the required values for both the emissive texture and and the main color.
  49179. */
  49180. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49181. /**
  49182. * Returns true if the mesh should render, otherwise false.
  49183. * @param mesh The mesh to render
  49184. * @returns true if it should render otherwise false
  49185. */
  49186. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49187. /**
  49188. * Adds specific effects defines.
  49189. * @param defines The defines to add specifics to.
  49190. */
  49191. protected _addCustomEffectDefines(defines: string[]): void;
  49192. /**
  49193. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49194. * @param mesh The mesh to exclude from the glow layer
  49195. */
  49196. addExcludedMesh(mesh: Mesh): void;
  49197. /**
  49198. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49199. * @param mesh The mesh to remove
  49200. */
  49201. removeExcludedMesh(mesh: Mesh): void;
  49202. /**
  49203. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49204. * @param mesh The mesh to include in the glow layer
  49205. */
  49206. addIncludedOnlyMesh(mesh: Mesh): void;
  49207. /**
  49208. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49209. * @param mesh The mesh to remove
  49210. */
  49211. removeIncludedOnlyMesh(mesh: Mesh): void;
  49212. /**
  49213. * Determine if a given mesh will be used in the glow layer
  49214. * @param mesh The mesh to test
  49215. * @returns true if the mesh will be highlighted by the current glow layer
  49216. */
  49217. hasMesh(mesh: AbstractMesh): boolean;
  49218. /**
  49219. * Free any resources and references associated to a mesh.
  49220. * Internal use
  49221. * @param mesh The mesh to free.
  49222. * @hidden
  49223. */
  49224. _disposeMesh(mesh: Mesh): void;
  49225. /**
  49226. * Gets the class name of the effect layer
  49227. * @returns the string with the class name of the effect layer
  49228. */
  49229. getClassName(): string;
  49230. /**
  49231. * Serializes this glow layer
  49232. * @returns a serialized glow layer object
  49233. */
  49234. serialize(): any;
  49235. /**
  49236. * Creates a Glow Layer from parsed glow layer data
  49237. * @param parsedGlowLayer defines glow layer data
  49238. * @param scene defines the current scene
  49239. * @param rootUrl defines the root URL containing the glow layer information
  49240. * @returns a parsed Glow Layer
  49241. */
  49242. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /** @hidden */
  49247. export var glowBlurPostProcessPixelShader: {
  49248. name: string;
  49249. shader: string;
  49250. };
  49251. }
  49252. declare module BABYLON {
  49253. interface AbstractScene {
  49254. /**
  49255. * Return a the first highlight layer of the scene with a given name.
  49256. * @param name The name of the highlight layer to look for.
  49257. * @return The highlight layer if found otherwise null.
  49258. */
  49259. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49260. }
  49261. /**
  49262. * Highlight layer options. This helps customizing the behaviour
  49263. * of the highlight layer.
  49264. */
  49265. export interface IHighlightLayerOptions {
  49266. /**
  49267. * Multiplication factor apply to the canvas size to compute the render target size
  49268. * used to generated the glowing objects (the smaller the faster).
  49269. */
  49270. mainTextureRatio: number;
  49271. /**
  49272. * Enforces a fixed size texture to ensure resize independant blur.
  49273. */
  49274. mainTextureFixedSize?: number;
  49275. /**
  49276. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49277. * of the picture to blur (the smaller the faster).
  49278. */
  49279. blurTextureSizeRatio: number;
  49280. /**
  49281. * How big in texel of the blur texture is the vertical blur.
  49282. */
  49283. blurVerticalSize: number;
  49284. /**
  49285. * How big in texel of the blur texture is the horizontal blur.
  49286. */
  49287. blurHorizontalSize: number;
  49288. /**
  49289. * Alpha blending mode used to apply the blur. Default is combine.
  49290. */
  49291. alphaBlendingMode: number;
  49292. /**
  49293. * The camera attached to the layer.
  49294. */
  49295. camera: Nullable<Camera>;
  49296. /**
  49297. * Should we display highlight as a solid stroke?
  49298. */
  49299. isStroke?: boolean;
  49300. /**
  49301. * The rendering group to draw the layer in.
  49302. */
  49303. renderingGroupId: number;
  49304. }
  49305. /**
  49306. * The highlight layer Helps adding a glow effect around a mesh.
  49307. *
  49308. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49309. * glowy meshes to your scene.
  49310. *
  49311. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49312. */
  49313. export class HighlightLayer extends EffectLayer {
  49314. name: string;
  49315. /**
  49316. * Effect Name of the highlight layer.
  49317. */
  49318. static readonly EffectName: string;
  49319. /**
  49320. * The neutral color used during the preparation of the glow effect.
  49321. * This is black by default as the blend operation is a blend operation.
  49322. */
  49323. static NeutralColor: Color4;
  49324. /**
  49325. * Stencil value used for glowing meshes.
  49326. */
  49327. static GlowingMeshStencilReference: number;
  49328. /**
  49329. * Stencil value used for the other meshes in the scene.
  49330. */
  49331. static NormalMeshStencilReference: number;
  49332. /**
  49333. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49334. */
  49335. innerGlow: boolean;
  49336. /**
  49337. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49338. */
  49339. outerGlow: boolean;
  49340. /**
  49341. * Specifies the horizontal size of the blur.
  49342. */
  49343. /**
  49344. * Gets the horizontal size of the blur.
  49345. */
  49346. blurHorizontalSize: number;
  49347. /**
  49348. * Specifies the vertical size of the blur.
  49349. */
  49350. /**
  49351. * Gets the vertical size of the blur.
  49352. */
  49353. blurVerticalSize: number;
  49354. /**
  49355. * An event triggered when the highlight layer is being blurred.
  49356. */
  49357. onBeforeBlurObservable: Observable<HighlightLayer>;
  49358. /**
  49359. * An event triggered when the highlight layer has been blurred.
  49360. */
  49361. onAfterBlurObservable: Observable<HighlightLayer>;
  49362. private _instanceGlowingMeshStencilReference;
  49363. private _options;
  49364. private _downSamplePostprocess;
  49365. private _horizontalBlurPostprocess;
  49366. private _verticalBlurPostprocess;
  49367. private _blurTexture;
  49368. private _meshes;
  49369. private _excludedMeshes;
  49370. /**
  49371. * Instantiates a new highlight Layer and references it to the scene..
  49372. * @param name The name of the layer
  49373. * @param scene The scene to use the layer in
  49374. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49375. */
  49376. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49377. /**
  49378. * Get the effect name of the layer.
  49379. * @return The effect name
  49380. */
  49381. getEffectName(): string;
  49382. /**
  49383. * Create the merge effect. This is the shader use to blit the information back
  49384. * to the main canvas at the end of the scene rendering.
  49385. */
  49386. protected _createMergeEffect(): Effect;
  49387. /**
  49388. * Creates the render target textures and post processes used in the highlight layer.
  49389. */
  49390. protected _createTextureAndPostProcesses(): void;
  49391. /**
  49392. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49393. */
  49394. needStencil(): boolean;
  49395. /**
  49396. * Checks for the readiness of the element composing the layer.
  49397. * @param subMesh the mesh to check for
  49398. * @param useInstances specify wether or not to use instances to render the mesh
  49399. * @param emissiveTexture the associated emissive texture used to generate the glow
  49400. * @return true if ready otherwise, false
  49401. */
  49402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49403. /**
  49404. * Implementation specific of rendering the generating effect on the main canvas.
  49405. * @param effect The effect used to render through
  49406. */
  49407. protected _internalRender(effect: Effect): void;
  49408. /**
  49409. * Returns true if the layer contains information to display, otherwise false.
  49410. */
  49411. shouldRender(): boolean;
  49412. /**
  49413. * Returns true if the mesh should render, otherwise false.
  49414. * @param mesh The mesh to render
  49415. * @returns true if it should render otherwise false
  49416. */
  49417. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49418. /**
  49419. * Sets the required values for both the emissive texture and and the main color.
  49420. */
  49421. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49422. /**
  49423. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49424. * @param mesh The mesh to exclude from the highlight layer
  49425. */
  49426. addExcludedMesh(mesh: Mesh): void;
  49427. /**
  49428. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49429. * @param mesh The mesh to highlight
  49430. */
  49431. removeExcludedMesh(mesh: Mesh): void;
  49432. /**
  49433. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49434. * @param mesh mesh to test
  49435. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49436. */
  49437. hasMesh(mesh: AbstractMesh): boolean;
  49438. /**
  49439. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49440. * @param mesh The mesh to highlight
  49441. * @param color The color of the highlight
  49442. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49443. */
  49444. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49445. /**
  49446. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49447. * @param mesh The mesh to highlight
  49448. */
  49449. removeMesh(mesh: Mesh): void;
  49450. /**
  49451. * Force the stencil to the normal expected value for none glowing parts
  49452. */
  49453. private _defaultStencilReference;
  49454. /**
  49455. * Free any resources and references associated to a mesh.
  49456. * Internal use
  49457. * @param mesh The mesh to free.
  49458. * @hidden
  49459. */
  49460. _disposeMesh(mesh: Mesh): void;
  49461. /**
  49462. * Dispose the highlight layer and free resources.
  49463. */
  49464. dispose(): void;
  49465. /**
  49466. * Gets the class name of the effect layer
  49467. * @returns the string with the class name of the effect layer
  49468. */
  49469. getClassName(): string;
  49470. /**
  49471. * Serializes this Highlight layer
  49472. * @returns a serialized Highlight layer object
  49473. */
  49474. serialize(): any;
  49475. /**
  49476. * Creates a Highlight layer from parsed Highlight layer data
  49477. * @param parsedHightlightLayer defines the Highlight layer data
  49478. * @param scene defines the current scene
  49479. * @param rootUrl defines the root URL containing the Highlight layer information
  49480. * @returns a parsed Highlight layer
  49481. */
  49482. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49483. }
  49484. }
  49485. declare module BABYLON {
  49486. interface AbstractScene {
  49487. /**
  49488. * The list of layers (background and foreground) of the scene
  49489. */
  49490. layers: Array<Layer>;
  49491. }
  49492. /**
  49493. * Defines the layer scene component responsible to manage any layers
  49494. * in a given scene.
  49495. */
  49496. export class LayerSceneComponent implements ISceneComponent {
  49497. /**
  49498. * The component name helpfull to identify the component in the list of scene components.
  49499. */
  49500. readonly name: string;
  49501. /**
  49502. * The scene the component belongs to.
  49503. */
  49504. scene: Scene;
  49505. private _engine;
  49506. /**
  49507. * Creates a new instance of the component for the given scene
  49508. * @param scene Defines the scene to register the component in
  49509. */
  49510. constructor(scene: Scene);
  49511. /**
  49512. * Registers the component in a given scene
  49513. */
  49514. register(): void;
  49515. /**
  49516. * Rebuilds the elements related to this component in case of
  49517. * context lost for instance.
  49518. */
  49519. rebuild(): void;
  49520. /**
  49521. * Disposes the component and the associated ressources.
  49522. */
  49523. dispose(): void;
  49524. private _draw;
  49525. private _drawCameraPredicate;
  49526. private _drawCameraBackground;
  49527. private _drawCameraForeground;
  49528. private _drawRenderTargetPredicate;
  49529. private _drawRenderTargetBackground;
  49530. private _drawRenderTargetForeground;
  49531. /**
  49532. * Adds all the elements from the container to the scene
  49533. * @param container the container holding the elements
  49534. */
  49535. addFromContainer(container: AbstractScene): void;
  49536. /**
  49537. * Removes all the elements in the container from the scene
  49538. * @param container contains the elements to remove
  49539. * @param dispose if the removed element should be disposed (default: false)
  49540. */
  49541. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49542. }
  49543. }
  49544. declare module BABYLON {
  49545. /** @hidden */
  49546. export var layerPixelShader: {
  49547. name: string;
  49548. shader: string;
  49549. };
  49550. }
  49551. declare module BABYLON {
  49552. /** @hidden */
  49553. export var layerVertexShader: {
  49554. name: string;
  49555. shader: string;
  49556. };
  49557. }
  49558. declare module BABYLON {
  49559. /**
  49560. * This represents a full screen 2d layer.
  49561. * This can be useful to display a picture in the background of your scene for instance.
  49562. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49563. */
  49564. export class Layer {
  49565. /**
  49566. * Define the name of the layer.
  49567. */
  49568. name: string;
  49569. /**
  49570. * Define the texture the layer should display.
  49571. */
  49572. texture: Nullable<Texture>;
  49573. /**
  49574. * Is the layer in background or foreground.
  49575. */
  49576. isBackground: boolean;
  49577. /**
  49578. * Define the color of the layer (instead of texture).
  49579. */
  49580. color: Color4;
  49581. /**
  49582. * Define the scale of the layer in order to zoom in out of the texture.
  49583. */
  49584. scale: Vector2;
  49585. /**
  49586. * Define an offset for the layer in order to shift the texture.
  49587. */
  49588. offset: Vector2;
  49589. /**
  49590. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49591. */
  49592. alphaBlendingMode: number;
  49593. /**
  49594. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49595. * Alpha test will not mix with the background color in case of transparency.
  49596. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49597. */
  49598. alphaTest: boolean;
  49599. /**
  49600. * Define a mask to restrict the layer to only some of the scene cameras.
  49601. */
  49602. layerMask: number;
  49603. /**
  49604. * Define the list of render target the layer is visible into.
  49605. */
  49606. renderTargetTextures: RenderTargetTexture[];
  49607. /**
  49608. * Define if the layer is only used in renderTarget or if it also
  49609. * renders in the main frame buffer of the canvas.
  49610. */
  49611. renderOnlyInRenderTargetTextures: boolean;
  49612. private _scene;
  49613. private _vertexBuffers;
  49614. private _indexBuffer;
  49615. private _effect;
  49616. private _alphaTestEffect;
  49617. /**
  49618. * An event triggered when the layer is disposed.
  49619. */
  49620. onDisposeObservable: Observable<Layer>;
  49621. private _onDisposeObserver;
  49622. /**
  49623. * Back compatibility with callback before the onDisposeObservable existed.
  49624. * The set callback will be triggered when the layer has been disposed.
  49625. */
  49626. onDispose: () => void;
  49627. /**
  49628. * An event triggered before rendering the scene
  49629. */
  49630. onBeforeRenderObservable: Observable<Layer>;
  49631. private _onBeforeRenderObserver;
  49632. /**
  49633. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49634. * The set callback will be triggered just before rendering the layer.
  49635. */
  49636. onBeforeRender: () => void;
  49637. /**
  49638. * An event triggered after rendering the scene
  49639. */
  49640. onAfterRenderObservable: Observable<Layer>;
  49641. private _onAfterRenderObserver;
  49642. /**
  49643. * Back compatibility with callback before the onAfterRenderObservable existed.
  49644. * The set callback will be triggered just after rendering the layer.
  49645. */
  49646. onAfterRender: () => void;
  49647. /**
  49648. * Instantiates a new layer.
  49649. * This represents a full screen 2d layer.
  49650. * This can be useful to display a picture in the background of your scene for instance.
  49651. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49652. * @param name Define the name of the layer in the scene
  49653. * @param imgUrl Define the url of the texture to display in the layer
  49654. * @param scene Define the scene the layer belongs to
  49655. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49656. * @param color Defines a color for the layer
  49657. */
  49658. constructor(
  49659. /**
  49660. * Define the name of the layer.
  49661. */
  49662. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49663. private _createIndexBuffer;
  49664. /** @hidden */
  49665. _rebuild(): void;
  49666. /**
  49667. * Renders the layer in the scene.
  49668. */
  49669. render(): void;
  49670. /**
  49671. * Disposes and releases the associated ressources.
  49672. */
  49673. dispose(): void;
  49674. }
  49675. }
  49676. declare module BABYLON {
  49677. /** @hidden */
  49678. export var lensFlarePixelShader: {
  49679. name: string;
  49680. shader: string;
  49681. };
  49682. }
  49683. declare module BABYLON {
  49684. /** @hidden */
  49685. export var lensFlareVertexShader: {
  49686. name: string;
  49687. shader: string;
  49688. };
  49689. }
  49690. declare module BABYLON {
  49691. /**
  49692. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49693. * It is usually composed of several `lensFlare`.
  49694. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49695. */
  49696. export class LensFlareSystem {
  49697. /**
  49698. * Define the name of the lens flare system
  49699. */
  49700. name: string;
  49701. /**
  49702. * List of lens flares used in this system.
  49703. */
  49704. lensFlares: LensFlare[];
  49705. /**
  49706. * Define a limit from the border the lens flare can be visible.
  49707. */
  49708. borderLimit: number;
  49709. /**
  49710. * Define a viewport border we do not want to see the lens flare in.
  49711. */
  49712. viewportBorder: number;
  49713. /**
  49714. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49715. */
  49716. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49717. /**
  49718. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49719. */
  49720. layerMask: number;
  49721. /**
  49722. * Define the id of the lens flare system in the scene.
  49723. * (equal to name by default)
  49724. */
  49725. id: string;
  49726. private _scene;
  49727. private _emitter;
  49728. private _vertexBuffers;
  49729. private _indexBuffer;
  49730. private _effect;
  49731. private _positionX;
  49732. private _positionY;
  49733. private _isEnabled;
  49734. /** @hidden */
  49735. static _SceneComponentInitialization: (scene: Scene) => void;
  49736. /**
  49737. * Instantiates a lens flare system.
  49738. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49739. * It is usually composed of several `lensFlare`.
  49740. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49741. * @param name Define the name of the lens flare system in the scene
  49742. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49743. * @param scene Define the scene the lens flare system belongs to
  49744. */
  49745. constructor(
  49746. /**
  49747. * Define the name of the lens flare system
  49748. */
  49749. name: string, emitter: any, scene: Scene);
  49750. /**
  49751. * Define if the lens flare system is enabled.
  49752. */
  49753. isEnabled: boolean;
  49754. /**
  49755. * Get the scene the effects belongs to.
  49756. * @returns the scene holding the lens flare system
  49757. */
  49758. getScene(): Scene;
  49759. /**
  49760. * Get the emitter of the lens flare system.
  49761. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49762. * @returns the emitter of the lens flare system
  49763. */
  49764. getEmitter(): any;
  49765. /**
  49766. * Set the emitter of the lens flare system.
  49767. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49768. * @param newEmitter Define the new emitter of the system
  49769. */
  49770. setEmitter(newEmitter: any): void;
  49771. /**
  49772. * Get the lens flare system emitter position.
  49773. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49774. * @returns the position
  49775. */
  49776. getEmitterPosition(): Vector3;
  49777. /**
  49778. * @hidden
  49779. */
  49780. computeEffectivePosition(globalViewport: Viewport): boolean;
  49781. /** @hidden */
  49782. _isVisible(): boolean;
  49783. /**
  49784. * @hidden
  49785. */
  49786. render(): boolean;
  49787. /**
  49788. * Dispose and release the lens flare with its associated resources.
  49789. */
  49790. dispose(): void;
  49791. /**
  49792. * Parse a lens flare system from a JSON repressentation
  49793. * @param parsedLensFlareSystem Define the JSON to parse
  49794. * @param scene Define the scene the parsed system should be instantiated in
  49795. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49796. * @returns the parsed system
  49797. */
  49798. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49799. /**
  49800. * Serialize the current Lens Flare System into a JSON representation.
  49801. * @returns the serialized JSON
  49802. */
  49803. serialize(): any;
  49804. }
  49805. }
  49806. declare module BABYLON {
  49807. /**
  49808. * This represents one of the lens effect in a `lensFlareSystem`.
  49809. * It controls one of the indiviual texture used in the effect.
  49810. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49811. */
  49812. export class LensFlare {
  49813. /**
  49814. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49815. */
  49816. size: number;
  49817. /**
  49818. * 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.
  49819. */
  49820. position: number;
  49821. /**
  49822. * Define the lens color.
  49823. */
  49824. color: Color3;
  49825. /**
  49826. * Define the lens texture.
  49827. */
  49828. texture: Nullable<Texture>;
  49829. /**
  49830. * Define the alpha mode to render this particular lens.
  49831. */
  49832. alphaMode: number;
  49833. private _system;
  49834. /**
  49835. * Creates a new Lens Flare.
  49836. * This represents one of the lens effect in a `lensFlareSystem`.
  49837. * It controls one of the indiviual texture used in the effect.
  49838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49839. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49840. * @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.
  49841. * @param color Define the lens color
  49842. * @param imgUrl Define the lens texture url
  49843. * @param system Define the `lensFlareSystem` this flare is part of
  49844. * @returns The newly created Lens Flare
  49845. */
  49846. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49847. /**
  49848. * Instantiates a new Lens Flare.
  49849. * This represents one of the lens effect in a `lensFlareSystem`.
  49850. * It controls one of the indiviual texture used in the effect.
  49851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49852. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49853. * @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.
  49854. * @param color Define the lens color
  49855. * @param imgUrl Define the lens texture url
  49856. * @param system Define the `lensFlareSystem` this flare is part of
  49857. */
  49858. constructor(
  49859. /**
  49860. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49861. */
  49862. size: number,
  49863. /**
  49864. * 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.
  49865. */
  49866. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49867. /**
  49868. * Dispose and release the lens flare with its associated resources.
  49869. */
  49870. dispose(): void;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. interface AbstractScene {
  49875. /**
  49876. * The list of lens flare system added to the scene
  49877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49878. */
  49879. lensFlareSystems: Array<LensFlareSystem>;
  49880. /**
  49881. * Removes the given lens flare system from this scene.
  49882. * @param toRemove The lens flare system to remove
  49883. * @returns The index of the removed lens flare system
  49884. */
  49885. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49886. /**
  49887. * Adds the given lens flare system to this scene
  49888. * @param newLensFlareSystem The lens flare system to add
  49889. */
  49890. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49891. /**
  49892. * Gets a lens flare system using its name
  49893. * @param name defines the name to look for
  49894. * @returns the lens flare system or null if not found
  49895. */
  49896. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49897. /**
  49898. * Gets a lens flare system using its id
  49899. * @param id defines the id to look for
  49900. * @returns the lens flare system or null if not found
  49901. */
  49902. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49903. }
  49904. /**
  49905. * Defines the lens flare scene component responsible to manage any lens flares
  49906. * in a given scene.
  49907. */
  49908. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49909. /**
  49910. * The component name helpfull to identify the component in the list of scene components.
  49911. */
  49912. readonly name: string;
  49913. /**
  49914. * The scene the component belongs to.
  49915. */
  49916. scene: Scene;
  49917. /**
  49918. * Creates a new instance of the component for the given scene
  49919. * @param scene Defines the scene to register the component in
  49920. */
  49921. constructor(scene: Scene);
  49922. /**
  49923. * Registers the component in a given scene
  49924. */
  49925. register(): void;
  49926. /**
  49927. * Rebuilds the elements related to this component in case of
  49928. * context lost for instance.
  49929. */
  49930. rebuild(): void;
  49931. /**
  49932. * Adds all the elements from the container to the scene
  49933. * @param container the container holding the elements
  49934. */
  49935. addFromContainer(container: AbstractScene): void;
  49936. /**
  49937. * Removes all the elements in the container from the scene
  49938. * @param container contains the elements to remove
  49939. * @param dispose if the removed element should be disposed (default: false)
  49940. */
  49941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49942. /**
  49943. * Serializes the component data to the specified json object
  49944. * @param serializationObject The object to serialize to
  49945. */
  49946. serialize(serializationObject: any): void;
  49947. /**
  49948. * Disposes the component and the associated ressources.
  49949. */
  49950. dispose(): void;
  49951. private _draw;
  49952. }
  49953. }
  49954. declare module BABYLON {
  49955. /**
  49956. * Defines the shadow generator component responsible to manage any shadow generators
  49957. * in a given scene.
  49958. */
  49959. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49960. /**
  49961. * The component name helpfull to identify the component in the list of scene components.
  49962. */
  49963. readonly name: string;
  49964. /**
  49965. * The scene the component belongs to.
  49966. */
  49967. scene: Scene;
  49968. /**
  49969. * Creates a new instance of the component for the given scene
  49970. * @param scene Defines the scene to register the component in
  49971. */
  49972. constructor(scene: Scene);
  49973. /**
  49974. * Registers the component in a given scene
  49975. */
  49976. register(): void;
  49977. /**
  49978. * Rebuilds the elements related to this component in case of
  49979. * context lost for instance.
  49980. */
  49981. rebuild(): void;
  49982. /**
  49983. * Serializes the component data to the specified json object
  49984. * @param serializationObject The object to serialize to
  49985. */
  49986. serialize(serializationObject: any): void;
  49987. /**
  49988. * Adds all the elements from the container to the scene
  49989. * @param container the container holding the elements
  49990. */
  49991. addFromContainer(container: AbstractScene): void;
  49992. /**
  49993. * Removes all the elements in the container from the scene
  49994. * @param container contains the elements to remove
  49995. * @param dispose if the removed element should be disposed (default: false)
  49996. */
  49997. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49998. /**
  49999. * Rebuilds the elements related to this component in case of
  50000. * context lost for instance.
  50001. */
  50002. dispose(): void;
  50003. private _gatherRenderTargets;
  50004. }
  50005. }
  50006. declare module BABYLON {
  50007. /**
  50008. * A point light is a light defined by an unique point in world space.
  50009. * The light is emitted in every direction from this point.
  50010. * A good example of a point light is a standard light bulb.
  50011. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50012. */
  50013. export class PointLight extends ShadowLight {
  50014. private _shadowAngle;
  50015. /**
  50016. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50017. * This specifies what angle the shadow will use to be created.
  50018. *
  50019. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50020. */
  50021. /**
  50022. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50023. * This specifies what angle the shadow will use to be created.
  50024. *
  50025. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50026. */
  50027. shadowAngle: number;
  50028. /**
  50029. * Gets the direction if it has been set.
  50030. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50031. */
  50032. /**
  50033. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50034. */
  50035. direction: Vector3;
  50036. /**
  50037. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50038. * A PointLight emits the light in every direction.
  50039. * It can cast shadows.
  50040. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50041. * ```javascript
  50042. * var pointLight = new PointLight("pl", camera.position, scene);
  50043. * ```
  50044. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50045. * @param name The light friendly name
  50046. * @param position The position of the point light in the scene
  50047. * @param scene The scene the lights belongs to
  50048. */
  50049. constructor(name: string, position: Vector3, scene: Scene);
  50050. /**
  50051. * Returns the string "PointLight"
  50052. * @returns the class name
  50053. */
  50054. getClassName(): string;
  50055. /**
  50056. * Returns the integer 0.
  50057. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50058. */
  50059. getTypeID(): number;
  50060. /**
  50061. * Specifies wether or not the shadowmap should be a cube texture.
  50062. * @returns true if the shadowmap needs to be a cube texture.
  50063. */
  50064. needCube(): boolean;
  50065. /**
  50066. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50069. */
  50070. getShadowDirection(faceIndex?: number): Vector3;
  50071. /**
  50072. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50073. * - fov = PI / 2
  50074. * - aspect ratio : 1.0
  50075. * - z-near and far equal to the active camera minZ and maxZ.
  50076. * Returns the PointLight.
  50077. */
  50078. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50079. protected _buildUniformLayout(): void;
  50080. /**
  50081. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50082. * @param effect The effect to update
  50083. * @param lightIndex The index of the light in the effect to update
  50084. * @returns The point light
  50085. */
  50086. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50087. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50088. /**
  50089. * Prepares the list of defines specific to the light type.
  50090. * @param defines the list of defines
  50091. * @param lightIndex defines the index of the light for the effect
  50092. */
  50093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50094. }
  50095. }
  50096. declare module BABYLON {
  50097. /**
  50098. * Header information of HDR texture files.
  50099. */
  50100. export interface HDRInfo {
  50101. /**
  50102. * The height of the texture in pixels.
  50103. */
  50104. height: number;
  50105. /**
  50106. * The width of the texture in pixels.
  50107. */
  50108. width: number;
  50109. /**
  50110. * The index of the beginning of the data in the binary file.
  50111. */
  50112. dataPosition: number;
  50113. }
  50114. /**
  50115. * This groups tools to convert HDR texture to native colors array.
  50116. */
  50117. export class HDRTools {
  50118. private static Ldexp;
  50119. private static Rgbe2float;
  50120. private static readStringLine;
  50121. /**
  50122. * Reads header information from an RGBE texture stored in a native array.
  50123. * More information on this format are available here:
  50124. * https://en.wikipedia.org/wiki/RGBE_image_format
  50125. *
  50126. * @param uint8array The binary file stored in native array.
  50127. * @return The header information.
  50128. */
  50129. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50130. /**
  50131. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50132. * This RGBE texture needs to store the information as a panorama.
  50133. *
  50134. * More information on this format are available here:
  50135. * https://en.wikipedia.org/wiki/RGBE_image_format
  50136. *
  50137. * @param buffer The binary file stored in an array buffer.
  50138. * @param size The expected size of the extracted cubemap.
  50139. * @return The Cube Map information.
  50140. */
  50141. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50142. /**
  50143. * Returns the pixels data extracted from an RGBE texture.
  50144. * This pixels will be stored left to right up to down in the R G B order in one array.
  50145. *
  50146. * More information on this format are available here:
  50147. * https://en.wikipedia.org/wiki/RGBE_image_format
  50148. *
  50149. * @param uint8array The binary file stored in an array buffer.
  50150. * @param hdrInfo The header information of the file.
  50151. * @return The pixels data in RGB right to left up to down order.
  50152. */
  50153. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50154. private static RGBE_ReadPixels_RLE;
  50155. }
  50156. }
  50157. declare module BABYLON {
  50158. /**
  50159. * This represents a texture coming from an HDR input.
  50160. *
  50161. * The only supported format is currently panorama picture stored in RGBE format.
  50162. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50163. */
  50164. export class HDRCubeTexture extends BaseTexture {
  50165. private static _facesMapping;
  50166. private _generateHarmonics;
  50167. private _noMipmap;
  50168. private _textureMatrix;
  50169. private _size;
  50170. private _onLoad;
  50171. private _onError;
  50172. /**
  50173. * The texture URL.
  50174. */
  50175. url: string;
  50176. /**
  50177. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50178. */
  50179. coordinatesMode: number;
  50180. protected _isBlocking: boolean;
  50181. /**
  50182. * Sets wether or not the texture is blocking during loading.
  50183. */
  50184. /**
  50185. * Gets wether or not the texture is blocking during loading.
  50186. */
  50187. isBlocking: boolean;
  50188. protected _rotationY: number;
  50189. /**
  50190. * Sets texture matrix rotation angle around Y axis in radians.
  50191. */
  50192. /**
  50193. * Gets texture matrix rotation angle around Y axis radians.
  50194. */
  50195. rotationY: number;
  50196. /**
  50197. * Gets or sets the center of the bounding box associated with the cube texture
  50198. * It must define where the camera used to render the texture was set
  50199. */
  50200. boundingBoxPosition: Vector3;
  50201. private _boundingBoxSize;
  50202. /**
  50203. * Gets or sets the size of the bounding box associated with the cube texture
  50204. * When defined, the cubemap will switch to local mode
  50205. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50206. * @example https://www.babylonjs-playground.com/#RNASML
  50207. */
  50208. boundingBoxSize: Vector3;
  50209. /**
  50210. * Instantiates an HDRTexture from the following parameters.
  50211. *
  50212. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50213. * @param scene The scene the texture will be used in
  50214. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50215. * @param noMipmap Forces to not generate the mipmap if true
  50216. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50217. * @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)
  50218. * @param reserved Reserved flag for internal use.
  50219. */
  50220. 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>);
  50221. /**
  50222. * Get the current class name of the texture useful for serialization or dynamic coding.
  50223. * @returns "HDRCubeTexture"
  50224. */
  50225. getClassName(): string;
  50226. /**
  50227. * Occurs when the file is raw .hdr file.
  50228. */
  50229. private loadTexture;
  50230. clone(): HDRCubeTexture;
  50231. delayLoad(): void;
  50232. /**
  50233. * Get the texture reflection matrix used to rotate/transform the reflection.
  50234. * @returns the reflection matrix
  50235. */
  50236. getReflectionTextureMatrix(): Matrix;
  50237. /**
  50238. * Set the texture reflection matrix used to rotate/transform the reflection.
  50239. * @param value Define the reflection matrix to set
  50240. */
  50241. setReflectionTextureMatrix(value: Matrix): void;
  50242. /**
  50243. * Parses a JSON representation of an HDR Texture in order to create the texture
  50244. * @param parsedTexture Define the JSON representation
  50245. * @param scene Define the scene the texture should be created in
  50246. * @param rootUrl Define the root url in case we need to load relative dependencies
  50247. * @returns the newly created texture after parsing
  50248. */
  50249. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50250. serialize(): any;
  50251. }
  50252. }
  50253. declare module BABYLON {
  50254. /**
  50255. * Class used to control physics engine
  50256. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50257. */
  50258. export class PhysicsEngine implements IPhysicsEngine {
  50259. private _physicsPlugin;
  50260. /**
  50261. * Global value used to control the smallest number supported by the simulation
  50262. */
  50263. static Epsilon: number;
  50264. private _impostors;
  50265. private _joints;
  50266. /**
  50267. * Gets the gravity vector used by the simulation
  50268. */
  50269. gravity: Vector3;
  50270. /**
  50271. * Factory used to create the default physics plugin.
  50272. * @returns The default physics plugin
  50273. */
  50274. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50275. /**
  50276. * Creates a new Physics Engine
  50277. * @param gravity defines the gravity vector used by the simulation
  50278. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50279. */
  50280. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50281. /**
  50282. * Sets the gravity vector used by the simulation
  50283. * @param gravity defines the gravity vector to use
  50284. */
  50285. setGravity(gravity: Vector3): void;
  50286. /**
  50287. * Set the time step of the physics engine.
  50288. * Default is 1/60.
  50289. * To slow it down, enter 1/600 for example.
  50290. * To speed it up, 1/30
  50291. * @param newTimeStep defines the new timestep to apply to this world.
  50292. */
  50293. setTimeStep(newTimeStep?: number): void;
  50294. /**
  50295. * Get the time step of the physics engine.
  50296. * @returns the current time step
  50297. */
  50298. getTimeStep(): number;
  50299. /**
  50300. * Release all resources
  50301. */
  50302. dispose(): void;
  50303. /**
  50304. * Gets the name of the current physics plugin
  50305. * @returns the name of the plugin
  50306. */
  50307. getPhysicsPluginName(): string;
  50308. /**
  50309. * Adding a new impostor for the impostor tracking.
  50310. * This will be done by the impostor itself.
  50311. * @param impostor the impostor to add
  50312. */
  50313. addImpostor(impostor: PhysicsImpostor): void;
  50314. /**
  50315. * Remove an impostor from the engine.
  50316. * This impostor and its mesh will not longer be updated by the physics engine.
  50317. * @param impostor the impostor to remove
  50318. */
  50319. removeImpostor(impostor: PhysicsImpostor): void;
  50320. /**
  50321. * Add a joint to the physics engine
  50322. * @param mainImpostor defines the main impostor to which the joint is added.
  50323. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50324. * @param joint defines the joint that will connect both impostors.
  50325. */
  50326. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50327. /**
  50328. * Removes a joint from the simulation
  50329. * @param mainImpostor defines the impostor used with the joint
  50330. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50331. * @param joint defines the joint to remove
  50332. */
  50333. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50334. /**
  50335. * Called by the scene. No need to call it.
  50336. * @param delta defines the timespam between frames
  50337. */
  50338. _step(delta: number): void;
  50339. /**
  50340. * Gets the current plugin used to run the simulation
  50341. * @returns current plugin
  50342. */
  50343. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50344. /**
  50345. * Gets the list of physic impostors
  50346. * @returns an array of PhysicsImpostor
  50347. */
  50348. getImpostors(): Array<PhysicsImpostor>;
  50349. /**
  50350. * Gets the impostor for a physics enabled object
  50351. * @param object defines the object impersonated by the impostor
  50352. * @returns the PhysicsImpostor or null if not found
  50353. */
  50354. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50355. /**
  50356. * Gets the impostor for a physics body object
  50357. * @param body defines physics body used by the impostor
  50358. * @returns the PhysicsImpostor or null if not found
  50359. */
  50360. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50361. /**
  50362. * Does a raycast in the physics world
  50363. * @param from when should the ray start?
  50364. * @param to when should the ray end?
  50365. * @returns PhysicsRaycastResult
  50366. */
  50367. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50368. }
  50369. }
  50370. declare module BABYLON {
  50371. /** @hidden */
  50372. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50373. private _useDeltaForWorldStep;
  50374. world: any;
  50375. name: string;
  50376. private _physicsMaterials;
  50377. private _fixedTimeStep;
  50378. private _cannonRaycastResult;
  50379. private _raycastResult;
  50380. private _physicsBodysToRemoveAfterStep;
  50381. BJSCANNON: any;
  50382. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50383. setGravity(gravity: Vector3): void;
  50384. setTimeStep(timeStep: number): void;
  50385. getTimeStep(): number;
  50386. executeStep(delta: number): void;
  50387. private _removeMarkedPhysicsBodiesFromWorld;
  50388. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50390. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50391. private _processChildMeshes;
  50392. removePhysicsBody(impostor: PhysicsImpostor): void;
  50393. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50394. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50395. private _addMaterial;
  50396. private _checkWithEpsilon;
  50397. private _createShape;
  50398. private _createHeightmap;
  50399. private _minus90X;
  50400. private _plus90X;
  50401. private _tmpPosition;
  50402. private _tmpDeltaPosition;
  50403. private _tmpUnityRotation;
  50404. private _updatePhysicsBodyTransformation;
  50405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50406. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50407. isSupported(): boolean;
  50408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50413. getBodyMass(impostor: PhysicsImpostor): number;
  50414. getBodyFriction(impostor: PhysicsImpostor): number;
  50415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50416. getBodyRestitution(impostor: PhysicsImpostor): number;
  50417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50418. sleepBody(impostor: PhysicsImpostor): void;
  50419. wakeUpBody(impostor: PhysicsImpostor): void;
  50420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50424. getRadius(impostor: PhysicsImpostor): number;
  50425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50426. dispose(): void;
  50427. private _extendNamespace;
  50428. /**
  50429. * Does a raycast in the physics world
  50430. * @param from when should the ray start?
  50431. * @param to when should the ray end?
  50432. * @returns PhysicsRaycastResult
  50433. */
  50434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50435. }
  50436. }
  50437. declare module BABYLON {
  50438. /** @hidden */
  50439. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50440. world: any;
  50441. name: string;
  50442. BJSOIMO: any;
  50443. private _raycastResult;
  50444. constructor(iterations?: number, oimoInjection?: any);
  50445. setGravity(gravity: Vector3): void;
  50446. setTimeStep(timeStep: number): void;
  50447. getTimeStep(): number;
  50448. private _tmpImpostorsArray;
  50449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50453. private _tmpPositionVector;
  50454. removePhysicsBody(impostor: PhysicsImpostor): void;
  50455. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50456. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50457. isSupported(): boolean;
  50458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50461. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50463. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50465. getBodyMass(impostor: PhysicsImpostor): number;
  50466. getBodyFriction(impostor: PhysicsImpostor): number;
  50467. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50468. getBodyRestitution(impostor: PhysicsImpostor): number;
  50469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50470. sleepBody(impostor: PhysicsImpostor): void;
  50471. wakeUpBody(impostor: PhysicsImpostor): void;
  50472. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50473. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50476. getRadius(impostor: PhysicsImpostor): number;
  50477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50478. dispose(): void;
  50479. /**
  50480. * Does a raycast in the physics world
  50481. * @param from when should the ray start?
  50482. * @param to when should the ray end?
  50483. * @returns PhysicsRaycastResult
  50484. */
  50485. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * Class containing static functions to help procedurally build meshes
  50491. */
  50492. export class RibbonBuilder {
  50493. /**
  50494. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50495. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50496. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50497. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50498. * * 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
  50499. * * 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
  50500. * * 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
  50501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50502. * * 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
  50503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50504. * * 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
  50505. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50506. * * 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
  50507. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50509. * @param name defines the name of the mesh
  50510. * @param options defines the options used to create the mesh
  50511. * @param scene defines the hosting scene
  50512. * @returns the ribbon mesh
  50513. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50515. */
  50516. static CreateRibbon(name: string, options: {
  50517. pathArray: Vector3[][];
  50518. closeArray?: boolean;
  50519. closePath?: boolean;
  50520. offset?: number;
  50521. updatable?: boolean;
  50522. sideOrientation?: number;
  50523. frontUVs?: Vector4;
  50524. backUVs?: Vector4;
  50525. instance?: Mesh;
  50526. invertUV?: boolean;
  50527. uvs?: Vector2[];
  50528. colors?: Color4[];
  50529. }, scene?: Nullable<Scene>): Mesh;
  50530. }
  50531. }
  50532. declare module BABYLON {
  50533. /**
  50534. * Class containing static functions to help procedurally build meshes
  50535. */
  50536. export class ShapeBuilder {
  50537. /**
  50538. * 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.
  50539. * * 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.
  50540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50541. * * 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.
  50542. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50543. * * 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
  50544. * * 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
  50545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50547. * * 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
  50548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50550. * @param name defines the name of the mesh
  50551. * @param options defines the options used to create the mesh
  50552. * @param scene defines the hosting scene
  50553. * @returns the extruded shape mesh
  50554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50556. */
  50557. static ExtrudeShape(name: string, options: {
  50558. shape: Vector3[];
  50559. path: Vector3[];
  50560. scale?: number;
  50561. rotation?: number;
  50562. cap?: number;
  50563. updatable?: boolean;
  50564. sideOrientation?: number;
  50565. frontUVs?: Vector4;
  50566. backUVs?: Vector4;
  50567. instance?: Mesh;
  50568. invertUV?: boolean;
  50569. }, scene?: Nullable<Scene>): Mesh;
  50570. /**
  50571. * Creates an custom extruded shape mesh.
  50572. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50573. * * 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.
  50574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50575. * * 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
  50576. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50577. * * 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
  50578. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50579. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50580. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50581. * * 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
  50582. * * 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
  50583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50585. * * 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
  50586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50588. * @param name defines the name of the mesh
  50589. * @param options defines the options used to create the mesh
  50590. * @param scene defines the hosting scene
  50591. * @returns the custom extruded shape mesh
  50592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50595. */
  50596. static ExtrudeShapeCustom(name: string, options: {
  50597. shape: Vector3[];
  50598. path: Vector3[];
  50599. scaleFunction?: any;
  50600. rotationFunction?: any;
  50601. ribbonCloseArray?: boolean;
  50602. ribbonClosePath?: boolean;
  50603. cap?: number;
  50604. updatable?: boolean;
  50605. sideOrientation?: number;
  50606. frontUVs?: Vector4;
  50607. backUVs?: Vector4;
  50608. instance?: Mesh;
  50609. invertUV?: boolean;
  50610. }, scene?: Nullable<Scene>): Mesh;
  50611. private static _ExtrudeShapeGeneric;
  50612. }
  50613. }
  50614. declare module BABYLON {
  50615. /**
  50616. * AmmoJS Physics plugin
  50617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50618. * @see https://github.com/kripken/ammo.js/
  50619. */
  50620. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50621. private _useDeltaForWorldStep;
  50622. /**
  50623. * Reference to the Ammo library
  50624. */
  50625. bjsAMMO: any;
  50626. /**
  50627. * Created ammoJS world which physics bodies are added to
  50628. */
  50629. world: any;
  50630. /**
  50631. * Name of the plugin
  50632. */
  50633. name: string;
  50634. private _timeStep;
  50635. private _fixedTimeStep;
  50636. private _maxSteps;
  50637. private _tmpQuaternion;
  50638. private _tmpAmmoTransform;
  50639. private _tmpAmmoQuaternion;
  50640. private _tmpAmmoConcreteContactResultCallback;
  50641. private _collisionConfiguration;
  50642. private _dispatcher;
  50643. private _overlappingPairCache;
  50644. private _solver;
  50645. private _softBodySolver;
  50646. private _tmpAmmoVectorA;
  50647. private _tmpAmmoVectorB;
  50648. private _tmpAmmoVectorC;
  50649. private _tmpAmmoVectorD;
  50650. private _tmpContactCallbackResult;
  50651. private _tmpAmmoVectorRCA;
  50652. private _tmpAmmoVectorRCB;
  50653. private _raycastResult;
  50654. private static readonly DISABLE_COLLISION_FLAG;
  50655. private static readonly KINEMATIC_FLAG;
  50656. private static readonly DISABLE_DEACTIVATION_FLAG;
  50657. /**
  50658. * Initializes the ammoJS plugin
  50659. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50660. * @param ammoInjection can be used to inject your own ammo reference
  50661. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50662. */
  50663. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50664. /**
  50665. * Sets the gravity of the physics world (m/(s^2))
  50666. * @param gravity Gravity to set
  50667. */
  50668. setGravity(gravity: Vector3): void;
  50669. /**
  50670. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50671. * @param timeStep timestep to use in seconds
  50672. */
  50673. setTimeStep(timeStep: number): void;
  50674. /**
  50675. * 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)
  50676. * @param fixedTimeStep fixedTimeStep to use in seconds
  50677. */
  50678. setFixedTimeStep(fixedTimeStep: number): void;
  50679. /**
  50680. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50681. * @param maxSteps the maximum number of steps by the physics engine per frame
  50682. */
  50683. setMaxSteps(maxSteps: number): void;
  50684. /**
  50685. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50686. * @returns the current timestep in seconds
  50687. */
  50688. getTimeStep(): number;
  50689. private _isImpostorInContact;
  50690. private _isImpostorPairInContact;
  50691. private _stepSimulation;
  50692. /**
  50693. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50694. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50695. * After the step the babylon meshes are set to the position of the physics imposters
  50696. * @param delta amount of time to step forward
  50697. * @param impostors array of imposters to update before/after the step
  50698. */
  50699. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50700. /**
  50701. * Update babylon mesh to match physics world object
  50702. * @param impostor imposter to match
  50703. */
  50704. private _afterSoftStep;
  50705. /**
  50706. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50707. * @param impostor imposter to match
  50708. */
  50709. private _ropeStep;
  50710. /**
  50711. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50712. * @param impostor imposter to match
  50713. */
  50714. private _softbodyOrClothStep;
  50715. private _tmpVector;
  50716. private _tmpMatrix;
  50717. /**
  50718. * Applies an impulse on the imposter
  50719. * @param impostor imposter to apply impulse to
  50720. * @param force amount of force to be applied to the imposter
  50721. * @param contactPoint the location to apply the impulse on the imposter
  50722. */
  50723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50724. /**
  50725. * Applies a force on the imposter
  50726. * @param impostor imposter to apply force
  50727. * @param force amount of force to be applied to the imposter
  50728. * @param contactPoint the location to apply the force on the imposter
  50729. */
  50730. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50731. /**
  50732. * Creates a physics body using the plugin
  50733. * @param impostor the imposter to create the physics body on
  50734. */
  50735. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50736. /**
  50737. * Removes the physics body from the imposter and disposes of the body's memory
  50738. * @param impostor imposter to remove the physics body from
  50739. */
  50740. removePhysicsBody(impostor: PhysicsImpostor): void;
  50741. /**
  50742. * Generates a joint
  50743. * @param impostorJoint the imposter joint to create the joint with
  50744. */
  50745. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50746. /**
  50747. * Removes a joint
  50748. * @param impostorJoint the imposter joint to remove the joint from
  50749. */
  50750. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50751. private _addMeshVerts;
  50752. /**
  50753. * Initialise the soft body vertices to match its object's (mesh) vertices
  50754. * Softbody vertices (nodes) are in world space and to match this
  50755. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50756. * @param impostor to create the softbody for
  50757. */
  50758. private _softVertexData;
  50759. /**
  50760. * Create an impostor's soft body
  50761. * @param impostor to create the softbody for
  50762. */
  50763. private _createSoftbody;
  50764. /**
  50765. * Create cloth for an impostor
  50766. * @param impostor to create the softbody for
  50767. */
  50768. private _createCloth;
  50769. /**
  50770. * Create rope for an impostor
  50771. * @param impostor to create the softbody for
  50772. */
  50773. private _createRope;
  50774. private _addHullVerts;
  50775. private _createShape;
  50776. /**
  50777. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50778. * @param impostor imposter containing the physics body and babylon object
  50779. */
  50780. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50781. /**
  50782. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50783. * @param impostor imposter containing the physics body and babylon object
  50784. * @param newPosition new position
  50785. * @param newRotation new rotation
  50786. */
  50787. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50788. /**
  50789. * If this plugin is supported
  50790. * @returns true if its supported
  50791. */
  50792. isSupported(): boolean;
  50793. /**
  50794. * Sets the linear velocity of the physics body
  50795. * @param impostor imposter to set the velocity on
  50796. * @param velocity velocity to set
  50797. */
  50798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50799. /**
  50800. * Sets the angular velocity of the physics body
  50801. * @param impostor imposter to set the velocity on
  50802. * @param velocity velocity to set
  50803. */
  50804. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50805. /**
  50806. * gets the linear velocity
  50807. * @param impostor imposter to get linear velocity from
  50808. * @returns linear velocity
  50809. */
  50810. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50811. /**
  50812. * gets the angular velocity
  50813. * @param impostor imposter to get angular velocity from
  50814. * @returns angular velocity
  50815. */
  50816. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50817. /**
  50818. * Sets the mass of physics body
  50819. * @param impostor imposter to set the mass on
  50820. * @param mass mass to set
  50821. */
  50822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50823. /**
  50824. * Gets the mass of the physics body
  50825. * @param impostor imposter to get the mass from
  50826. * @returns mass
  50827. */
  50828. getBodyMass(impostor: PhysicsImpostor): number;
  50829. /**
  50830. * Gets friction of the impostor
  50831. * @param impostor impostor to get friction from
  50832. * @returns friction value
  50833. */
  50834. getBodyFriction(impostor: PhysicsImpostor): number;
  50835. /**
  50836. * Sets friction of the impostor
  50837. * @param impostor impostor to set friction on
  50838. * @param friction friction value
  50839. */
  50840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50841. /**
  50842. * Gets restitution of the impostor
  50843. * @param impostor impostor to get restitution from
  50844. * @returns restitution value
  50845. */
  50846. getBodyRestitution(impostor: PhysicsImpostor): number;
  50847. /**
  50848. * Sets resitution of the impostor
  50849. * @param impostor impostor to set resitution on
  50850. * @param restitution resitution value
  50851. */
  50852. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50853. /**
  50854. * Gets pressure inside the impostor
  50855. * @param impostor impostor to get pressure from
  50856. * @returns pressure value
  50857. */
  50858. getBodyPressure(impostor: PhysicsImpostor): number;
  50859. /**
  50860. * Sets pressure inside a soft body impostor
  50861. * Cloth and rope must remain 0 pressure
  50862. * @param impostor impostor to set pressure on
  50863. * @param pressure pressure value
  50864. */
  50865. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50866. /**
  50867. * Gets stiffness of the impostor
  50868. * @param impostor impostor to get stiffness from
  50869. * @returns pressure value
  50870. */
  50871. getBodyStiffness(impostor: PhysicsImpostor): number;
  50872. /**
  50873. * Sets stiffness of the impostor
  50874. * @param impostor impostor to set stiffness on
  50875. * @param stiffness stiffness value from 0 to 1
  50876. */
  50877. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50878. /**
  50879. * Gets velocityIterations of the impostor
  50880. * @param impostor impostor to get velocity iterations from
  50881. * @returns velocityIterations value
  50882. */
  50883. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50884. /**
  50885. * Sets velocityIterations of the impostor
  50886. * @param impostor impostor to set velocity iterations on
  50887. * @param velocityIterations velocityIterations value
  50888. */
  50889. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50890. /**
  50891. * Gets positionIterations of the impostor
  50892. * @param impostor impostor to get position iterations from
  50893. * @returns positionIterations value
  50894. */
  50895. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50896. /**
  50897. * Sets positionIterations of the impostor
  50898. * @param impostor impostor to set position on
  50899. * @param positionIterations positionIterations value
  50900. */
  50901. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50902. /**
  50903. * Append an anchor to a cloth object
  50904. * @param impostor is the cloth impostor to add anchor to
  50905. * @param otherImpostor is the rigid impostor to anchor to
  50906. * @param width ratio across width from 0 to 1
  50907. * @param height ratio up height from 0 to 1
  50908. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50909. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50910. */
  50911. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50912. /**
  50913. * Append an hook to a rope object
  50914. * @param impostor is the rope impostor to add hook to
  50915. * @param otherImpostor is the rigid impostor to hook to
  50916. * @param length ratio along the rope from 0 to 1
  50917. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50919. */
  50920. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50921. /**
  50922. * Sleeps the physics body and stops it from being active
  50923. * @param impostor impostor to sleep
  50924. */
  50925. sleepBody(impostor: PhysicsImpostor): void;
  50926. /**
  50927. * Activates the physics body
  50928. * @param impostor impostor to activate
  50929. */
  50930. wakeUpBody(impostor: PhysicsImpostor): void;
  50931. /**
  50932. * Updates the distance parameters of the joint
  50933. * @param joint joint to update
  50934. * @param maxDistance maximum distance of the joint
  50935. * @param minDistance minimum distance of the joint
  50936. */
  50937. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50938. /**
  50939. * Sets a motor on the joint
  50940. * @param joint joint to set motor on
  50941. * @param speed speed of the motor
  50942. * @param maxForce maximum force of the motor
  50943. * @param motorIndex index of the motor
  50944. */
  50945. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50946. /**
  50947. * Sets the motors limit
  50948. * @param joint joint to set limit on
  50949. * @param upperLimit upper limit
  50950. * @param lowerLimit lower limit
  50951. */
  50952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50953. /**
  50954. * Syncs the position and rotation of a mesh with the impostor
  50955. * @param mesh mesh to sync
  50956. * @param impostor impostor to update the mesh with
  50957. */
  50958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50959. /**
  50960. * Gets the radius of the impostor
  50961. * @param impostor impostor to get radius from
  50962. * @returns the radius
  50963. */
  50964. getRadius(impostor: PhysicsImpostor): number;
  50965. /**
  50966. * Gets the box size of the impostor
  50967. * @param impostor impostor to get box size from
  50968. * @param result the resulting box size
  50969. */
  50970. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50971. /**
  50972. * Disposes of the impostor
  50973. */
  50974. dispose(): void;
  50975. /**
  50976. * Does a raycast in the physics world
  50977. * @param from when should the ray start?
  50978. * @param to when should the ray end?
  50979. * @returns PhysicsRaycastResult
  50980. */
  50981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50982. }
  50983. }
  50984. declare module BABYLON {
  50985. interface AbstractScene {
  50986. /**
  50987. * The list of reflection probes added to the scene
  50988. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50989. */
  50990. reflectionProbes: Array<ReflectionProbe>;
  50991. /**
  50992. * Removes the given reflection probe from this scene.
  50993. * @param toRemove The reflection probe to remove
  50994. * @returns The index of the removed reflection probe
  50995. */
  50996. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50997. /**
  50998. * Adds the given reflection probe to this scene.
  50999. * @param newReflectionProbe The reflection probe to add
  51000. */
  51001. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51002. }
  51003. /**
  51004. * Class used to generate realtime reflection / refraction cube textures
  51005. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51006. */
  51007. export class ReflectionProbe {
  51008. /** defines the name of the probe */
  51009. name: string;
  51010. private _scene;
  51011. private _renderTargetTexture;
  51012. private _projectionMatrix;
  51013. private _viewMatrix;
  51014. private _target;
  51015. private _add;
  51016. private _attachedMesh;
  51017. private _invertYAxis;
  51018. /** Gets or sets probe position (center of the cube map) */
  51019. position: Vector3;
  51020. /**
  51021. * Creates a new reflection probe
  51022. * @param name defines the name of the probe
  51023. * @param size defines the texture resolution (for each face)
  51024. * @param scene defines the hosting scene
  51025. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51026. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51027. */
  51028. constructor(
  51029. /** defines the name of the probe */
  51030. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51031. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51032. samples: number;
  51033. /** Gets or sets the refresh rate to use (on every frame by default) */
  51034. refreshRate: number;
  51035. /**
  51036. * Gets the hosting scene
  51037. * @returns a Scene
  51038. */
  51039. getScene(): Scene;
  51040. /** Gets the internal CubeTexture used to render to */
  51041. readonly cubeTexture: RenderTargetTexture;
  51042. /** Gets the list of meshes to render */
  51043. readonly renderList: Nullable<AbstractMesh[]>;
  51044. /**
  51045. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51046. * @param mesh defines the mesh to attach to
  51047. */
  51048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51049. /**
  51050. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51051. * @param renderingGroupId The rendering group id corresponding to its index
  51052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51053. */
  51054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51055. /**
  51056. * Clean all associated resources
  51057. */
  51058. dispose(): void;
  51059. /**
  51060. * Converts the reflection probe information to a readable string for debug purpose.
  51061. * @param fullDetails Supports for multiple levels of logging within scene loading
  51062. * @returns the human readable reflection probe info
  51063. */
  51064. toString(fullDetails?: boolean): string;
  51065. /**
  51066. * Get the class name of the relfection probe.
  51067. * @returns "ReflectionProbe"
  51068. */
  51069. getClassName(): string;
  51070. /**
  51071. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51072. * @returns The JSON representation of the texture
  51073. */
  51074. serialize(): any;
  51075. /**
  51076. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51077. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51078. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51080. * @returns The parsed reflection probe if successful
  51081. */
  51082. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51083. }
  51084. }
  51085. declare module BABYLON {
  51086. /** @hidden */
  51087. export var _BabylonLoaderRegistered: boolean;
  51088. }
  51089. declare module BABYLON {
  51090. /**
  51091. * The Physically based simple base material of BJS.
  51092. *
  51093. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51094. * It is used as the base class for both the specGloss and metalRough conventions.
  51095. */
  51096. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51097. /**
  51098. * Number of Simultaneous lights allowed on the material.
  51099. */
  51100. maxSimultaneousLights: number;
  51101. /**
  51102. * If sets to true, disables all the lights affecting the material.
  51103. */
  51104. disableLighting: boolean;
  51105. /**
  51106. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51107. */
  51108. environmentTexture: BaseTexture;
  51109. /**
  51110. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51111. */
  51112. invertNormalMapX: boolean;
  51113. /**
  51114. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51115. */
  51116. invertNormalMapY: boolean;
  51117. /**
  51118. * Normal map used in the model.
  51119. */
  51120. normalTexture: BaseTexture;
  51121. /**
  51122. * Emissivie color used to self-illuminate the model.
  51123. */
  51124. emissiveColor: Color3;
  51125. /**
  51126. * Emissivie texture used to self-illuminate the model.
  51127. */
  51128. emissiveTexture: BaseTexture;
  51129. /**
  51130. * Occlusion Channel Strenght.
  51131. */
  51132. occlusionStrength: number;
  51133. /**
  51134. * Occlusion Texture of the material (adding extra occlusion effects).
  51135. */
  51136. occlusionTexture: BaseTexture;
  51137. /**
  51138. * Defines the alpha limits in alpha test mode.
  51139. */
  51140. alphaCutOff: number;
  51141. /**
  51142. * Gets the current double sided mode.
  51143. */
  51144. /**
  51145. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51146. */
  51147. doubleSided: boolean;
  51148. /**
  51149. * Stores the pre-calculated light information of a mesh in a texture.
  51150. */
  51151. lightmapTexture: BaseTexture;
  51152. /**
  51153. * If true, the light map contains occlusion information instead of lighting info.
  51154. */
  51155. useLightmapAsShadowmap: boolean;
  51156. /**
  51157. * Instantiates a new PBRMaterial instance.
  51158. *
  51159. * @param name The material name
  51160. * @param scene The scene the material will be use in.
  51161. */
  51162. constructor(name: string, scene: Scene);
  51163. getClassName(): string;
  51164. }
  51165. }
  51166. declare module BABYLON {
  51167. /**
  51168. * The PBR material of BJS following the metal roughness convention.
  51169. *
  51170. * This fits to the PBR convention in the GLTF definition:
  51171. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51172. */
  51173. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51174. /**
  51175. * The base color has two different interpretations depending on the value of metalness.
  51176. * When the material is a metal, the base color is the specific measured reflectance value
  51177. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51178. * of the material.
  51179. */
  51180. baseColor: Color3;
  51181. /**
  51182. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51183. * well as opacity information in the alpha channel.
  51184. */
  51185. baseTexture: BaseTexture;
  51186. /**
  51187. * Specifies the metallic scalar value of the material.
  51188. * Can also be used to scale the metalness values of the metallic texture.
  51189. */
  51190. metallic: number;
  51191. /**
  51192. * Specifies the roughness scalar value of the material.
  51193. * Can also be used to scale the roughness values of the metallic texture.
  51194. */
  51195. roughness: number;
  51196. /**
  51197. * Texture containing both the metallic value in the B channel and the
  51198. * roughness value in the G channel to keep better precision.
  51199. */
  51200. metallicRoughnessTexture: BaseTexture;
  51201. /**
  51202. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51203. *
  51204. * @param name The material name
  51205. * @param scene The scene the material will be use in.
  51206. */
  51207. constructor(name: string, scene: Scene);
  51208. /**
  51209. * Return the currrent class name of the material.
  51210. */
  51211. getClassName(): string;
  51212. /**
  51213. * Makes a duplicate of the current material.
  51214. * @param name - name to use for the new material.
  51215. */
  51216. clone(name: string): PBRMetallicRoughnessMaterial;
  51217. /**
  51218. * Serialize the material to a parsable JSON object.
  51219. */
  51220. serialize(): any;
  51221. /**
  51222. * Parses a JSON object correponding to the serialize function.
  51223. */
  51224. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51225. }
  51226. }
  51227. declare module BABYLON {
  51228. /**
  51229. * The PBR material of BJS following the specular glossiness convention.
  51230. *
  51231. * This fits to the PBR convention in the GLTF definition:
  51232. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51233. */
  51234. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51235. /**
  51236. * Specifies the diffuse color of the material.
  51237. */
  51238. diffuseColor: Color3;
  51239. /**
  51240. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51241. * channel.
  51242. */
  51243. diffuseTexture: BaseTexture;
  51244. /**
  51245. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51246. */
  51247. specularColor: Color3;
  51248. /**
  51249. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51250. */
  51251. glossiness: number;
  51252. /**
  51253. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51254. */
  51255. specularGlossinessTexture: BaseTexture;
  51256. /**
  51257. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51258. *
  51259. * @param name The material name
  51260. * @param scene The scene the material will be use in.
  51261. */
  51262. constructor(name: string, scene: Scene);
  51263. /**
  51264. * Return the currrent class name of the material.
  51265. */
  51266. getClassName(): string;
  51267. /**
  51268. * Makes a duplicate of the current material.
  51269. * @param name - name to use for the new material.
  51270. */
  51271. clone(name: string): PBRSpecularGlossinessMaterial;
  51272. /**
  51273. * Serialize the material to a parsable JSON object.
  51274. */
  51275. serialize(): any;
  51276. /**
  51277. * Parses a JSON object correponding to the serialize function.
  51278. */
  51279. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51280. }
  51281. }
  51282. declare module BABYLON {
  51283. /**
  51284. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51285. * It can help converting any input color in a desired output one. This can then be used to create effects
  51286. * from sepia, black and white to sixties or futuristic rendering...
  51287. *
  51288. * The only supported format is currently 3dl.
  51289. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51290. */
  51291. export class ColorGradingTexture extends BaseTexture {
  51292. /**
  51293. * The current texture matrix. (will always be identity in color grading texture)
  51294. */
  51295. private _textureMatrix;
  51296. /**
  51297. * The texture URL.
  51298. */
  51299. url: string;
  51300. /**
  51301. * Empty line regex stored for GC.
  51302. */
  51303. private static _noneEmptyLineRegex;
  51304. private _engine;
  51305. /**
  51306. * Instantiates a ColorGradingTexture from the following parameters.
  51307. *
  51308. * @param url The location of the color gradind data (currently only supporting 3dl)
  51309. * @param scene The scene the texture will be used in
  51310. */
  51311. constructor(url: string, scene: Scene);
  51312. /**
  51313. * Returns the texture matrix used in most of the material.
  51314. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51315. */
  51316. getTextureMatrix(): Matrix;
  51317. /**
  51318. * Occurs when the file being loaded is a .3dl LUT file.
  51319. */
  51320. private load3dlTexture;
  51321. /**
  51322. * Starts the loading process of the texture.
  51323. */
  51324. private loadTexture;
  51325. /**
  51326. * Clones the color gradind texture.
  51327. */
  51328. clone(): ColorGradingTexture;
  51329. /**
  51330. * Called during delayed load for textures.
  51331. */
  51332. delayLoad(): void;
  51333. /**
  51334. * Parses a color grading texture serialized by Babylon.
  51335. * @param parsedTexture The texture information being parsedTexture
  51336. * @param scene The scene to load the texture in
  51337. * @param rootUrl The root url of the data assets to load
  51338. * @return A color gradind texture
  51339. */
  51340. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51341. /**
  51342. * Serializes the LUT texture to json format.
  51343. */
  51344. serialize(): any;
  51345. }
  51346. }
  51347. declare module BABYLON {
  51348. /**
  51349. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51350. */
  51351. export class EquiRectangularCubeTexture extends BaseTexture {
  51352. /** The six faces of the cube. */
  51353. private static _FacesMapping;
  51354. private _noMipmap;
  51355. private _onLoad;
  51356. private _onError;
  51357. /** The size of the cubemap. */
  51358. private _size;
  51359. /** The buffer of the image. */
  51360. private _buffer;
  51361. /** The width of the input image. */
  51362. private _width;
  51363. /** The height of the input image. */
  51364. private _height;
  51365. /** The URL to the image. */
  51366. url: string;
  51367. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51368. coordinatesMode: number;
  51369. /**
  51370. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51371. * @param url The location of the image
  51372. * @param scene The scene the texture will be used in
  51373. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51374. * @param noMipmap Forces to not generate the mipmap if true
  51375. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51376. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51377. * @param onLoad — defines a callback called when texture is loaded
  51378. * @param onError — defines a callback called if there is an error
  51379. */
  51380. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51381. /**
  51382. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51383. */
  51384. private loadImage;
  51385. /**
  51386. * Convert the image buffer into a cubemap and create a CubeTexture.
  51387. */
  51388. private loadTexture;
  51389. /**
  51390. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51391. * @param buffer The ArrayBuffer that should be converted.
  51392. * @returns The buffer as Float32Array.
  51393. */
  51394. private getFloat32ArrayFromArrayBuffer;
  51395. /**
  51396. * Get the current class name of the texture useful for serialization or dynamic coding.
  51397. * @returns "EquiRectangularCubeTexture"
  51398. */
  51399. getClassName(): string;
  51400. /**
  51401. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51402. * @returns A clone of the current EquiRectangularCubeTexture.
  51403. */
  51404. clone(): EquiRectangularCubeTexture;
  51405. }
  51406. }
  51407. declare module BABYLON {
  51408. /**
  51409. * Based on jsTGALoader - Javascript loader for TGA file
  51410. * By Vincent Thibault
  51411. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51412. */
  51413. export class TGATools {
  51414. private static _TYPE_INDEXED;
  51415. private static _TYPE_RGB;
  51416. private static _TYPE_GREY;
  51417. private static _TYPE_RLE_INDEXED;
  51418. private static _TYPE_RLE_RGB;
  51419. private static _TYPE_RLE_GREY;
  51420. private static _ORIGIN_MASK;
  51421. private static _ORIGIN_SHIFT;
  51422. private static _ORIGIN_BL;
  51423. private static _ORIGIN_BR;
  51424. private static _ORIGIN_UL;
  51425. private static _ORIGIN_UR;
  51426. /**
  51427. * Gets the header of a TGA file
  51428. * @param data defines the TGA data
  51429. * @returns the header
  51430. */
  51431. static GetTGAHeader(data: Uint8Array): any;
  51432. /**
  51433. * Uploads TGA content to a Babylon Texture
  51434. * @hidden
  51435. */
  51436. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51437. /** @hidden */
  51438. 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;
  51439. /** @hidden */
  51440. 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;
  51441. /** @hidden */
  51442. 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;
  51443. /** @hidden */
  51444. 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;
  51445. /** @hidden */
  51446. 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;
  51447. /** @hidden */
  51448. 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;
  51449. }
  51450. }
  51451. declare module BABYLON {
  51452. /**
  51453. * Implementation of the TGA Texture Loader.
  51454. * @hidden
  51455. */
  51456. export class _TGATextureLoader implements IInternalTextureLoader {
  51457. /**
  51458. * Defines wether the loader supports cascade loading the different faces.
  51459. */
  51460. readonly supportCascades: boolean;
  51461. /**
  51462. * This returns if the loader support the current file information.
  51463. * @param extension defines the file extension of the file being loaded
  51464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51465. * @param fallback defines the fallback internal texture if any
  51466. * @param isBase64 defines whether the texture is encoded as a base64
  51467. * @param isBuffer defines whether the texture data are stored as a buffer
  51468. * @returns true if the loader can load the specified file
  51469. */
  51470. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51471. /**
  51472. * Transform the url before loading if required.
  51473. * @param rootUrl the url of the texture
  51474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51475. * @returns the transformed texture
  51476. */
  51477. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51478. /**
  51479. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51480. * @param rootUrl the url of the texture
  51481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51482. * @returns the fallback texture
  51483. */
  51484. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51485. /**
  51486. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51487. * @param data contains the texture data
  51488. * @param texture defines the BabylonJS internal texture
  51489. * @param createPolynomials will be true if polynomials have been requested
  51490. * @param onLoad defines the callback to trigger once the texture is ready
  51491. * @param onError defines the callback to trigger in case of error
  51492. */
  51493. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51494. /**
  51495. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51496. * @param data contains the texture data
  51497. * @param texture defines the BabylonJS internal texture
  51498. * @param callback defines the method to call once ready to upload
  51499. */
  51500. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51501. }
  51502. }
  51503. declare module BABYLON {
  51504. /**
  51505. * Info about the .basis files
  51506. */
  51507. class BasisFileInfo {
  51508. /**
  51509. * If the file has alpha
  51510. */
  51511. hasAlpha: boolean;
  51512. /**
  51513. * Info about each image of the basis file
  51514. */
  51515. images: Array<{
  51516. levels: Array<{
  51517. width: number;
  51518. height: number;
  51519. transcodedPixels: ArrayBufferView;
  51520. }>;
  51521. }>;
  51522. }
  51523. /**
  51524. * Result of transcoding a basis file
  51525. */
  51526. class TranscodeResult {
  51527. /**
  51528. * Info about the .basis file
  51529. */
  51530. fileInfo: BasisFileInfo;
  51531. /**
  51532. * Format to use when loading the file
  51533. */
  51534. format: number;
  51535. }
  51536. /**
  51537. * Configuration options for the Basis transcoder
  51538. */
  51539. export class BasisTranscodeConfiguration {
  51540. /**
  51541. * Supported compression formats used to determine the supported output format of the transcoder
  51542. */
  51543. supportedCompressionFormats?: {
  51544. /**
  51545. * etc1 compression format
  51546. */
  51547. etc1?: boolean;
  51548. /**
  51549. * s3tc compression format
  51550. */
  51551. s3tc?: boolean;
  51552. /**
  51553. * pvrtc compression format
  51554. */
  51555. pvrtc?: boolean;
  51556. /**
  51557. * etc2 compression format
  51558. */
  51559. etc2?: boolean;
  51560. };
  51561. /**
  51562. * If mipmap levels should be loaded for transcoded images (Default: true)
  51563. */
  51564. loadMipmapLevels?: boolean;
  51565. /**
  51566. * Index of a single image to load (Default: all images)
  51567. */
  51568. loadSingleImage?: number;
  51569. }
  51570. /**
  51571. * Used to load .Basis files
  51572. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51573. */
  51574. export class BasisTools {
  51575. private static _IgnoreSupportedFormats;
  51576. /**
  51577. * URL to use when loading the basis transcoder
  51578. */
  51579. static JSModuleURL: string;
  51580. /**
  51581. * URL to use when loading the wasm module for the transcoder
  51582. */
  51583. static WasmModuleURL: string;
  51584. /**
  51585. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51586. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51587. * @returns internal format corresponding to the Basis format
  51588. */
  51589. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51590. private static _WorkerPromise;
  51591. private static _Worker;
  51592. private static _actionId;
  51593. private static _CreateWorkerAsync;
  51594. /**
  51595. * Transcodes a loaded image file to compressed pixel data
  51596. * @param imageData image data to transcode
  51597. * @param config configuration options for the transcoding
  51598. * @returns a promise resulting in the transcoded image
  51599. */
  51600. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51601. /**
  51602. * Loads a texture from the transcode result
  51603. * @param texture texture load to
  51604. * @param transcodeResult the result of transcoding the basis file to load from
  51605. */
  51606. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51607. }
  51608. }
  51609. declare module BABYLON {
  51610. /**
  51611. * Loader for .basis file format
  51612. */
  51613. export class _BasisTextureLoader implements IInternalTextureLoader {
  51614. /**
  51615. * Defines whether the loader supports cascade loading the different faces.
  51616. */
  51617. readonly supportCascades: boolean;
  51618. /**
  51619. * This returns if the loader support the current file information.
  51620. * @param extension defines the file extension of the file being loaded
  51621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51622. * @param fallback defines the fallback internal texture if any
  51623. * @param isBase64 defines whether the texture is encoded as a base64
  51624. * @param isBuffer defines whether the texture data are stored as a buffer
  51625. * @returns true if the loader can load the specified file
  51626. */
  51627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51628. /**
  51629. * Transform the url before loading if required.
  51630. * @param rootUrl the url of the texture
  51631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51632. * @returns the transformed texture
  51633. */
  51634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51635. /**
  51636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51637. * @param rootUrl the url of the texture
  51638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51639. * @returns the fallback texture
  51640. */
  51641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51642. /**
  51643. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51644. * @param data contains the texture data
  51645. * @param texture defines the BabylonJS internal texture
  51646. * @param createPolynomials will be true if polynomials have been requested
  51647. * @param onLoad defines the callback to trigger once the texture is ready
  51648. * @param onError defines the callback to trigger in case of error
  51649. */
  51650. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51651. /**
  51652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51653. * @param data contains the texture data
  51654. * @param texture defines the BabylonJS internal texture
  51655. * @param callback defines the method to call once ready to upload
  51656. */
  51657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51658. }
  51659. }
  51660. declare module BABYLON {
  51661. /**
  51662. * 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.
  51663. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51664. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51665. */
  51666. export class CustomProceduralTexture extends ProceduralTexture {
  51667. private _animate;
  51668. private _time;
  51669. private _config;
  51670. private _texturePath;
  51671. /**
  51672. * Instantiates a new Custom Procedural Texture.
  51673. * 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.
  51674. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51675. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51676. * @param name Define the name of the texture
  51677. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51678. * @param size Define the size of the texture to create
  51679. * @param scene Define the scene the texture belongs to
  51680. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51681. * @param generateMipMaps Define if the texture should creates mip maps or not
  51682. */
  51683. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51684. private _loadJson;
  51685. /**
  51686. * Is the texture ready to be used ? (rendered at least once)
  51687. * @returns true if ready, otherwise, false.
  51688. */
  51689. isReady(): boolean;
  51690. /**
  51691. * Render the texture to its associated render target.
  51692. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51693. */
  51694. render(useCameraPostProcess?: boolean): void;
  51695. /**
  51696. * Update the list of dependant textures samplers in the shader.
  51697. */
  51698. updateTextures(): void;
  51699. /**
  51700. * Update the uniform values of the procedural texture in the shader.
  51701. */
  51702. updateShaderUniforms(): void;
  51703. /**
  51704. * Define if the texture animates or not.
  51705. */
  51706. animate: boolean;
  51707. }
  51708. }
  51709. declare module BABYLON {
  51710. /** @hidden */
  51711. export var noisePixelShader: {
  51712. name: string;
  51713. shader: string;
  51714. };
  51715. }
  51716. declare module BABYLON {
  51717. /**
  51718. * Class used to generate noise procedural textures
  51719. */
  51720. export class NoiseProceduralTexture extends ProceduralTexture {
  51721. private _time;
  51722. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51723. brightness: number;
  51724. /** Defines the number of octaves to process */
  51725. octaves: number;
  51726. /** Defines the level of persistence (0.8 by default) */
  51727. persistence: number;
  51728. /** Gets or sets animation speed factor (default is 1) */
  51729. animationSpeedFactor: number;
  51730. /**
  51731. * Creates a new NoiseProceduralTexture
  51732. * @param name defines the name fo the texture
  51733. * @param size defines the size of the texture (default is 256)
  51734. * @param scene defines the hosting scene
  51735. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51736. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51737. */
  51738. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51739. private _updateShaderUniforms;
  51740. protected _getDefines(): string;
  51741. /** Generate the current state of the procedural texture */
  51742. render(useCameraPostProcess?: boolean): void;
  51743. /**
  51744. * Serializes this noise procedural texture
  51745. * @returns a serialized noise procedural texture object
  51746. */
  51747. serialize(): any;
  51748. /**
  51749. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51750. * @param parsedTexture defines parsed texture data
  51751. * @param scene defines the current scene
  51752. * @param rootUrl defines the root URL containing noise procedural texture information
  51753. * @returns a parsed NoiseProceduralTexture
  51754. */
  51755. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. /**
  51760. * Raw cube texture where the raw buffers are passed in
  51761. */
  51762. export class RawCubeTexture extends CubeTexture {
  51763. /**
  51764. * Creates a cube texture where the raw buffers are passed in.
  51765. * @param scene defines the scene the texture is attached to
  51766. * @param data defines the array of data to use to create each face
  51767. * @param size defines the size of the textures
  51768. * @param format defines the format of the data
  51769. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51770. * @param generateMipMaps defines if the engine should generate the mip levels
  51771. * @param invertY defines if data must be stored with Y axis inverted
  51772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51773. * @param compression defines the compression used (null by default)
  51774. */
  51775. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51776. /**
  51777. * Updates the raw cube texture.
  51778. * @param data defines the data to store
  51779. * @param format defines the data format
  51780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51781. * @param invertY defines if data must be stored with Y axis inverted
  51782. * @param compression defines the compression used (null by default)
  51783. * @param level defines which level of the texture to update
  51784. */
  51785. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51786. /**
  51787. * Updates a raw cube texture with RGBD encoded data.
  51788. * @param data defines the array of data [mipmap][face] to use to create each face
  51789. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51792. * @returns a promsie that resolves when the operation is complete
  51793. */
  51794. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51795. /**
  51796. * Clones the raw cube texture.
  51797. * @return a new cube texture
  51798. */
  51799. clone(): CubeTexture;
  51800. /** @hidden */
  51801. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51802. }
  51803. }
  51804. declare module BABYLON {
  51805. /**
  51806. * Class used to store 3D textures containing user data
  51807. */
  51808. export class RawTexture3D extends Texture {
  51809. /** Gets or sets the texture format to use */
  51810. format: number;
  51811. private _engine;
  51812. /**
  51813. * Create a new RawTexture3D
  51814. * @param data defines the data of the texture
  51815. * @param width defines the width of the texture
  51816. * @param height defines the height of the texture
  51817. * @param depth defines the depth of the texture
  51818. * @param format defines the texture format to use
  51819. * @param scene defines the hosting scene
  51820. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51821. * @param invertY defines if texture must be stored with Y axis inverted
  51822. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51823. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51824. */
  51825. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51826. /** Gets or sets the texture format to use */
  51827. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51828. /**
  51829. * Update the texture with new data
  51830. * @param data defines the data to store in the texture
  51831. */
  51832. update(data: ArrayBufferView): void;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Creates a refraction texture used by refraction channel of the standard material.
  51838. * It is like a mirror but to see through a material.
  51839. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51840. */
  51841. export class RefractionTexture extends RenderTargetTexture {
  51842. /**
  51843. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51844. * 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.
  51845. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51846. */
  51847. refractionPlane: Plane;
  51848. /**
  51849. * Define how deep under the surface we should see.
  51850. */
  51851. depth: number;
  51852. /**
  51853. * Creates a refraction texture used by refraction channel of the standard material.
  51854. * It is like a mirror but to see through a material.
  51855. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51856. * @param name Define the texture name
  51857. * @param size Define the size of the underlying texture
  51858. * @param scene Define the scene the refraction belongs to
  51859. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51860. */
  51861. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51862. /**
  51863. * Clone the refraction texture.
  51864. * @returns the cloned texture
  51865. */
  51866. clone(): RefractionTexture;
  51867. /**
  51868. * Serialize the texture to a JSON representation you could use in Parse later on
  51869. * @returns the serialized JSON representation
  51870. */
  51871. serialize(): any;
  51872. }
  51873. }
  51874. declare module BABYLON {
  51875. /**
  51876. * Defines the options related to the creation of an HtmlElementTexture
  51877. */
  51878. export interface IHtmlElementTextureOptions {
  51879. /**
  51880. * Defines wether mip maps should be created or not.
  51881. */
  51882. generateMipMaps?: boolean;
  51883. /**
  51884. * Defines the sampling mode of the texture.
  51885. */
  51886. samplingMode?: number;
  51887. /**
  51888. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51889. */
  51890. engine: Nullable<Engine>;
  51891. /**
  51892. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51893. */
  51894. scene: Nullable<Scene>;
  51895. }
  51896. /**
  51897. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51898. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51899. * is automatically managed.
  51900. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51901. * in your application.
  51902. *
  51903. * As the update is not automatic, you need to call them manually.
  51904. */
  51905. export class HtmlElementTexture extends BaseTexture {
  51906. /**
  51907. * The texture URL.
  51908. */
  51909. element: HTMLVideoElement | HTMLCanvasElement;
  51910. private static readonly DefaultOptions;
  51911. private _textureMatrix;
  51912. private _engine;
  51913. private _isVideo;
  51914. private _generateMipMaps;
  51915. private _samplingMode;
  51916. /**
  51917. * Instantiates a HtmlElementTexture from the following parameters.
  51918. *
  51919. * @param name Defines the name of the texture
  51920. * @param element Defines the video or canvas the texture is filled with
  51921. * @param options Defines the other none mandatory texture creation options
  51922. */
  51923. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51924. private _createInternalTexture;
  51925. /**
  51926. * Returns the texture matrix used in most of the material.
  51927. */
  51928. getTextureMatrix(): Matrix;
  51929. /**
  51930. * Updates the content of the texture.
  51931. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51932. */
  51933. update(invertY?: Nullable<boolean>): void;
  51934. }
  51935. }
  51936. declare module BABYLON {
  51937. /**
  51938. * Enum used to define the target of a block
  51939. */
  51940. export enum NodeMaterialBlockTargets {
  51941. /** Vertex shader */
  51942. Vertex = 1,
  51943. /** Fragment shader */
  51944. Fragment = 2,
  51945. /** Neutral */
  51946. Neutral = 4,
  51947. /** Vertex and Fragment */
  51948. VertexAndFragment = 3
  51949. }
  51950. }
  51951. declare module BABYLON {
  51952. /**
  51953. * Defines the kind of connection point for node based material
  51954. */
  51955. export enum NodeMaterialBlockConnectionPointTypes {
  51956. /** Float */
  51957. Float = 1,
  51958. /** Int */
  51959. Int = 2,
  51960. /** Vector2 */
  51961. Vector2 = 4,
  51962. /** Vector3 */
  51963. Vector3 = 8,
  51964. /** Vector4 */
  51965. Vector4 = 16,
  51966. /** Color3 */
  51967. Color3 = 32,
  51968. /** Color4 */
  51969. Color4 = 64,
  51970. /** Matrix */
  51971. Matrix = 128,
  51972. /** Detect type based on connection */
  51973. AutoDetect = 1024,
  51974. /** Output type that will be defined by input type */
  51975. BasedOnInput = 2048
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * Root class for all node material optimizers
  51981. */
  51982. export class NodeMaterialOptimizer {
  51983. /**
  51984. * Function used to optimize a NodeMaterial graph
  51985. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51986. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51987. */
  51988. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51989. }
  51990. }
  51991. declare module BABYLON {
  51992. /**
  51993. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51994. */
  51995. export class TransformBlock extends NodeMaterialBlock {
  51996. /**
  51997. * Defines the value to use to complement W value to transform it to a Vector4
  51998. */
  51999. complementW: number;
  52000. /**
  52001. * Defines the value to use to complement z value to transform it to a Vector4
  52002. */
  52003. complementZ: number;
  52004. /**
  52005. * Creates a new TransformBlock
  52006. * @param name defines the block name
  52007. */
  52008. constructor(name: string);
  52009. /**
  52010. * Gets the current class name
  52011. * @returns the class name
  52012. */
  52013. getClassName(): string;
  52014. /**
  52015. * Gets the vector input
  52016. */
  52017. readonly vector: NodeMaterialConnectionPoint;
  52018. /**
  52019. * Gets the output component
  52020. */
  52021. readonly output: NodeMaterialConnectionPoint;
  52022. /**
  52023. * Gets the matrix transform input
  52024. */
  52025. readonly transform: NodeMaterialConnectionPoint;
  52026. protected _buildBlock(state: NodeMaterialBuildState): this;
  52027. serialize(): any;
  52028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52029. protected _dumpPropertiesCode(): string;
  52030. }
  52031. }
  52032. declare module BABYLON {
  52033. /**
  52034. * Block used to output the vertex position
  52035. */
  52036. export class VertexOutputBlock extends NodeMaterialBlock {
  52037. /**
  52038. * Creates a new VertexOutputBlock
  52039. * @param name defines the block name
  52040. */
  52041. constructor(name: string);
  52042. /**
  52043. * Gets the current class name
  52044. * @returns the class name
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Gets the vector input component
  52049. */
  52050. readonly vector: NodeMaterialConnectionPoint;
  52051. protected _buildBlock(state: NodeMaterialBuildState): this;
  52052. }
  52053. }
  52054. declare module BABYLON {
  52055. /**
  52056. * Block used to output the final color
  52057. */
  52058. export class FragmentOutputBlock extends NodeMaterialBlock {
  52059. /**
  52060. * Create a new FragmentOutputBlock
  52061. * @param name defines the block name
  52062. */
  52063. constructor(name: string);
  52064. /**
  52065. * Gets the current class name
  52066. * @returns the class name
  52067. */
  52068. getClassName(): string;
  52069. /**
  52070. * Gets the rgba input component
  52071. */
  52072. readonly rgba: NodeMaterialConnectionPoint;
  52073. /**
  52074. * Gets the rgb input component
  52075. */
  52076. readonly rgb: NodeMaterialConnectionPoint;
  52077. /**
  52078. * Gets the a input component
  52079. */
  52080. readonly a: NodeMaterialConnectionPoint;
  52081. protected _buildBlock(state: NodeMaterialBuildState): this;
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /**
  52086. * Enum used to define system values e.g. values automatically provided by the system
  52087. */
  52088. export enum NodeMaterialSystemValues {
  52089. /** World */
  52090. World = 1,
  52091. /** View */
  52092. View = 2,
  52093. /** Projection */
  52094. Projection = 3,
  52095. /** ViewProjection */
  52096. ViewProjection = 4,
  52097. /** WorldView */
  52098. WorldView = 5,
  52099. /** WorldViewProjection */
  52100. WorldViewProjection = 6,
  52101. /** CameraPosition */
  52102. CameraPosition = 7,
  52103. /** Fog Color */
  52104. FogColor = 8
  52105. }
  52106. }
  52107. declare module BABYLON {
  52108. /**
  52109. * Block used to read a reflection texture from a sampler
  52110. */
  52111. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52112. private _define3DName;
  52113. private _defineCubicName;
  52114. private _defineExplicitName;
  52115. private _defineProjectionName;
  52116. private _defineLocalCubicName;
  52117. private _defineSphericalName;
  52118. private _definePlanarName;
  52119. private _defineEquirectangularName;
  52120. private _defineMirroredEquirectangularFixedName;
  52121. private _defineEquirectangularFixedName;
  52122. private _defineSkyboxName;
  52123. private _cubeSamplerName;
  52124. private _2DSamplerName;
  52125. private _positionUVWName;
  52126. private _directionWName;
  52127. private _reflectionCoordsName;
  52128. private _reflection2DCoordsName;
  52129. private _reflectionColorName;
  52130. private _reflectionMatrixName;
  52131. /**
  52132. * Gets or sets the texture associated with the node
  52133. */
  52134. texture: Nullable<BaseTexture>;
  52135. /**
  52136. * Create a new TextureBlock
  52137. * @param name defines the block name
  52138. */
  52139. constructor(name: string);
  52140. /**
  52141. * Gets the current class name
  52142. * @returns the class name
  52143. */
  52144. getClassName(): string;
  52145. /**
  52146. * Gets the world position input component
  52147. */
  52148. readonly position: NodeMaterialConnectionPoint;
  52149. /**
  52150. * Gets the world position input component
  52151. */
  52152. readonly worldPosition: NodeMaterialConnectionPoint;
  52153. /**
  52154. * Gets the world normal input component
  52155. */
  52156. readonly worldNormal: NodeMaterialConnectionPoint;
  52157. /**
  52158. * Gets the world input component
  52159. */
  52160. readonly world: NodeMaterialConnectionPoint;
  52161. /**
  52162. * Gets the camera (or eye) position component
  52163. */
  52164. readonly cameraPosition: NodeMaterialConnectionPoint;
  52165. /**
  52166. * Gets the view input component
  52167. */
  52168. readonly view: NodeMaterialConnectionPoint;
  52169. /**
  52170. * Gets the rgb output component
  52171. */
  52172. readonly rgb: NodeMaterialConnectionPoint;
  52173. /**
  52174. * Gets the r output component
  52175. */
  52176. readonly r: NodeMaterialConnectionPoint;
  52177. /**
  52178. * Gets the g output component
  52179. */
  52180. readonly g: NodeMaterialConnectionPoint;
  52181. /**
  52182. * Gets the b output component
  52183. */
  52184. readonly b: NodeMaterialConnectionPoint;
  52185. autoConfigure(material: NodeMaterial): void;
  52186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52187. isReady(): boolean;
  52188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52189. private _injectVertexCode;
  52190. private _writeOutput;
  52191. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52192. serialize(): any;
  52193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * Interface used to configure the node material editor
  52199. */
  52200. export interface INodeMaterialEditorOptions {
  52201. /** Define the URl to load node editor script */
  52202. editorURL?: string;
  52203. }
  52204. /** @hidden */
  52205. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52206. /** BONES */
  52207. NUM_BONE_INFLUENCERS: number;
  52208. BonesPerMesh: number;
  52209. BONETEXTURE: boolean;
  52210. /** MORPH TARGETS */
  52211. MORPHTARGETS: boolean;
  52212. MORPHTARGETS_NORMAL: boolean;
  52213. MORPHTARGETS_TANGENT: boolean;
  52214. MORPHTARGETS_UV: boolean;
  52215. NUM_MORPH_INFLUENCERS: number;
  52216. /** IMAGE PROCESSING */
  52217. IMAGEPROCESSING: boolean;
  52218. VIGNETTE: boolean;
  52219. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52220. VIGNETTEBLENDMODEOPAQUE: boolean;
  52221. TONEMAPPING: boolean;
  52222. TONEMAPPING_ACES: boolean;
  52223. CONTRAST: boolean;
  52224. EXPOSURE: boolean;
  52225. COLORCURVES: boolean;
  52226. COLORGRADING: boolean;
  52227. COLORGRADING3D: boolean;
  52228. SAMPLER3DGREENDEPTH: boolean;
  52229. SAMPLER3DBGRMAP: boolean;
  52230. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52231. constructor();
  52232. setValue(name: string, value: boolean): void;
  52233. }
  52234. /**
  52235. * Class used to configure NodeMaterial
  52236. */
  52237. export interface INodeMaterialOptions {
  52238. /**
  52239. * Defines if blocks should emit comments
  52240. */
  52241. emitComments: boolean;
  52242. }
  52243. /**
  52244. * Class used to create a node based material built by assembling shader blocks
  52245. */
  52246. export class NodeMaterial extends PushMaterial {
  52247. private static _BuildIdGenerator;
  52248. private _options;
  52249. private _vertexCompilationState;
  52250. private _fragmentCompilationState;
  52251. private _sharedData;
  52252. private _buildId;
  52253. private _buildWasSuccessful;
  52254. private _cachedWorldViewMatrix;
  52255. private _cachedWorldViewProjectionMatrix;
  52256. private _optimizers;
  52257. private _animationFrame;
  52258. /** Define the URl to load node editor script */
  52259. static EditorURL: string;
  52260. private BJSNODEMATERIALEDITOR;
  52261. /** Get the inspector from bundle or global */
  52262. private _getGlobalNodeMaterialEditor;
  52263. /**
  52264. * 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)
  52265. */
  52266. ignoreAlpha: boolean;
  52267. /**
  52268. * Defines the maximum number of lights that can be used in the material
  52269. */
  52270. maxSimultaneousLights: number;
  52271. /**
  52272. * Observable raised when the material is built
  52273. */
  52274. onBuildObservable: Observable<NodeMaterial>;
  52275. /**
  52276. * Gets or sets the root nodes of the material vertex shader
  52277. */
  52278. _vertexOutputNodes: NodeMaterialBlock[];
  52279. /**
  52280. * Gets or sets the root nodes of the material fragment (pixel) shader
  52281. */
  52282. _fragmentOutputNodes: NodeMaterialBlock[];
  52283. /** Gets or sets options to control the node material overall behavior */
  52284. options: INodeMaterialOptions;
  52285. /**
  52286. * Default configuration related to image processing available in the standard Material.
  52287. */
  52288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52289. /**
  52290. * Gets the image processing configuration used either in this material.
  52291. */
  52292. /**
  52293. * Sets the Default image processing configuration used either in the this material.
  52294. *
  52295. * If sets to null, the scene one is in use.
  52296. */
  52297. imageProcessingConfiguration: ImageProcessingConfiguration;
  52298. /**
  52299. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52300. */
  52301. attachedBlocks: NodeMaterialBlock[];
  52302. /**
  52303. * Create a new node based material
  52304. * @param name defines the material name
  52305. * @param scene defines the hosting scene
  52306. * @param options defines creation option
  52307. */
  52308. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52309. /**
  52310. * Gets the current class name of the material e.g. "NodeMaterial"
  52311. * @returns the class name
  52312. */
  52313. getClassName(): string;
  52314. /**
  52315. * Keep track of the image processing observer to allow dispose and replace.
  52316. */
  52317. private _imageProcessingObserver;
  52318. /**
  52319. * Attaches a new image processing configuration to the Standard Material.
  52320. * @param configuration
  52321. */
  52322. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52323. /**
  52324. * Get a block by its name
  52325. * @param name defines the name of the block to retrieve
  52326. * @returns the required block or null if not found
  52327. */
  52328. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52329. /**
  52330. * Get a block by its name
  52331. * @param predicate defines the predicate used to find the good candidate
  52332. * @returns the required block or null if not found
  52333. */
  52334. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52335. /**
  52336. * Get an input block by its name
  52337. * @param predicate defines the predicate used to find the good candidate
  52338. * @returns the required input block or null if not found
  52339. */
  52340. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52341. /**
  52342. * Gets the list of input blocks attached to this material
  52343. * @returns an array of InputBlocks
  52344. */
  52345. getInputBlocks(): InputBlock[];
  52346. /**
  52347. * Adds a new optimizer to the list of optimizers
  52348. * @param optimizer defines the optimizers to add
  52349. * @returns the current material
  52350. */
  52351. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52352. /**
  52353. * Remove an optimizer from the list of optimizers
  52354. * @param optimizer defines the optimizers to remove
  52355. * @returns the current material
  52356. */
  52357. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52358. /**
  52359. * Add a new block to the list of output nodes
  52360. * @param node defines the node to add
  52361. * @returns the current material
  52362. */
  52363. addOutputNode(node: NodeMaterialBlock): this;
  52364. /**
  52365. * Remove a block from the list of root nodes
  52366. * @param node defines the node to remove
  52367. * @returns the current material
  52368. */
  52369. removeOutputNode(node: NodeMaterialBlock): this;
  52370. private _addVertexOutputNode;
  52371. private _removeVertexOutputNode;
  52372. private _addFragmentOutputNode;
  52373. private _removeFragmentOutputNode;
  52374. /**
  52375. * Specifies if the material will require alpha blending
  52376. * @returns a boolean specifying if alpha blending is needed
  52377. */
  52378. needAlphaBlending(): boolean;
  52379. /**
  52380. * Specifies if this material should be rendered in alpha test mode
  52381. * @returns a boolean specifying if an alpha test is needed.
  52382. */
  52383. needAlphaTesting(): boolean;
  52384. private _initializeBlock;
  52385. private _resetDualBlocks;
  52386. /**
  52387. * Build the material and generates the inner effect
  52388. * @param verbose defines if the build should log activity
  52389. */
  52390. build(verbose?: boolean): void;
  52391. /**
  52392. * Runs an otpimization phase to try to improve the shader code
  52393. */
  52394. optimize(): void;
  52395. private _prepareDefinesForAttributes;
  52396. /**
  52397. * Get if the submesh is ready to be used and all its information available.
  52398. * Child classes can use it to update shaders
  52399. * @param mesh defines the mesh to check
  52400. * @param subMesh defines which submesh to check
  52401. * @param useInstances specifies that instances should be used
  52402. * @returns a boolean indicating that the submesh is ready or not
  52403. */
  52404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52405. /**
  52406. * Get a string representing the shaders built by the current node graph
  52407. */
  52408. readonly compiledShaders: string;
  52409. /**
  52410. * Binds the world matrix to the material
  52411. * @param world defines the world transformation matrix
  52412. */
  52413. bindOnlyWorldMatrix(world: Matrix): void;
  52414. /**
  52415. * Binds the submesh to this material by preparing the effect and shader to draw
  52416. * @param world defines the world transformation matrix
  52417. * @param mesh defines the mesh containing the submesh
  52418. * @param subMesh defines the submesh to bind the material to
  52419. */
  52420. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52421. /**
  52422. * Gets the active textures from the material
  52423. * @returns an array of textures
  52424. */
  52425. getActiveTextures(): BaseTexture[];
  52426. /**
  52427. * Gets the list of texture blocks
  52428. * @returns an array of texture blocks
  52429. */
  52430. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52431. /**
  52432. * Specifies if the material uses a texture
  52433. * @param texture defines the texture to check against the material
  52434. * @returns a boolean specifying if the material uses the texture
  52435. */
  52436. hasTexture(texture: BaseTexture): boolean;
  52437. /**
  52438. * Disposes the material
  52439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52442. */
  52443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52444. /** Creates the node editor window. */
  52445. private _createNodeEditor;
  52446. /**
  52447. * Launch the node material editor
  52448. * @param config Define the configuration of the editor
  52449. * @return a promise fulfilled when the node editor is visible
  52450. */
  52451. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52452. /**
  52453. * Clear the current material
  52454. */
  52455. clear(): void;
  52456. /**
  52457. * Clear the current material and set it to a default state
  52458. */
  52459. setToDefault(): void;
  52460. /**
  52461. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52462. * @param url defines the url to load from
  52463. * @returns a promise that will fullfil when the material is fully loaded
  52464. */
  52465. loadAsync(url: string): Promise<unknown>;
  52466. private _gatherBlocks;
  52467. /**
  52468. * Generate a string containing the code declaration required to create an equivalent of this material
  52469. * @returns a string
  52470. */
  52471. generateCode(): string;
  52472. /**
  52473. * Serializes this material in a JSON representation
  52474. * @returns the serialized material object
  52475. */
  52476. serialize(): any;
  52477. private _restoreConnections;
  52478. /**
  52479. * Clear the current graph and load a new one from a serialization object
  52480. * @param source defines the JSON representation of the material
  52481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52482. */
  52483. loadFromSerialization(source: any, rootUrl?: string): void;
  52484. /**
  52485. * Creates a node material from parsed material data
  52486. * @param source defines the JSON representation of the material
  52487. * @param scene defines the hosting scene
  52488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52489. * @returns a new node material
  52490. */
  52491. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52492. /**
  52493. * Creates a new node material set to default basic configuration
  52494. * @param name defines the name of the material
  52495. * @param scene defines the hosting scene
  52496. * @returns a new NodeMaterial
  52497. */
  52498. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * Block used to read a texture from a sampler
  52504. */
  52505. export class TextureBlock extends NodeMaterialBlock {
  52506. private _defineName;
  52507. private _samplerName;
  52508. private _transformedUVName;
  52509. private _textureTransformName;
  52510. private _textureInfoName;
  52511. private _mainUVName;
  52512. private _mainUVDefineName;
  52513. /**
  52514. * Gets or sets the texture associated with the node
  52515. */
  52516. texture: Nullable<BaseTexture>;
  52517. /**
  52518. * Create a new TextureBlock
  52519. * @param name defines the block name
  52520. */
  52521. constructor(name: string);
  52522. /**
  52523. * Gets the current class name
  52524. * @returns the class name
  52525. */
  52526. getClassName(): string;
  52527. /**
  52528. * Gets the uv input component
  52529. */
  52530. readonly uv: NodeMaterialConnectionPoint;
  52531. /**
  52532. * Gets the rgba output component
  52533. */
  52534. readonly rgba: NodeMaterialConnectionPoint;
  52535. /**
  52536. * Gets the rgb output component
  52537. */
  52538. readonly rgb: NodeMaterialConnectionPoint;
  52539. /**
  52540. * Gets the r output component
  52541. */
  52542. readonly r: NodeMaterialConnectionPoint;
  52543. /**
  52544. * Gets the g output component
  52545. */
  52546. readonly g: NodeMaterialConnectionPoint;
  52547. /**
  52548. * Gets the b output component
  52549. */
  52550. readonly b: NodeMaterialConnectionPoint;
  52551. /**
  52552. * Gets the a output component
  52553. */
  52554. readonly a: NodeMaterialConnectionPoint;
  52555. readonly target: NodeMaterialBlockTargets;
  52556. autoConfigure(material: NodeMaterial): void;
  52557. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52559. isReady(): boolean;
  52560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52561. private readonly _isMixed;
  52562. private _injectVertexCode;
  52563. private _writeOutput;
  52564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52565. protected _dumpPropertiesCode(): string;
  52566. serialize(): any;
  52567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Class used to store shared data between 2 NodeMaterialBuildState
  52573. */
  52574. export class NodeMaterialBuildStateSharedData {
  52575. /**
  52576. * Gets the list of emitted varyings
  52577. */
  52578. temps: string[];
  52579. /**
  52580. * Gets the list of emitted varyings
  52581. */
  52582. varyings: string[];
  52583. /**
  52584. * Gets the varying declaration string
  52585. */
  52586. varyingDeclaration: string;
  52587. /**
  52588. * Input blocks
  52589. */
  52590. inputBlocks: InputBlock[];
  52591. /**
  52592. * Input blocks
  52593. */
  52594. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52595. /**
  52596. * Bindable blocks (Blocks that need to set data to the effect)
  52597. */
  52598. bindableBlocks: NodeMaterialBlock[];
  52599. /**
  52600. * List of blocks that can provide a compilation fallback
  52601. */
  52602. blocksWithFallbacks: NodeMaterialBlock[];
  52603. /**
  52604. * List of blocks that can provide a define update
  52605. */
  52606. blocksWithDefines: NodeMaterialBlock[];
  52607. /**
  52608. * List of blocks that can provide a repeatable content
  52609. */
  52610. repeatableContentBlocks: NodeMaterialBlock[];
  52611. /**
  52612. * List of blocks that can provide a dynamic list of uniforms
  52613. */
  52614. dynamicUniformBlocks: NodeMaterialBlock[];
  52615. /**
  52616. * List of blocks that can block the isReady function for the material
  52617. */
  52618. blockingBlocks: NodeMaterialBlock[];
  52619. /**
  52620. * Gets the list of animated inputs
  52621. */
  52622. animatedInputs: InputBlock[];
  52623. /**
  52624. * Build Id used to avoid multiple recompilations
  52625. */
  52626. buildId: number;
  52627. /** List of emitted variables */
  52628. variableNames: {
  52629. [key: string]: number;
  52630. };
  52631. /** List of emitted defines */
  52632. defineNames: {
  52633. [key: string]: number;
  52634. };
  52635. /** Should emit comments? */
  52636. emitComments: boolean;
  52637. /** Emit build activity */
  52638. verbose: boolean;
  52639. /**
  52640. * Gets the compilation hints emitted at compilation time
  52641. */
  52642. hints: {
  52643. needWorldViewMatrix: boolean;
  52644. needWorldViewProjectionMatrix: boolean;
  52645. needAlphaBlending: boolean;
  52646. needAlphaTesting: boolean;
  52647. };
  52648. /**
  52649. * List of compilation checks
  52650. */
  52651. checks: {
  52652. emitVertex: boolean;
  52653. emitFragment: boolean;
  52654. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52655. };
  52656. /** Creates a new shared data */
  52657. constructor();
  52658. /**
  52659. * Emits console errors and exceptions if there is a failing check
  52660. */
  52661. emitErrors(): void;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. /**
  52666. * Class used to store node based material build state
  52667. */
  52668. export class NodeMaterialBuildState {
  52669. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52670. supportUniformBuffers: boolean;
  52671. /**
  52672. * Gets the list of emitted attributes
  52673. */
  52674. attributes: string[];
  52675. /**
  52676. * Gets the list of emitted uniforms
  52677. */
  52678. uniforms: string[];
  52679. /**
  52680. * Gets the list of emitted uniform buffers
  52681. */
  52682. uniformBuffers: string[];
  52683. /**
  52684. * Gets the list of emitted samplers
  52685. */
  52686. samplers: string[];
  52687. /**
  52688. * Gets the list of emitted functions
  52689. */
  52690. functions: {
  52691. [key: string]: string;
  52692. };
  52693. /**
  52694. * Gets the target of the compilation state
  52695. */
  52696. target: NodeMaterialBlockTargets;
  52697. /**
  52698. * Gets the list of emitted counters
  52699. */
  52700. counters: {
  52701. [key: string]: number;
  52702. };
  52703. /**
  52704. * Shared data between multiple NodeMaterialBuildState instances
  52705. */
  52706. sharedData: NodeMaterialBuildStateSharedData;
  52707. /** @hidden */
  52708. _vertexState: NodeMaterialBuildState;
  52709. /** @hidden */
  52710. _attributeDeclaration: string;
  52711. /** @hidden */
  52712. _uniformDeclaration: string;
  52713. /** @hidden */
  52714. _samplerDeclaration: string;
  52715. /** @hidden */
  52716. _varyingTransfer: string;
  52717. private _repeatableContentAnchorIndex;
  52718. /** @hidden */
  52719. _builtCompilationString: string;
  52720. /**
  52721. * Gets the emitted compilation strings
  52722. */
  52723. compilationString: string;
  52724. /**
  52725. * Finalize the compilation strings
  52726. * @param state defines the current compilation state
  52727. */
  52728. finalize(state: NodeMaterialBuildState): void;
  52729. /** @hidden */
  52730. readonly _repeatableContentAnchor: string;
  52731. /** @hidden */
  52732. _getFreeVariableName(prefix: string): string;
  52733. /** @hidden */
  52734. _getFreeDefineName(prefix: string): string;
  52735. /** @hidden */
  52736. _excludeVariableName(name: string): void;
  52737. /** @hidden */
  52738. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52739. /** @hidden */
  52740. _emitFunction(name: string, code: string, comments: string): void;
  52741. /** @hidden */
  52742. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52743. replaceStrings?: {
  52744. search: RegExp;
  52745. replace: string;
  52746. }[];
  52747. repeatKey?: string;
  52748. }): string;
  52749. /** @hidden */
  52750. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52751. repeatKey?: string;
  52752. removeAttributes?: boolean;
  52753. removeUniforms?: boolean;
  52754. removeVaryings?: boolean;
  52755. removeIfDef?: boolean;
  52756. replaceStrings?: {
  52757. search: RegExp;
  52758. replace: string;
  52759. }[];
  52760. }, storeKey?: string): void;
  52761. /** @hidden */
  52762. _registerTempVariable(name: string): boolean;
  52763. /** @hidden */
  52764. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52765. /** @hidden */
  52766. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52767. }
  52768. }
  52769. declare module BABYLON {
  52770. /**
  52771. * Defines a block that can be used inside a node based material
  52772. */
  52773. export class NodeMaterialBlock {
  52774. private _buildId;
  52775. private _buildTarget;
  52776. private _target;
  52777. private _isFinalMerger;
  52778. private _isInput;
  52779. /** @hidden */
  52780. _codeVariableName: string;
  52781. /** @hidden */
  52782. _inputs: NodeMaterialConnectionPoint[];
  52783. /** @hidden */
  52784. _outputs: NodeMaterialConnectionPoint[];
  52785. /** @hidden */
  52786. _preparationId: number;
  52787. /**
  52788. * Gets or sets the name of the block
  52789. */
  52790. name: string;
  52791. /**
  52792. * Gets or sets the unique id of the node
  52793. */
  52794. uniqueId: number;
  52795. /**
  52796. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52797. */
  52798. readonly isFinalMerger: boolean;
  52799. /**
  52800. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52801. */
  52802. readonly isInput: boolean;
  52803. /**
  52804. * Gets or sets the build Id
  52805. */
  52806. buildId: number;
  52807. /**
  52808. * Gets or sets the target of the block
  52809. */
  52810. target: NodeMaterialBlockTargets;
  52811. /**
  52812. * Gets the list of input points
  52813. */
  52814. readonly inputs: NodeMaterialConnectionPoint[];
  52815. /** Gets the list of output points */
  52816. readonly outputs: NodeMaterialConnectionPoint[];
  52817. /**
  52818. * Find an input by its name
  52819. * @param name defines the name of the input to look for
  52820. * @returns the input or null if not found
  52821. */
  52822. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52823. /**
  52824. * Find an output by its name
  52825. * @param name defines the name of the outputto look for
  52826. * @returns the output or null if not found
  52827. */
  52828. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52829. /**
  52830. * Creates a new NodeMaterialBlock
  52831. * @param name defines the block name
  52832. * @param target defines the target of that block (Vertex by default)
  52833. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52834. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52835. */
  52836. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52837. /**
  52838. * Initialize the block and prepare the context for build
  52839. * @param state defines the state that will be used for the build
  52840. */
  52841. initialize(state: NodeMaterialBuildState): void;
  52842. /**
  52843. * Bind data to effect. Will only be called for blocks with isBindable === true
  52844. * @param effect defines the effect to bind data to
  52845. * @param nodeMaterial defines the hosting NodeMaterial
  52846. * @param mesh defines the mesh that will be rendered
  52847. */
  52848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52849. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52850. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52851. protected _writeFloat(value: number): string;
  52852. /**
  52853. * Gets the current class name e.g. "NodeMaterialBlock"
  52854. * @returns the class name
  52855. */
  52856. getClassName(): string;
  52857. /**
  52858. * Register a new input. Must be called inside a block constructor
  52859. * @param name defines the connection point name
  52860. * @param type defines the connection point type
  52861. * @param isOptional defines a boolean indicating that this input can be omitted
  52862. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52863. * @returns the current block
  52864. */
  52865. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52866. /**
  52867. * Register a new output. Must be called inside a block constructor
  52868. * @param name defines the connection point name
  52869. * @param type defines the connection point type
  52870. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52871. * @returns the current block
  52872. */
  52873. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52874. /**
  52875. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52876. * @param forOutput defines an optional connection point to check compatibility with
  52877. * @returns the first available input or null
  52878. */
  52879. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52880. /**
  52881. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52882. * @param forBlock defines an optional block to check compatibility with
  52883. * @returns the first available input or null
  52884. */
  52885. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52886. /**
  52887. * Gets the sibling of the given output
  52888. * @param current defines the current output
  52889. * @returns the next output in the list or null
  52890. */
  52891. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52892. /**
  52893. * Connect current block with another block
  52894. * @param other defines the block to connect with
  52895. * @param options define the various options to help pick the right connections
  52896. * @returns the current block
  52897. */
  52898. connectTo(other: NodeMaterialBlock, options?: {
  52899. input?: string;
  52900. output?: string;
  52901. outputSwizzle?: string;
  52902. }): this | undefined;
  52903. protected _buildBlock(state: NodeMaterialBuildState): void;
  52904. /**
  52905. * Add uniforms, samplers and uniform buffers at compilation time
  52906. * @param state defines the state to update
  52907. * @param nodeMaterial defines the node material requesting the update
  52908. * @param defines defines the material defines to update
  52909. */
  52910. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52911. /**
  52912. * Add potential fallbacks if shader compilation fails
  52913. * @param mesh defines the mesh to be rendered
  52914. * @param fallbacks defines the current prioritized list of fallbacks
  52915. */
  52916. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52917. /**
  52918. * Update defines for shader compilation
  52919. * @param mesh defines the mesh to be rendered
  52920. * @param nodeMaterial defines the node material requesting the update
  52921. * @param defines defines the material defines to update
  52922. * @param useInstances specifies that instances should be used
  52923. */
  52924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52925. /**
  52926. * Initialize defines for shader compilation
  52927. * @param mesh defines the mesh to be rendered
  52928. * @param nodeMaterial defines the node material requesting the update
  52929. * @param defines defines the material defines to be prepared
  52930. * @param useInstances specifies that instances should be used
  52931. */
  52932. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52933. /**
  52934. * Lets the block try to connect some inputs automatically
  52935. * @param material defines the hosting NodeMaterial
  52936. */
  52937. autoConfigure(material: NodeMaterial): void;
  52938. /**
  52939. * Function called when a block is declared as repeatable content generator
  52940. * @param vertexShaderState defines the current compilation state for the vertex shader
  52941. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52942. * @param mesh defines the mesh to be rendered
  52943. * @param defines defines the material defines to update
  52944. */
  52945. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52946. /**
  52947. * Checks if the block is ready
  52948. * @param mesh defines the mesh to be rendered
  52949. * @param nodeMaterial defines the node material requesting the update
  52950. * @param defines defines the material defines to update
  52951. * @param useInstances specifies that instances should be used
  52952. * @returns true if the block is ready
  52953. */
  52954. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52955. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52956. private _processBuild;
  52957. /**
  52958. * Compile the current node and generate the shader code
  52959. * @param state defines the current compilation state (uniforms, samplers, current string)
  52960. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52961. * @returns true if already built
  52962. */
  52963. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52964. protected _inputRename(name: string): string;
  52965. protected _outputRename(name: string): string;
  52966. protected _dumpPropertiesCode(): string;
  52967. /** @hidden */
  52968. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52969. /**
  52970. * Clone the current block to a new identical block
  52971. * @param scene defines the hosting scene
  52972. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52973. * @returns a copy of the current block
  52974. */
  52975. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52976. /**
  52977. * Serializes this block in a JSON representation
  52978. * @returns the serialized block object
  52979. */
  52980. serialize(): any;
  52981. /** @hidden */
  52982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52983. }
  52984. }
  52985. declare module BABYLON {
  52986. /**
  52987. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52988. */
  52989. export enum NodeMaterialBlockConnectionPointMode {
  52990. /** Value is an uniform */
  52991. Uniform = 0,
  52992. /** Value is a mesh attribute */
  52993. Attribute = 1,
  52994. /** Value is a varying between vertex and fragment shaders */
  52995. Varying = 2,
  52996. /** Mode is undefined */
  52997. Undefined = 3
  52998. }
  52999. }
  53000. declare module BABYLON {
  53001. /**
  53002. * Enum defining the type of animations supported by InputBlock
  53003. */
  53004. export enum AnimatedInputBlockTypes {
  53005. /** No animation */
  53006. None = 0,
  53007. /** Time based animation. Will only work for floats */
  53008. Time = 1
  53009. }
  53010. }
  53011. declare module BABYLON {
  53012. /**
  53013. * Block used to expose an input value
  53014. */
  53015. export class InputBlock extends NodeMaterialBlock {
  53016. private _mode;
  53017. private _associatedVariableName;
  53018. private _storedValue;
  53019. private _valueCallback;
  53020. private _type;
  53021. private _animationType;
  53022. /** @hidden */
  53023. _systemValue: Nullable<NodeMaterialSystemValues>;
  53024. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53025. visibleInInspector: boolean;
  53026. /**
  53027. * Gets or sets the connection point type (default is float)
  53028. */
  53029. readonly type: NodeMaterialBlockConnectionPointTypes;
  53030. /**
  53031. * Creates a new InputBlock
  53032. * @param name defines the block name
  53033. * @param target defines the target of that block (Vertex by default)
  53034. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53035. */
  53036. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53037. /**
  53038. * Gets the output component
  53039. */
  53040. readonly output: NodeMaterialConnectionPoint;
  53041. /**
  53042. * Set the source of this connection point to a vertex attribute
  53043. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53044. * @returns the current connection point
  53045. */
  53046. setAsAttribute(attributeName?: string): InputBlock;
  53047. /**
  53048. * Set the source of this connection point to a system value
  53049. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53050. * @returns the current connection point
  53051. */
  53052. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53053. /**
  53054. * Gets or sets the value of that point.
  53055. * Please note that this value will be ignored if valueCallback is defined
  53056. */
  53057. value: any;
  53058. /**
  53059. * Gets or sets a callback used to get the value of that point.
  53060. * Please note that setting this value will force the connection point to ignore the value property
  53061. */
  53062. valueCallback: () => any;
  53063. /**
  53064. * Gets or sets the associated variable name in the shader
  53065. */
  53066. associatedVariableName: string;
  53067. /** Gets or sets the type of animation applied to the input */
  53068. animationType: AnimatedInputBlockTypes;
  53069. /**
  53070. * Gets a boolean indicating that this connection point not defined yet
  53071. */
  53072. readonly isUndefined: boolean;
  53073. /**
  53074. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53075. * In this case the connection point name must be the name of the uniform to use.
  53076. * Can only be set on inputs
  53077. */
  53078. isUniform: boolean;
  53079. /**
  53080. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53081. * In this case the connection point name must be the name of the attribute to use
  53082. * Can only be set on inputs
  53083. */
  53084. isAttribute: boolean;
  53085. /**
  53086. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53087. * Can only be set on exit points
  53088. */
  53089. isVarying: boolean;
  53090. /**
  53091. * Gets a boolean indicating that the current connection point is a system value
  53092. */
  53093. readonly isSystemValue: boolean;
  53094. /**
  53095. * Gets or sets the current well known value or null if not defined as a system value
  53096. */
  53097. systemValue: Nullable<NodeMaterialSystemValues>;
  53098. /**
  53099. * Gets the current class name
  53100. * @returns the class name
  53101. */
  53102. getClassName(): string;
  53103. /**
  53104. * Animate the input if animationType !== None
  53105. * @param scene defines the rendering scene
  53106. */
  53107. animate(scene: Scene): void;
  53108. private _emitDefine;
  53109. /**
  53110. * Set the input block to its default value (based on its type)
  53111. */
  53112. setDefaultValue(): void;
  53113. protected _dumpPropertiesCode(): string;
  53114. private _emit;
  53115. /** @hidden */
  53116. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53117. /** @hidden */
  53118. _transmit(effect: Effect, scene: Scene): void;
  53119. protected _buildBlock(state: NodeMaterialBuildState): void;
  53120. serialize(): any;
  53121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53122. }
  53123. }
  53124. declare module BABYLON {
  53125. /**
  53126. * Defines a connection point for a block
  53127. */
  53128. export class NodeMaterialConnectionPoint {
  53129. /** @hidden */
  53130. _ownerBlock: NodeMaterialBlock;
  53131. /** @hidden */
  53132. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53133. private _endpoints;
  53134. private _associatedVariableName;
  53135. /** @hidden */
  53136. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53137. /** @hidden */
  53138. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53139. private _type;
  53140. /** @hidden */
  53141. _enforceAssociatedVariableName: boolean;
  53142. /**
  53143. * Gets or sets the additional types supported byt this connection point
  53144. */
  53145. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53146. /**
  53147. * Gets or sets the associated variable name in the shader
  53148. */
  53149. associatedVariableName: string;
  53150. /**
  53151. * Gets or sets the connection point type (default is float)
  53152. */
  53153. type: NodeMaterialBlockConnectionPointTypes;
  53154. /**
  53155. * Gets or sets the connection point name
  53156. */
  53157. name: string;
  53158. /**
  53159. * Gets or sets a boolean indicating that this connection point can be omitted
  53160. */
  53161. isOptional: boolean;
  53162. /**
  53163. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53164. */
  53165. define: string;
  53166. /** Gets or sets the target of that connection point */
  53167. target: NodeMaterialBlockTargets;
  53168. /**
  53169. * Gets a boolean indicating that the current point is connected
  53170. */
  53171. readonly isConnected: boolean;
  53172. /**
  53173. * Gets a boolean indicating that the current point is connected to an input block
  53174. */
  53175. readonly isConnectedToInputBlock: boolean;
  53176. /**
  53177. * Gets a the connected input block (if any)
  53178. */
  53179. readonly connectInputBlock: Nullable<InputBlock>;
  53180. /** Get the other side of the connection (if any) */
  53181. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53182. /** Get the block that owns this connection point */
  53183. readonly ownerBlock: NodeMaterialBlock;
  53184. /** Get the block connected on the other side of this connection (if any) */
  53185. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53186. /** Get the block connected on the endpoints of this connection (if any) */
  53187. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53188. /** Gets the list of connected endpoints */
  53189. readonly endpoints: NodeMaterialConnectionPoint[];
  53190. /** Gets a boolean indicating if that output point is connected to at least one input */
  53191. readonly hasEndpoints: boolean;
  53192. /**
  53193. * Creates a new connection point
  53194. * @param name defines the connection point name
  53195. * @param ownerBlock defines the block hosting this connection point
  53196. */
  53197. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53198. /**
  53199. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53200. * @returns the class name
  53201. */
  53202. getClassName(): string;
  53203. /**
  53204. * Gets an boolean indicating if the current point can be connected to another point
  53205. * @param connectionPoint defines the other connection point
  53206. * @returns true if the connection is possible
  53207. */
  53208. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53209. /**
  53210. * Connect this point to another connection point
  53211. * @param connectionPoint defines the other connection point
  53212. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53213. * @returns the current connection point
  53214. */
  53215. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53216. /**
  53217. * Disconnect this point from one of his endpoint
  53218. * @param endpoint defines the other connection point
  53219. * @returns the current connection point
  53220. */
  53221. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53222. /**
  53223. * Serializes this point in a JSON representation
  53224. * @returns the serialized point object
  53225. */
  53226. serialize(): any;
  53227. }
  53228. }
  53229. declare module BABYLON {
  53230. /**
  53231. * Block used to add support for vertex skinning (bones)
  53232. */
  53233. export class BonesBlock extends NodeMaterialBlock {
  53234. /**
  53235. * Creates a new BonesBlock
  53236. * @param name defines the block name
  53237. */
  53238. constructor(name: string);
  53239. /**
  53240. * Initialize the block and prepare the context for build
  53241. * @param state defines the state that will be used for the build
  53242. */
  53243. initialize(state: NodeMaterialBuildState): void;
  53244. /**
  53245. * Gets the current class name
  53246. * @returns the class name
  53247. */
  53248. getClassName(): string;
  53249. /**
  53250. * Gets the matrix indices input component
  53251. */
  53252. readonly matricesIndices: NodeMaterialConnectionPoint;
  53253. /**
  53254. * Gets the matrix weights input component
  53255. */
  53256. readonly matricesWeights: NodeMaterialConnectionPoint;
  53257. /**
  53258. * Gets the extra matrix indices input component
  53259. */
  53260. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53261. /**
  53262. * Gets the extra matrix weights input component
  53263. */
  53264. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53265. /**
  53266. * Gets the world input component
  53267. */
  53268. readonly world: NodeMaterialConnectionPoint;
  53269. /**
  53270. * Gets the output component
  53271. */
  53272. readonly output: NodeMaterialConnectionPoint;
  53273. autoConfigure(material: NodeMaterial): void;
  53274. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53276. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53277. protected _buildBlock(state: NodeMaterialBuildState): this;
  53278. }
  53279. }
  53280. declare module BABYLON {
  53281. /**
  53282. * Block used to add support for instances
  53283. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53284. */
  53285. export class InstancesBlock extends NodeMaterialBlock {
  53286. /**
  53287. * Creates a new InstancesBlock
  53288. * @param name defines the block name
  53289. */
  53290. constructor(name: string);
  53291. /**
  53292. * Gets the current class name
  53293. * @returns the class name
  53294. */
  53295. getClassName(): string;
  53296. /**
  53297. * Gets the first world row input component
  53298. */
  53299. readonly world0: NodeMaterialConnectionPoint;
  53300. /**
  53301. * Gets the second world row input component
  53302. */
  53303. readonly world1: NodeMaterialConnectionPoint;
  53304. /**
  53305. * Gets the third world row input component
  53306. */
  53307. readonly world2: NodeMaterialConnectionPoint;
  53308. /**
  53309. * Gets the forth world row input component
  53310. */
  53311. readonly world3: NodeMaterialConnectionPoint;
  53312. /**
  53313. * Gets the world input component
  53314. */
  53315. readonly world: NodeMaterialConnectionPoint;
  53316. /**
  53317. * Gets the output component
  53318. */
  53319. readonly output: NodeMaterialConnectionPoint;
  53320. autoConfigure(material: NodeMaterial): void;
  53321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53322. protected _buildBlock(state: NodeMaterialBuildState): this;
  53323. }
  53324. }
  53325. declare module BABYLON {
  53326. /**
  53327. * Block used to add morph targets support to vertex shader
  53328. */
  53329. export class MorphTargetsBlock extends NodeMaterialBlock {
  53330. private _repeatableContentAnchor;
  53331. private _repeatebleContentGenerated;
  53332. /**
  53333. * Create a new MorphTargetsBlock
  53334. * @param name defines the block name
  53335. */
  53336. constructor(name: string);
  53337. /**
  53338. * Gets the current class name
  53339. * @returns the class name
  53340. */
  53341. getClassName(): string;
  53342. /**
  53343. * Gets the position input component
  53344. */
  53345. readonly position: NodeMaterialConnectionPoint;
  53346. /**
  53347. * Gets the normal input component
  53348. */
  53349. readonly normal: NodeMaterialConnectionPoint;
  53350. /**
  53351. * Gets the tangent input component
  53352. */
  53353. readonly tangent: NodeMaterialConnectionPoint;
  53354. /**
  53355. * Gets the tangent input component
  53356. */
  53357. readonly uv: NodeMaterialConnectionPoint;
  53358. /**
  53359. * Gets the position output component
  53360. */
  53361. readonly positionOutput: NodeMaterialConnectionPoint;
  53362. /**
  53363. * Gets the normal output component
  53364. */
  53365. readonly normalOutput: NodeMaterialConnectionPoint;
  53366. /**
  53367. * Gets the tangent output component
  53368. */
  53369. readonly tangentOutput: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the tangent output component
  53372. */
  53373. readonly uvOutput: NodeMaterialConnectionPoint;
  53374. initialize(state: NodeMaterialBuildState): void;
  53375. autoConfigure(material: NodeMaterial): void;
  53376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53378. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53379. protected _buildBlock(state: NodeMaterialBuildState): this;
  53380. }
  53381. }
  53382. declare module BABYLON {
  53383. /**
  53384. * Block used to get data information from a light
  53385. */
  53386. export class LightInformationBlock extends NodeMaterialBlock {
  53387. private _lightDataDefineName;
  53388. private _lightColorDefineName;
  53389. /**
  53390. * Gets or sets the light associated with this block
  53391. */
  53392. light: Nullable<Light>;
  53393. /**
  53394. * Creates a new LightInformationBlock
  53395. * @param name defines the block name
  53396. */
  53397. constructor(name: string);
  53398. /**
  53399. * Gets the current class name
  53400. * @returns the class name
  53401. */
  53402. getClassName(): string;
  53403. /**
  53404. * Gets the world position input component
  53405. */
  53406. readonly worldPosition: NodeMaterialConnectionPoint;
  53407. /**
  53408. * Gets the direction output component
  53409. */
  53410. readonly direction: NodeMaterialConnectionPoint;
  53411. /**
  53412. * Gets the direction output component
  53413. */
  53414. readonly color: NodeMaterialConnectionPoint;
  53415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53416. protected _buildBlock(state: NodeMaterialBuildState): this;
  53417. serialize(): any;
  53418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53419. }
  53420. }
  53421. declare module BABYLON {
  53422. /**
  53423. * Block used to add an alpha test in the fragment shader
  53424. */
  53425. export class AlphaTestBlock extends NodeMaterialBlock {
  53426. /**
  53427. * Gets or sets the alpha value where alpha testing happens
  53428. */
  53429. alphaCutOff: number;
  53430. /**
  53431. * Create a new AlphaTestBlock
  53432. * @param name defines the block name
  53433. */
  53434. constructor(name: string);
  53435. /**
  53436. * Gets the current class name
  53437. * @returns the class name
  53438. */
  53439. getClassName(): string;
  53440. /**
  53441. * Gets the color input component
  53442. */
  53443. readonly color: NodeMaterialConnectionPoint;
  53444. /**
  53445. * Gets the alpha input component
  53446. */
  53447. readonly alpha: NodeMaterialConnectionPoint;
  53448. protected _buildBlock(state: NodeMaterialBuildState): this;
  53449. protected _dumpPropertiesCode(): string;
  53450. serialize(): any;
  53451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53452. }
  53453. }
  53454. declare module BABYLON {
  53455. /**
  53456. * Block used to add image processing support to fragment shader
  53457. */
  53458. export class ImageProcessingBlock extends NodeMaterialBlock {
  53459. /**
  53460. * Create a new ImageProcessingBlock
  53461. * @param name defines the block name
  53462. */
  53463. constructor(name: string);
  53464. /**
  53465. * Gets the current class name
  53466. * @returns the class name
  53467. */
  53468. getClassName(): string;
  53469. /**
  53470. * Gets the color input component
  53471. */
  53472. readonly color: NodeMaterialConnectionPoint;
  53473. /**
  53474. * Gets the output component
  53475. */
  53476. readonly output: NodeMaterialConnectionPoint;
  53477. /**
  53478. * Initialize the block and prepare the context for build
  53479. * @param state defines the state that will be used for the build
  53480. */
  53481. initialize(state: NodeMaterialBuildState): void;
  53482. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53485. protected _buildBlock(state: NodeMaterialBuildState): this;
  53486. }
  53487. }
  53488. declare module BABYLON {
  53489. /**
  53490. * Block used to add support for scene fog
  53491. */
  53492. export class FogBlock extends NodeMaterialBlock {
  53493. private _fogDistanceName;
  53494. private _fogParameters;
  53495. /**
  53496. * Create a new FogBlock
  53497. * @param name defines the block name
  53498. */
  53499. constructor(name: string);
  53500. /**
  53501. * Gets the current class name
  53502. * @returns the class name
  53503. */
  53504. getClassName(): string;
  53505. /**
  53506. * Gets the world position input component
  53507. */
  53508. readonly worldPosition: NodeMaterialConnectionPoint;
  53509. /**
  53510. * Gets the view input component
  53511. */
  53512. readonly view: NodeMaterialConnectionPoint;
  53513. /**
  53514. * Gets the color input component
  53515. */
  53516. readonly input: NodeMaterialConnectionPoint;
  53517. /**
  53518. * Gets the fog color input component
  53519. */
  53520. readonly fogColor: NodeMaterialConnectionPoint;
  53521. /**
  53522. * Gets the output component
  53523. */
  53524. readonly output: NodeMaterialConnectionPoint;
  53525. autoConfigure(material: NodeMaterial): void;
  53526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53528. protected _buildBlock(state: NodeMaterialBuildState): this;
  53529. }
  53530. }
  53531. declare module BABYLON {
  53532. /**
  53533. * Block used to add light in the fragment shader
  53534. */
  53535. export class LightBlock extends NodeMaterialBlock {
  53536. private _lightId;
  53537. /**
  53538. * Gets or sets the light associated with this block
  53539. */
  53540. light: Nullable<Light>;
  53541. /**
  53542. * Create a new LightBlock
  53543. * @param name defines the block name
  53544. */
  53545. constructor(name: string);
  53546. /**
  53547. * Gets the current class name
  53548. * @returns the class name
  53549. */
  53550. getClassName(): string;
  53551. /**
  53552. * Gets the world position input component
  53553. */
  53554. readonly worldPosition: NodeMaterialConnectionPoint;
  53555. /**
  53556. * Gets the world normal input component
  53557. */
  53558. readonly worldNormal: NodeMaterialConnectionPoint;
  53559. /**
  53560. * Gets the camera (or eye) position component
  53561. */
  53562. readonly cameraPosition: NodeMaterialConnectionPoint;
  53563. /**
  53564. * Gets the diffuse output component
  53565. */
  53566. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53567. /**
  53568. * Gets the specular output component
  53569. */
  53570. readonly specularOutput: NodeMaterialConnectionPoint;
  53571. autoConfigure(material: NodeMaterial): void;
  53572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53573. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53575. private _injectVertexCode;
  53576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53577. serialize(): any;
  53578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53579. }
  53580. }
  53581. declare module BABYLON {
  53582. /**
  53583. * Block used to multiply 2 values
  53584. */
  53585. export class MultiplyBlock extends NodeMaterialBlock {
  53586. /**
  53587. * Creates a new MultiplyBlock
  53588. * @param name defines the block name
  53589. */
  53590. constructor(name: string);
  53591. /**
  53592. * Gets the current class name
  53593. * @returns the class name
  53594. */
  53595. getClassName(): string;
  53596. /**
  53597. * Gets the left operand input component
  53598. */
  53599. readonly left: NodeMaterialConnectionPoint;
  53600. /**
  53601. * Gets the right operand input component
  53602. */
  53603. readonly right: NodeMaterialConnectionPoint;
  53604. /**
  53605. * Gets the output component
  53606. */
  53607. readonly output: NodeMaterialConnectionPoint;
  53608. protected _buildBlock(state: NodeMaterialBuildState): this;
  53609. }
  53610. }
  53611. declare module BABYLON {
  53612. /**
  53613. * Block used to add 2 vectors
  53614. */
  53615. export class AddBlock extends NodeMaterialBlock {
  53616. /**
  53617. * Creates a new AddBlock
  53618. * @param name defines the block name
  53619. */
  53620. constructor(name: string);
  53621. /**
  53622. * Gets the current class name
  53623. * @returns the class name
  53624. */
  53625. getClassName(): string;
  53626. /**
  53627. * Gets the left operand input component
  53628. */
  53629. readonly left: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the right operand input component
  53632. */
  53633. readonly right: NodeMaterialConnectionPoint;
  53634. /**
  53635. * Gets the output component
  53636. */
  53637. readonly output: NodeMaterialConnectionPoint;
  53638. protected _buildBlock(state: NodeMaterialBuildState): this;
  53639. }
  53640. }
  53641. declare module BABYLON {
  53642. /**
  53643. * Block used to scale a vector by a float
  53644. */
  53645. export class ScaleBlock extends NodeMaterialBlock {
  53646. /**
  53647. * Creates a new ScaleBlock
  53648. * @param name defines the block name
  53649. */
  53650. constructor(name: string);
  53651. /**
  53652. * Gets the current class name
  53653. * @returns the class name
  53654. */
  53655. getClassName(): string;
  53656. /**
  53657. * Gets the input component
  53658. */
  53659. readonly input: NodeMaterialConnectionPoint;
  53660. /**
  53661. * Gets the factor input component
  53662. */
  53663. readonly factor: NodeMaterialConnectionPoint;
  53664. /**
  53665. * Gets the output component
  53666. */
  53667. readonly output: NodeMaterialConnectionPoint;
  53668. protected _buildBlock(state: NodeMaterialBuildState): this;
  53669. }
  53670. }
  53671. declare module BABYLON {
  53672. /**
  53673. * Block used to clamp a float
  53674. */
  53675. export class ClampBlock extends NodeMaterialBlock {
  53676. /** Gets or sets the minimum range */
  53677. minimum: number;
  53678. /** Gets or sets the maximum range */
  53679. maximum: number;
  53680. /**
  53681. * Creates a new ClampBlock
  53682. * @param name defines the block name
  53683. */
  53684. constructor(name: string);
  53685. /**
  53686. * Gets the current class name
  53687. * @returns the class name
  53688. */
  53689. getClassName(): string;
  53690. /**
  53691. * Gets the value input component
  53692. */
  53693. readonly value: NodeMaterialConnectionPoint;
  53694. /**
  53695. * Gets the output component
  53696. */
  53697. readonly output: NodeMaterialConnectionPoint;
  53698. protected _buildBlock(state: NodeMaterialBuildState): this;
  53699. protected _dumpPropertiesCode(): string;
  53700. serialize(): any;
  53701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /**
  53706. * Block used to apply a cross product between 2 vectors
  53707. */
  53708. export class CrossBlock extends NodeMaterialBlock {
  53709. /**
  53710. * Creates a new CrossBlock
  53711. * @param name defines the block name
  53712. */
  53713. constructor(name: string);
  53714. /**
  53715. * Gets the current class name
  53716. * @returns the class name
  53717. */
  53718. getClassName(): string;
  53719. /**
  53720. * Gets the left operand input component
  53721. */
  53722. readonly left: NodeMaterialConnectionPoint;
  53723. /**
  53724. * Gets the right operand input component
  53725. */
  53726. readonly right: NodeMaterialConnectionPoint;
  53727. /**
  53728. * Gets the output component
  53729. */
  53730. readonly output: NodeMaterialConnectionPoint;
  53731. protected _buildBlock(state: NodeMaterialBuildState): this;
  53732. }
  53733. }
  53734. declare module BABYLON {
  53735. /**
  53736. * Block used to apply a dot product between 2 vectors
  53737. */
  53738. export class DotBlock extends NodeMaterialBlock {
  53739. /**
  53740. * Creates a new DotBlock
  53741. * @param name defines the block name
  53742. */
  53743. constructor(name: string);
  53744. /**
  53745. * Gets the current class name
  53746. * @returns the class name
  53747. */
  53748. getClassName(): string;
  53749. /**
  53750. * Gets the left operand input component
  53751. */
  53752. readonly left: NodeMaterialConnectionPoint;
  53753. /**
  53754. * Gets the right operand input component
  53755. */
  53756. readonly right: NodeMaterialConnectionPoint;
  53757. /**
  53758. * Gets the output component
  53759. */
  53760. readonly output: NodeMaterialConnectionPoint;
  53761. protected _buildBlock(state: NodeMaterialBuildState): this;
  53762. }
  53763. }
  53764. declare module BABYLON {
  53765. /**
  53766. * Block used to remap a float from a range to a new one
  53767. */
  53768. export class RemapBlock extends NodeMaterialBlock {
  53769. /**
  53770. * Gets or sets the source range
  53771. */
  53772. sourceRange: Vector2;
  53773. /**
  53774. * Gets or sets the target range
  53775. */
  53776. targetRange: Vector2;
  53777. /**
  53778. * Creates a new RemapBlock
  53779. * @param name defines the block name
  53780. */
  53781. constructor(name: string);
  53782. /**
  53783. * Gets the current class name
  53784. * @returns the class name
  53785. */
  53786. getClassName(): string;
  53787. /**
  53788. * Gets the input component
  53789. */
  53790. readonly input: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the output component
  53793. */
  53794. readonly output: NodeMaterialConnectionPoint;
  53795. protected _buildBlock(state: NodeMaterialBuildState): this;
  53796. protected _dumpPropertiesCode(): string;
  53797. serialize(): any;
  53798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53799. }
  53800. }
  53801. declare module BABYLON {
  53802. /**
  53803. * Block used to normalize a vector
  53804. */
  53805. export class NormalizeBlock extends NodeMaterialBlock {
  53806. /**
  53807. * Creates a new NormalizeBlock
  53808. * @param name defines the block name
  53809. */
  53810. constructor(name: string);
  53811. /**
  53812. * Gets the current class name
  53813. * @returns the class name
  53814. */
  53815. getClassName(): string;
  53816. /**
  53817. * Gets the input component
  53818. */
  53819. readonly input: NodeMaterialConnectionPoint;
  53820. /**
  53821. * Gets the output component
  53822. */
  53823. readonly output: NodeMaterialConnectionPoint;
  53824. protected _buildBlock(state: NodeMaterialBuildState): this;
  53825. }
  53826. }
  53827. declare module BABYLON {
  53828. /**
  53829. * Operations supported by the Trigonometry block
  53830. */
  53831. export enum TrigonometryBlockOperations {
  53832. /** Cos */
  53833. Cos = 0,
  53834. /** Sin */
  53835. Sin = 1,
  53836. /** Abs */
  53837. Abs = 2,
  53838. /** Exp */
  53839. Exp = 3,
  53840. /** Exp2 */
  53841. Exp2 = 4,
  53842. /** Round */
  53843. Round = 5,
  53844. /** Floor */
  53845. Floor = 6,
  53846. /** Ceiling */
  53847. Ceiling = 7
  53848. }
  53849. /**
  53850. * Block used to apply trigonometry operation to floats
  53851. */
  53852. export class TrigonometryBlock extends NodeMaterialBlock {
  53853. /**
  53854. * Gets or sets the operation applied by the block
  53855. */
  53856. operation: TrigonometryBlockOperations;
  53857. /**
  53858. * Creates a new TrigonometryBlock
  53859. * @param name defines the block name
  53860. */
  53861. constructor(name: string);
  53862. /**
  53863. * Gets the current class name
  53864. * @returns the class name
  53865. */
  53866. getClassName(): string;
  53867. /**
  53868. * Gets the input component
  53869. */
  53870. readonly input: NodeMaterialConnectionPoint;
  53871. /**
  53872. * Gets the output component
  53873. */
  53874. readonly output: NodeMaterialConnectionPoint;
  53875. protected _buildBlock(state: NodeMaterialBuildState): this;
  53876. serialize(): any;
  53877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53878. }
  53879. }
  53880. declare module BABYLON {
  53881. /**
  53882. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53883. */
  53884. export class ColorMergerBlock extends NodeMaterialBlock {
  53885. /**
  53886. * Create a new ColorMergerBlock
  53887. * @param name defines the block name
  53888. */
  53889. constructor(name: string);
  53890. /**
  53891. * Gets the current class name
  53892. * @returns the class name
  53893. */
  53894. getClassName(): string;
  53895. /**
  53896. * Gets the r component (input)
  53897. */
  53898. readonly r: NodeMaterialConnectionPoint;
  53899. /**
  53900. * Gets the g component (input)
  53901. */
  53902. readonly g: NodeMaterialConnectionPoint;
  53903. /**
  53904. * Gets the b component (input)
  53905. */
  53906. readonly b: NodeMaterialConnectionPoint;
  53907. /**
  53908. * Gets the a component (input)
  53909. */
  53910. readonly a: NodeMaterialConnectionPoint;
  53911. /**
  53912. * Gets the rgba component (output)
  53913. */
  53914. readonly rgba: NodeMaterialConnectionPoint;
  53915. /**
  53916. * Gets the rgb component (output)
  53917. */
  53918. readonly rgb: NodeMaterialConnectionPoint;
  53919. protected _buildBlock(state: NodeMaterialBuildState): this;
  53920. }
  53921. }
  53922. declare module BABYLON {
  53923. /**
  53924. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53925. */
  53926. export class VectorMergerBlock extends NodeMaterialBlock {
  53927. /**
  53928. * Create a new VectorMergerBlock
  53929. * @param name defines the block name
  53930. */
  53931. constructor(name: string);
  53932. /**
  53933. * Gets the current class name
  53934. * @returns the class name
  53935. */
  53936. getClassName(): string;
  53937. /**
  53938. * Gets the x component (input)
  53939. */
  53940. readonly x: NodeMaterialConnectionPoint;
  53941. /**
  53942. * Gets the y component (input)
  53943. */
  53944. readonly y: NodeMaterialConnectionPoint;
  53945. /**
  53946. * Gets the z component (input)
  53947. */
  53948. readonly z: NodeMaterialConnectionPoint;
  53949. /**
  53950. * Gets the w component (input)
  53951. */
  53952. readonly w: NodeMaterialConnectionPoint;
  53953. /**
  53954. * Gets the xyzw component (output)
  53955. */
  53956. readonly xyzw: NodeMaterialConnectionPoint;
  53957. /**
  53958. * Gets the xyz component (output)
  53959. */
  53960. readonly xyz: NodeMaterialConnectionPoint;
  53961. /**
  53962. * Gets the xy component (output)
  53963. */
  53964. readonly xy: NodeMaterialConnectionPoint;
  53965. protected _buildBlock(state: NodeMaterialBuildState): this;
  53966. }
  53967. }
  53968. declare module BABYLON {
  53969. /**
  53970. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53971. */
  53972. export class ColorSplitterBlock extends NodeMaterialBlock {
  53973. /**
  53974. * Create a new ColorSplitterBlock
  53975. * @param name defines the block name
  53976. */
  53977. constructor(name: string);
  53978. /**
  53979. * Gets the current class name
  53980. * @returns the class name
  53981. */
  53982. getClassName(): string;
  53983. /**
  53984. * Gets the rgba component (input)
  53985. */
  53986. readonly rgba: NodeMaterialConnectionPoint;
  53987. /**
  53988. * Gets the rgb component (input)
  53989. */
  53990. readonly rgbIn: NodeMaterialConnectionPoint;
  53991. /**
  53992. * Gets the rgb component (output)
  53993. */
  53994. readonly rgbOut: NodeMaterialConnectionPoint;
  53995. /**
  53996. * Gets the r component (output)
  53997. */
  53998. readonly r: NodeMaterialConnectionPoint;
  53999. /**
  54000. * Gets the g component (output)
  54001. */
  54002. readonly g: NodeMaterialConnectionPoint;
  54003. /**
  54004. * Gets the b component (output)
  54005. */
  54006. readonly b: NodeMaterialConnectionPoint;
  54007. /**
  54008. * Gets the a component (output)
  54009. */
  54010. readonly a: NodeMaterialConnectionPoint;
  54011. protected _inputRename(name: string): string;
  54012. protected _outputRename(name: string): string;
  54013. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54014. }
  54015. }
  54016. declare module BABYLON {
  54017. /**
  54018. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54019. */
  54020. export class VectorSplitterBlock extends NodeMaterialBlock {
  54021. /**
  54022. * Create a new VectorSplitterBlock
  54023. * @param name defines the block name
  54024. */
  54025. constructor(name: string);
  54026. /**
  54027. * Gets the current class name
  54028. * @returns the class name
  54029. */
  54030. getClassName(): string;
  54031. /**
  54032. * Gets the xyzw component (input)
  54033. */
  54034. readonly xyzw: NodeMaterialConnectionPoint;
  54035. /**
  54036. * Gets the xyz component (input)
  54037. */
  54038. readonly xyzIn: NodeMaterialConnectionPoint;
  54039. /**
  54040. * Gets the xy component (input)
  54041. */
  54042. readonly xyIn: NodeMaterialConnectionPoint;
  54043. /**
  54044. * Gets the xyz component (output)
  54045. */
  54046. readonly xyzOut: NodeMaterialConnectionPoint;
  54047. /**
  54048. * Gets the xy component (output)
  54049. */
  54050. readonly xyOut: NodeMaterialConnectionPoint;
  54051. /**
  54052. * Gets the x component (output)
  54053. */
  54054. readonly x: NodeMaterialConnectionPoint;
  54055. /**
  54056. * Gets the y component (output)
  54057. */
  54058. readonly y: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the z component (output)
  54061. */
  54062. readonly z: NodeMaterialConnectionPoint;
  54063. /**
  54064. * Gets the w component (output)
  54065. */
  54066. readonly w: NodeMaterialConnectionPoint;
  54067. protected _inputRename(name: string): string;
  54068. protected _outputRename(name: string): string;
  54069. protected _buildBlock(state: NodeMaterialBuildState): this;
  54070. }
  54071. }
  54072. declare module BABYLON {
  54073. /**
  54074. * Block used to lerp 2 values
  54075. */
  54076. export class LerpBlock extends NodeMaterialBlock {
  54077. /**
  54078. * Creates a new LerpBlock
  54079. * @param name defines the block name
  54080. */
  54081. constructor(name: string);
  54082. /**
  54083. * Gets the current class name
  54084. * @returns the class name
  54085. */
  54086. getClassName(): string;
  54087. /**
  54088. * Gets the left operand input component
  54089. */
  54090. readonly left: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the right operand input component
  54093. */
  54094. readonly right: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the gradient operand input component
  54097. */
  54098. readonly gradient: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the output component
  54101. */
  54102. readonly output: NodeMaterialConnectionPoint;
  54103. protected _buildBlock(state: NodeMaterialBuildState): this;
  54104. }
  54105. }
  54106. declare module BABYLON {
  54107. /**
  54108. * Block used to divide 2 vectors
  54109. */
  54110. export class DivideBlock extends NodeMaterialBlock {
  54111. /**
  54112. * Creates a new DivideBlock
  54113. * @param name defines the block name
  54114. */
  54115. constructor(name: string);
  54116. /**
  54117. * Gets the current class name
  54118. * @returns the class name
  54119. */
  54120. getClassName(): string;
  54121. /**
  54122. * Gets the left operand input component
  54123. */
  54124. readonly left: NodeMaterialConnectionPoint;
  54125. /**
  54126. * Gets the right operand input component
  54127. */
  54128. readonly right: NodeMaterialConnectionPoint;
  54129. /**
  54130. * Gets the output component
  54131. */
  54132. readonly output: NodeMaterialConnectionPoint;
  54133. protected _buildBlock(state: NodeMaterialBuildState): this;
  54134. }
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * Block used to subtract 2 vectors
  54139. */
  54140. export class SubtractBlock extends NodeMaterialBlock {
  54141. /**
  54142. * Creates a new SubtractBlock
  54143. * @param name defines the block name
  54144. */
  54145. constructor(name: string);
  54146. /**
  54147. * Gets the current class name
  54148. * @returns the class name
  54149. */
  54150. getClassName(): string;
  54151. /**
  54152. * Gets the left operand input component
  54153. */
  54154. readonly left: NodeMaterialConnectionPoint;
  54155. /**
  54156. * Gets the right operand input component
  54157. */
  54158. readonly right: NodeMaterialConnectionPoint;
  54159. /**
  54160. * Gets the output component
  54161. */
  54162. readonly output: NodeMaterialConnectionPoint;
  54163. protected _buildBlock(state: NodeMaterialBuildState): this;
  54164. }
  54165. }
  54166. declare module BABYLON {
  54167. /**
  54168. * Block used to step a value
  54169. */
  54170. export class StepBlock extends NodeMaterialBlock {
  54171. /**
  54172. * Creates a new AddBlock
  54173. * @param name defines the block name
  54174. */
  54175. constructor(name: string);
  54176. /**
  54177. * Gets the current class name
  54178. * @returns the class name
  54179. */
  54180. getClassName(): string;
  54181. /**
  54182. * Gets the value operand input component
  54183. */
  54184. readonly value: NodeMaterialConnectionPoint;
  54185. /**
  54186. * Gets the edge operand input component
  54187. */
  54188. readonly edge: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the output component
  54191. */
  54192. readonly output: NodeMaterialConnectionPoint;
  54193. protected _buildBlock(state: NodeMaterialBuildState): this;
  54194. }
  54195. }
  54196. declare module BABYLON {
  54197. /**
  54198. * Block used to get the opposite of a value
  54199. */
  54200. export class OppositeBlock extends NodeMaterialBlock {
  54201. /**
  54202. * Creates a new OppositeBlock
  54203. * @param name defines the block name
  54204. */
  54205. constructor(name: string);
  54206. /**
  54207. * Gets the current class name
  54208. * @returns the class name
  54209. */
  54210. getClassName(): string;
  54211. /**
  54212. * Gets the input component
  54213. */
  54214. readonly input: NodeMaterialConnectionPoint;
  54215. /**
  54216. * Gets the output component
  54217. */
  54218. readonly output: NodeMaterialConnectionPoint;
  54219. protected _buildBlock(state: NodeMaterialBuildState): this;
  54220. }
  54221. }
  54222. declare module BABYLON {
  54223. /**
  54224. * Block used to get the view direction
  54225. */
  54226. export class ViewDirectionBlock extends NodeMaterialBlock {
  54227. /**
  54228. * Creates a new ViewDirectionBlock
  54229. * @param name defines the block name
  54230. */
  54231. constructor(name: string);
  54232. /**
  54233. * Gets the current class name
  54234. * @returns the class name
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Gets the world position component
  54239. */
  54240. readonly worldPosition: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the camera position component
  54243. */
  54244. readonly cameraPosition: NodeMaterialConnectionPoint;
  54245. /**
  54246. * Gets the output component
  54247. */
  54248. readonly output: NodeMaterialConnectionPoint;
  54249. autoConfigure(material: NodeMaterial): void;
  54250. protected _buildBlock(state: NodeMaterialBuildState): this;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * Block used to compute fresnel value
  54256. */
  54257. export class FresnelBlock extends NodeMaterialBlock {
  54258. /**
  54259. * Create a new FresnelBlock
  54260. * @param name defines the block name
  54261. */
  54262. constructor(name: string);
  54263. /**
  54264. * Gets the current class name
  54265. * @returns the class name
  54266. */
  54267. getClassName(): string;
  54268. /**
  54269. * Gets the world normal input component
  54270. */
  54271. readonly worldNormal: NodeMaterialConnectionPoint;
  54272. /**
  54273. * Gets the view direction input component
  54274. */
  54275. readonly viewDirection: NodeMaterialConnectionPoint;
  54276. /**
  54277. * Gets the bias input component
  54278. */
  54279. readonly bias: NodeMaterialConnectionPoint;
  54280. /**
  54281. * Gets the camera (or eye) position component
  54282. */
  54283. readonly power: NodeMaterialConnectionPoint;
  54284. /**
  54285. * Gets the fresnel output component
  54286. */
  54287. readonly fresnel: NodeMaterialConnectionPoint;
  54288. autoConfigure(material: NodeMaterial): void;
  54289. protected _buildBlock(state: NodeMaterialBuildState): this;
  54290. }
  54291. }
  54292. declare module BABYLON {
  54293. /**
  54294. * Block used to get the max of 2 values
  54295. */
  54296. export class MaxBlock extends NodeMaterialBlock {
  54297. /**
  54298. * Creates a new MaxBlock
  54299. * @param name defines the block name
  54300. */
  54301. constructor(name: string);
  54302. /**
  54303. * Gets the current class name
  54304. * @returns the class name
  54305. */
  54306. getClassName(): string;
  54307. /**
  54308. * Gets the left operand input component
  54309. */
  54310. readonly left: NodeMaterialConnectionPoint;
  54311. /**
  54312. * Gets the right operand input component
  54313. */
  54314. readonly right: NodeMaterialConnectionPoint;
  54315. /**
  54316. * Gets the output component
  54317. */
  54318. readonly output: NodeMaterialConnectionPoint;
  54319. protected _buildBlock(state: NodeMaterialBuildState): this;
  54320. }
  54321. }
  54322. declare module BABYLON {
  54323. /**
  54324. * Block used to get the min of 2 values
  54325. */
  54326. export class MinBlock extends NodeMaterialBlock {
  54327. /**
  54328. * Creates a new MinBlock
  54329. * @param name defines the block name
  54330. */
  54331. constructor(name: string);
  54332. /**
  54333. * Gets the current class name
  54334. * @returns the class name
  54335. */
  54336. getClassName(): string;
  54337. /**
  54338. * Gets the left operand input component
  54339. */
  54340. readonly left: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the right operand input component
  54343. */
  54344. readonly right: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Gets the output component
  54347. */
  54348. readonly output: NodeMaterialConnectionPoint;
  54349. protected _buildBlock(state: NodeMaterialBuildState): this;
  54350. }
  54351. }
  54352. declare module BABYLON {
  54353. /**
  54354. * Effect Render Options
  54355. */
  54356. export interface IEffectRendererOptions {
  54357. /**
  54358. * Defines the vertices positions.
  54359. */
  54360. positions?: number[];
  54361. /**
  54362. * Defines the indices.
  54363. */
  54364. indices?: number[];
  54365. }
  54366. /**
  54367. * Helper class to render one or more effects
  54368. */
  54369. export class EffectRenderer {
  54370. private engine;
  54371. private static _DefaultOptions;
  54372. private _vertexBuffers;
  54373. private _indexBuffer;
  54374. private _ringBufferIndex;
  54375. private _ringScreenBuffer;
  54376. private _fullscreenViewport;
  54377. private _getNextFrameBuffer;
  54378. /**
  54379. * Creates an effect renderer
  54380. * @param engine the engine to use for rendering
  54381. * @param options defines the options of the effect renderer
  54382. */
  54383. constructor(engine: Engine, options?: IEffectRendererOptions);
  54384. /**
  54385. * Sets the current viewport in normalized coordinates 0-1
  54386. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54387. */
  54388. setViewport(viewport?: Viewport): void;
  54389. /**
  54390. * Binds the embedded attributes buffer to the effect.
  54391. * @param effect Defines the effect to bind the attributes for
  54392. */
  54393. bindBuffers(effect: Effect): void;
  54394. /**
  54395. * Sets the current effect wrapper to use during draw.
  54396. * The effect needs to be ready before calling this api.
  54397. * This also sets the default full screen position attribute.
  54398. * @param effectWrapper Defines the effect to draw with
  54399. */
  54400. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54401. /**
  54402. * Draws a full screen quad.
  54403. */
  54404. draw(): void;
  54405. /**
  54406. * renders one or more effects to a specified texture
  54407. * @param effectWrappers list of effects to renderer
  54408. * @param outputTexture texture to draw to, if null it will render to the screen
  54409. */
  54410. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54411. /**
  54412. * Disposes of the effect renderer
  54413. */
  54414. dispose(): void;
  54415. }
  54416. /**
  54417. * Options to create an EffectWrapper
  54418. */
  54419. interface EffectWrapperCreationOptions {
  54420. /**
  54421. * Engine to use to create the effect
  54422. */
  54423. engine: Engine;
  54424. /**
  54425. * Fragment shader for the effect
  54426. */
  54427. fragmentShader: string;
  54428. /**
  54429. * Vertex shader for the effect
  54430. */
  54431. vertexShader?: string;
  54432. /**
  54433. * Attributes to use in the shader
  54434. */
  54435. attributeNames?: Array<string>;
  54436. /**
  54437. * Uniforms to use in the shader
  54438. */
  54439. uniformNames?: Array<string>;
  54440. /**
  54441. * Texture sampler names to use in the shader
  54442. */
  54443. samplerNames?: Array<string>;
  54444. /**
  54445. * The friendly name of the effect displayed in Spector.
  54446. */
  54447. name?: string;
  54448. }
  54449. /**
  54450. * Wraps an effect to be used for rendering
  54451. */
  54452. export class EffectWrapper {
  54453. /**
  54454. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54455. */
  54456. onApplyObservable: Observable<{}>;
  54457. /**
  54458. * The underlying effect
  54459. */
  54460. effect: Effect;
  54461. /**
  54462. * Creates an effect to be renderer
  54463. * @param creationOptions options to create the effect
  54464. */
  54465. constructor(creationOptions: EffectWrapperCreationOptions);
  54466. /**
  54467. * Disposes of the effect wrapper
  54468. */
  54469. dispose(): void;
  54470. }
  54471. }
  54472. declare module BABYLON {
  54473. /**
  54474. * Helper class to push actions to a pool of workers.
  54475. */
  54476. export class WorkerPool implements IDisposable {
  54477. private _workerInfos;
  54478. private _pendingActions;
  54479. /**
  54480. * Constructor
  54481. * @param workers Array of workers to use for actions
  54482. */
  54483. constructor(workers: Array<Worker>);
  54484. /**
  54485. * Terminates all workers and clears any pending actions.
  54486. */
  54487. dispose(): void;
  54488. /**
  54489. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54490. * pended until a worker has completed its action.
  54491. * @param action The action to perform. Call onComplete when the action is complete.
  54492. */
  54493. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54494. private _execute;
  54495. }
  54496. }
  54497. declare module BABYLON {
  54498. /**
  54499. * Configuration for Draco compression
  54500. */
  54501. export interface IDracoCompressionConfiguration {
  54502. /**
  54503. * Configuration for the decoder.
  54504. */
  54505. decoder: {
  54506. /**
  54507. * The url to the WebAssembly module.
  54508. */
  54509. wasmUrl?: string;
  54510. /**
  54511. * The url to the WebAssembly binary.
  54512. */
  54513. wasmBinaryUrl?: string;
  54514. /**
  54515. * The url to the fallback JavaScript module.
  54516. */
  54517. fallbackUrl?: string;
  54518. };
  54519. }
  54520. /**
  54521. * Draco compression (https://google.github.io/draco/)
  54522. *
  54523. * This class wraps the Draco module.
  54524. *
  54525. * **Encoder**
  54526. *
  54527. * The encoder is not currently implemented.
  54528. *
  54529. * **Decoder**
  54530. *
  54531. * 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.
  54532. *
  54533. * To update the configuration, use the following code:
  54534. * ```javascript
  54535. * DracoCompression.Configuration = {
  54536. * decoder: {
  54537. * wasmUrl: "<url to the WebAssembly library>",
  54538. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54539. * fallbackUrl: "<url to the fallback JavaScript library>",
  54540. * }
  54541. * };
  54542. * ```
  54543. *
  54544. * 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.
  54545. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54546. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54547. *
  54548. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54549. * ```javascript
  54550. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54551. * ```
  54552. *
  54553. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54554. */
  54555. export class DracoCompression implements IDisposable {
  54556. private _workerPoolPromise?;
  54557. private _decoderModulePromise?;
  54558. /**
  54559. * The configuration. Defaults to the following urls:
  54560. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54561. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54562. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54563. */
  54564. static Configuration: IDracoCompressionConfiguration;
  54565. /**
  54566. * Returns true if the decoder configuration is available.
  54567. */
  54568. static readonly DecoderAvailable: boolean;
  54569. /**
  54570. * Default number of workers to create when creating the draco compression object.
  54571. */
  54572. static DefaultNumWorkers: number;
  54573. private static GetDefaultNumWorkers;
  54574. private static _Default;
  54575. /**
  54576. * Default instance for the draco compression object.
  54577. */
  54578. static readonly Default: DracoCompression;
  54579. /**
  54580. * Constructor
  54581. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54582. */
  54583. constructor(numWorkers?: number);
  54584. /**
  54585. * Stop all async operations and release resources.
  54586. */
  54587. dispose(): void;
  54588. /**
  54589. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54590. * @returns a promise that resolves when ready
  54591. */
  54592. whenReadyAsync(): Promise<void>;
  54593. /**
  54594. * Decode Draco compressed mesh data to vertex data.
  54595. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54596. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54597. * @returns A promise that resolves with the decoded vertex data
  54598. */
  54599. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54600. [kind: string]: number;
  54601. }): Promise<VertexData>;
  54602. }
  54603. }
  54604. declare module BABYLON {
  54605. /**
  54606. * Class for building Constructive Solid Geometry
  54607. */
  54608. export class CSG {
  54609. private polygons;
  54610. /**
  54611. * The world matrix
  54612. */
  54613. matrix: Matrix;
  54614. /**
  54615. * Stores the position
  54616. */
  54617. position: Vector3;
  54618. /**
  54619. * Stores the rotation
  54620. */
  54621. rotation: Vector3;
  54622. /**
  54623. * Stores the rotation quaternion
  54624. */
  54625. rotationQuaternion: Nullable<Quaternion>;
  54626. /**
  54627. * Stores the scaling vector
  54628. */
  54629. scaling: Vector3;
  54630. /**
  54631. * Convert the Mesh to CSG
  54632. * @param mesh The Mesh to convert to CSG
  54633. * @returns A new CSG from the Mesh
  54634. */
  54635. static FromMesh(mesh: Mesh): CSG;
  54636. /**
  54637. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54638. * @param polygons Polygons used to construct a CSG solid
  54639. */
  54640. private static FromPolygons;
  54641. /**
  54642. * Clones, or makes a deep copy, of the CSG
  54643. * @returns A new CSG
  54644. */
  54645. clone(): CSG;
  54646. /**
  54647. * Unions this CSG with another CSG
  54648. * @param csg The CSG to union against this CSG
  54649. * @returns The unioned CSG
  54650. */
  54651. union(csg: CSG): CSG;
  54652. /**
  54653. * Unions this CSG with another CSG in place
  54654. * @param csg The CSG to union against this CSG
  54655. */
  54656. unionInPlace(csg: CSG): void;
  54657. /**
  54658. * Subtracts this CSG with another CSG
  54659. * @param csg The CSG to subtract against this CSG
  54660. * @returns A new CSG
  54661. */
  54662. subtract(csg: CSG): CSG;
  54663. /**
  54664. * Subtracts this CSG with another CSG in place
  54665. * @param csg The CSG to subtact against this CSG
  54666. */
  54667. subtractInPlace(csg: CSG): void;
  54668. /**
  54669. * Intersect this CSG with another CSG
  54670. * @param csg The CSG to intersect against this CSG
  54671. * @returns A new CSG
  54672. */
  54673. intersect(csg: CSG): CSG;
  54674. /**
  54675. * Intersects this CSG with another CSG in place
  54676. * @param csg The CSG to intersect against this CSG
  54677. */
  54678. intersectInPlace(csg: CSG): void;
  54679. /**
  54680. * Return a new CSG solid with solid and empty space switched. This solid is
  54681. * not modified.
  54682. * @returns A new CSG solid with solid and empty space switched
  54683. */
  54684. inverse(): CSG;
  54685. /**
  54686. * Inverses the CSG in place
  54687. */
  54688. inverseInPlace(): void;
  54689. /**
  54690. * This is used to keep meshes transformations so they can be restored
  54691. * when we build back a Babylon Mesh
  54692. * NB : All CSG operations are performed in world coordinates
  54693. * @param csg The CSG to copy the transform attributes from
  54694. * @returns This CSG
  54695. */
  54696. copyTransformAttributes(csg: CSG): CSG;
  54697. /**
  54698. * Build Raw mesh from CSG
  54699. * Coordinates here are in world space
  54700. * @param name The name of the mesh geometry
  54701. * @param scene The Scene
  54702. * @param keepSubMeshes Specifies if the submeshes should be kept
  54703. * @returns A new Mesh
  54704. */
  54705. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54706. /**
  54707. * Build Mesh from CSG taking material and transforms into account
  54708. * @param name The name of the Mesh
  54709. * @param material The material of the Mesh
  54710. * @param scene The Scene
  54711. * @param keepSubMeshes Specifies if submeshes should be kept
  54712. * @returns The new Mesh
  54713. */
  54714. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54715. }
  54716. }
  54717. declare module BABYLON {
  54718. /**
  54719. * Class used to create a trail following a mesh
  54720. */
  54721. export class TrailMesh extends Mesh {
  54722. private _generator;
  54723. private _autoStart;
  54724. private _running;
  54725. private _diameter;
  54726. private _length;
  54727. private _sectionPolygonPointsCount;
  54728. private _sectionVectors;
  54729. private _sectionNormalVectors;
  54730. private _beforeRenderObserver;
  54731. /**
  54732. * @constructor
  54733. * @param name The value used by scene.getMeshByName() to do a lookup.
  54734. * @param generator The mesh to generate a trail.
  54735. * @param scene The scene to add this mesh to.
  54736. * @param diameter Diameter of trailing mesh. Default is 1.
  54737. * @param length Length of trailing mesh. Default is 60.
  54738. * @param autoStart Automatically start trailing mesh. Default true.
  54739. */
  54740. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54741. /**
  54742. * "TrailMesh"
  54743. * @returns "TrailMesh"
  54744. */
  54745. getClassName(): string;
  54746. private _createMesh;
  54747. /**
  54748. * Start trailing mesh.
  54749. */
  54750. start(): void;
  54751. /**
  54752. * Stop trailing mesh.
  54753. */
  54754. stop(): void;
  54755. /**
  54756. * Update trailing mesh geometry.
  54757. */
  54758. update(): void;
  54759. /**
  54760. * Returns a new TrailMesh object.
  54761. * @param name is a string, the name given to the new mesh
  54762. * @param newGenerator use new generator object for cloned trail mesh
  54763. * @returns a new mesh
  54764. */
  54765. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54766. /**
  54767. * Serializes this trail mesh
  54768. * @param serializationObject object to write serialization to
  54769. */
  54770. serialize(serializationObject: any): void;
  54771. /**
  54772. * Parses a serialized trail mesh
  54773. * @param parsedMesh the serialized mesh
  54774. * @param scene the scene to create the trail mesh in
  54775. * @returns the created trail mesh
  54776. */
  54777. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54778. }
  54779. }
  54780. declare module BABYLON {
  54781. /**
  54782. * Class containing static functions to help procedurally build meshes
  54783. */
  54784. export class TiledBoxBuilder {
  54785. /**
  54786. * Creates a box mesh
  54787. * 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)
  54788. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54790. * * 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
  54791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54792. * @param name defines the name of the mesh
  54793. * @param options defines the options used to create the mesh
  54794. * @param scene defines the hosting scene
  54795. * @returns the box mesh
  54796. */
  54797. static CreateTiledBox(name: string, options: {
  54798. pattern?: number;
  54799. width?: number;
  54800. height?: number;
  54801. depth?: number;
  54802. tileSize?: number;
  54803. tileWidth?: number;
  54804. tileHeight?: number;
  54805. alignHorizontal?: number;
  54806. alignVertical?: number;
  54807. faceUV?: Vector4[];
  54808. faceColors?: Color4[];
  54809. sideOrientation?: number;
  54810. updatable?: boolean;
  54811. }, scene?: Nullable<Scene>): Mesh;
  54812. }
  54813. }
  54814. declare module BABYLON {
  54815. /**
  54816. * Class containing static functions to help procedurally build meshes
  54817. */
  54818. export class TorusKnotBuilder {
  54819. /**
  54820. * Creates a torus knot mesh
  54821. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54822. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54823. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54824. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54826. * * 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
  54827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54828. * @param name defines the name of the mesh
  54829. * @param options defines the options used to create the mesh
  54830. * @param scene defines the hosting scene
  54831. * @returns the torus knot mesh
  54832. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54833. */
  54834. static CreateTorusKnot(name: string, options: {
  54835. radius?: number;
  54836. tube?: number;
  54837. radialSegments?: number;
  54838. tubularSegments?: number;
  54839. p?: number;
  54840. q?: number;
  54841. updatable?: boolean;
  54842. sideOrientation?: number;
  54843. frontUVs?: Vector4;
  54844. backUVs?: Vector4;
  54845. }, scene: any): Mesh;
  54846. }
  54847. }
  54848. declare module BABYLON {
  54849. /**
  54850. * Polygon
  54851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54852. */
  54853. export class Polygon {
  54854. /**
  54855. * Creates a rectangle
  54856. * @param xmin bottom X coord
  54857. * @param ymin bottom Y coord
  54858. * @param xmax top X coord
  54859. * @param ymax top Y coord
  54860. * @returns points that make the resulting rectation
  54861. */
  54862. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54863. /**
  54864. * Creates a circle
  54865. * @param radius radius of circle
  54866. * @param cx scale in x
  54867. * @param cy scale in y
  54868. * @param numberOfSides number of sides that make up the circle
  54869. * @returns points that make the resulting circle
  54870. */
  54871. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54872. /**
  54873. * Creates a polygon from input string
  54874. * @param input Input polygon data
  54875. * @returns the parsed points
  54876. */
  54877. static Parse(input: string): Vector2[];
  54878. /**
  54879. * Starts building a polygon from x and y coordinates
  54880. * @param x x coordinate
  54881. * @param y y coordinate
  54882. * @returns the started path2
  54883. */
  54884. static StartingAt(x: number, y: number): Path2;
  54885. }
  54886. /**
  54887. * Builds a polygon
  54888. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54889. */
  54890. export class PolygonMeshBuilder {
  54891. private _points;
  54892. private _outlinepoints;
  54893. private _holes;
  54894. private _name;
  54895. private _scene;
  54896. private _epoints;
  54897. private _eholes;
  54898. private _addToepoint;
  54899. /**
  54900. * Babylon reference to the earcut plugin.
  54901. */
  54902. bjsEarcut: any;
  54903. /**
  54904. * Creates a PolygonMeshBuilder
  54905. * @param name name of the builder
  54906. * @param contours Path of the polygon
  54907. * @param scene scene to add to when creating the mesh
  54908. * @param earcutInjection can be used to inject your own earcut reference
  54909. */
  54910. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54911. /**
  54912. * Adds a whole within the polygon
  54913. * @param hole Array of points defining the hole
  54914. * @returns this
  54915. */
  54916. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54917. /**
  54918. * Creates the polygon
  54919. * @param updatable If the mesh should be updatable
  54920. * @param depth The depth of the mesh created
  54921. * @returns the created mesh
  54922. */
  54923. build(updatable?: boolean, depth?: number): Mesh;
  54924. /**
  54925. * Creates the polygon
  54926. * @param depth The depth of the mesh created
  54927. * @returns the created VertexData
  54928. */
  54929. buildVertexData(depth?: number): VertexData;
  54930. /**
  54931. * Adds a side to the polygon
  54932. * @param positions points that make the polygon
  54933. * @param normals normals of the polygon
  54934. * @param uvs uvs of the polygon
  54935. * @param indices indices of the polygon
  54936. * @param bounds bounds of the polygon
  54937. * @param points points of the polygon
  54938. * @param depth depth of the polygon
  54939. * @param flip flip of the polygon
  54940. */
  54941. private addSide;
  54942. }
  54943. }
  54944. declare module BABYLON {
  54945. /**
  54946. * Class containing static functions to help procedurally build meshes
  54947. */
  54948. export class PolygonBuilder {
  54949. /**
  54950. * Creates a polygon mesh
  54951. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54952. * * 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
  54953. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54955. * * 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)
  54956. * * Remember you can only change the shape positions, not their number when updating a polygon
  54957. * @param name defines the name of the mesh
  54958. * @param options defines the options used to create the mesh
  54959. * @param scene defines the hosting scene
  54960. * @param earcutInjection can be used to inject your own earcut reference
  54961. * @returns the polygon mesh
  54962. */
  54963. static CreatePolygon(name: string, options: {
  54964. shape: Vector3[];
  54965. holes?: Vector3[][];
  54966. depth?: number;
  54967. faceUV?: Vector4[];
  54968. faceColors?: Color4[];
  54969. updatable?: boolean;
  54970. sideOrientation?: number;
  54971. frontUVs?: Vector4;
  54972. backUVs?: Vector4;
  54973. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54974. /**
  54975. * Creates an extruded polygon mesh, with depth in the Y direction.
  54976. * * 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)
  54977. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54978. * @param name defines the name of the mesh
  54979. * @param options defines the options used to create the mesh
  54980. * @param scene defines the hosting scene
  54981. * @param earcutInjection can be used to inject your own earcut reference
  54982. * @returns the polygon mesh
  54983. */
  54984. static ExtrudePolygon(name: string, options: {
  54985. shape: Vector3[];
  54986. holes?: Vector3[][];
  54987. depth?: number;
  54988. faceUV?: Vector4[];
  54989. faceColors?: Color4[];
  54990. updatable?: boolean;
  54991. sideOrientation?: number;
  54992. frontUVs?: Vector4;
  54993. backUVs?: Vector4;
  54994. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54995. }
  54996. }
  54997. declare module BABYLON {
  54998. /**
  54999. * Class containing static functions to help procedurally build meshes
  55000. */
  55001. export class LatheBuilder {
  55002. /**
  55003. * Creates lathe mesh.
  55004. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55005. * * 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
  55006. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55007. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55008. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55009. * * 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
  55010. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55011. * * 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
  55012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55013. * * 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
  55014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55016. * @param name defines the name of the mesh
  55017. * @param options defines the options used to create the mesh
  55018. * @param scene defines the hosting scene
  55019. * @returns the lathe mesh
  55020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55021. */
  55022. static CreateLathe(name: string, options: {
  55023. shape: Vector3[];
  55024. radius?: number;
  55025. tessellation?: number;
  55026. clip?: number;
  55027. arc?: number;
  55028. closed?: boolean;
  55029. updatable?: boolean;
  55030. sideOrientation?: number;
  55031. frontUVs?: Vector4;
  55032. backUVs?: Vector4;
  55033. cap?: number;
  55034. invertUV?: boolean;
  55035. }, scene?: Nullable<Scene>): Mesh;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /**
  55040. * Class containing static functions to help procedurally build meshes
  55041. */
  55042. export class TiledPlaneBuilder {
  55043. /**
  55044. * Creates a tiled plane mesh
  55045. * * The parameter `pattern` will, depending on value, do nothing or
  55046. * * * flip (reflect about central vertical) alternate tiles across and up
  55047. * * * flip every tile on alternate rows
  55048. * * * rotate (180 degs) alternate tiles across and up
  55049. * * * rotate every tile on alternate rows
  55050. * * * flip and rotate alternate tiles across and up
  55051. * * * flip and rotate every tile on alternate rows
  55052. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55053. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55054. * * 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
  55055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55056. * * 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)
  55057. * * 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)
  55058. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55059. * @param name defines the name of the mesh
  55060. * @param options defines the options used to create the mesh
  55061. * @param scene defines the hosting scene
  55062. * @returns the box mesh
  55063. */
  55064. static CreateTiledPlane(name: string, options: {
  55065. pattern?: number;
  55066. tileSize?: number;
  55067. tileWidth?: number;
  55068. tileHeight?: number;
  55069. size?: number;
  55070. width?: number;
  55071. height?: number;
  55072. alignHorizontal?: number;
  55073. alignVertical?: number;
  55074. sideOrientation?: number;
  55075. frontUVs?: Vector4;
  55076. backUVs?: Vector4;
  55077. updatable?: boolean;
  55078. }, scene?: Nullable<Scene>): Mesh;
  55079. }
  55080. }
  55081. declare module BABYLON {
  55082. /**
  55083. * Class containing static functions to help procedurally build meshes
  55084. */
  55085. export class TubeBuilder {
  55086. /**
  55087. * Creates a tube mesh.
  55088. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55089. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55090. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55091. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55092. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55093. * * 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)
  55094. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55095. * * 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
  55096. * * 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
  55097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55101. * @param name defines the name of the mesh
  55102. * @param options defines the options used to create the mesh
  55103. * @param scene defines the hosting scene
  55104. * @returns the tube mesh
  55105. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55106. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55107. */
  55108. static CreateTube(name: string, options: {
  55109. path: Vector3[];
  55110. radius?: number;
  55111. tessellation?: number;
  55112. radiusFunction?: {
  55113. (i: number, distance: number): number;
  55114. };
  55115. cap?: number;
  55116. arc?: number;
  55117. updatable?: boolean;
  55118. sideOrientation?: number;
  55119. frontUVs?: Vector4;
  55120. backUVs?: Vector4;
  55121. instance?: Mesh;
  55122. invertUV?: boolean;
  55123. }, scene?: Nullable<Scene>): Mesh;
  55124. }
  55125. }
  55126. declare module BABYLON {
  55127. /**
  55128. * Class containing static functions to help procedurally build meshes
  55129. */
  55130. export class IcoSphereBuilder {
  55131. /**
  55132. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55133. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55134. * * 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`)
  55135. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55136. * * 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
  55137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55138. * * 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
  55139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55140. * @param name defines the name of the mesh
  55141. * @param options defines the options used to create the mesh
  55142. * @param scene defines the hosting scene
  55143. * @returns the icosahedron mesh
  55144. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55145. */
  55146. static CreateIcoSphere(name: string, options: {
  55147. radius?: number;
  55148. radiusX?: number;
  55149. radiusY?: number;
  55150. radiusZ?: number;
  55151. flat?: boolean;
  55152. subdivisions?: number;
  55153. sideOrientation?: number;
  55154. frontUVs?: Vector4;
  55155. backUVs?: Vector4;
  55156. updatable?: boolean;
  55157. }, scene?: Nullable<Scene>): Mesh;
  55158. }
  55159. }
  55160. declare module BABYLON {
  55161. /**
  55162. * Class containing static functions to help procedurally build meshes
  55163. */
  55164. export class DecalBuilder {
  55165. /**
  55166. * Creates a decal mesh.
  55167. * 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
  55168. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55169. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55170. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55171. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55172. * @param name defines the name of the mesh
  55173. * @param sourceMesh defines the mesh where the decal must be applied
  55174. * @param options defines the options used to create the mesh
  55175. * @param scene defines the hosting scene
  55176. * @returns the decal mesh
  55177. * @see https://doc.babylonjs.com/how_to/decals
  55178. */
  55179. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55180. position?: Vector3;
  55181. normal?: Vector3;
  55182. size?: Vector3;
  55183. angle?: number;
  55184. }): Mesh;
  55185. }
  55186. }
  55187. declare module BABYLON {
  55188. /**
  55189. * Class containing static functions to help procedurally build meshes
  55190. */
  55191. export class MeshBuilder {
  55192. /**
  55193. * Creates a box mesh
  55194. * * The parameter `size` sets the size (float) of each box side (default 1)
  55195. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55196. * * 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)
  55197. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55199. * * 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
  55200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55202. * @param name defines the name of the mesh
  55203. * @param options defines the options used to create the mesh
  55204. * @param scene defines the hosting scene
  55205. * @returns the box mesh
  55206. */
  55207. static CreateBox(name: string, options: {
  55208. size?: number;
  55209. width?: number;
  55210. height?: number;
  55211. depth?: number;
  55212. faceUV?: Vector4[];
  55213. faceColors?: Color4[];
  55214. sideOrientation?: number;
  55215. frontUVs?: Vector4;
  55216. backUVs?: Vector4;
  55217. updatable?: boolean;
  55218. }, scene?: Nullable<Scene>): Mesh;
  55219. /**
  55220. * Creates a tiled box mesh
  55221. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55223. * @param name defines the name of the mesh
  55224. * @param options defines the options used to create the mesh
  55225. * @param scene defines the hosting scene
  55226. * @returns the tiled box mesh
  55227. */
  55228. static CreateTiledBox(name: string, options: {
  55229. pattern?: number;
  55230. size?: number;
  55231. width?: number;
  55232. height?: number;
  55233. depth: number;
  55234. tileSize?: number;
  55235. tileWidth?: number;
  55236. tileHeight?: number;
  55237. faceUV?: Vector4[];
  55238. faceColors?: Color4[];
  55239. alignHorizontal?: number;
  55240. alignVertical?: number;
  55241. sideOrientation?: number;
  55242. updatable?: boolean;
  55243. }, scene?: Nullable<Scene>): Mesh;
  55244. /**
  55245. * Creates a sphere mesh
  55246. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55247. * * 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`)
  55248. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55249. * * 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
  55250. * * 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)
  55251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55252. * * 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
  55253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55254. * @param name defines the name of the mesh
  55255. * @param options defines the options used to create the mesh
  55256. * @param scene defines the hosting scene
  55257. * @returns the sphere mesh
  55258. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55259. */
  55260. static CreateSphere(name: string, options: {
  55261. segments?: number;
  55262. diameter?: number;
  55263. diameterX?: number;
  55264. diameterY?: number;
  55265. diameterZ?: number;
  55266. arc?: number;
  55267. slice?: number;
  55268. sideOrientation?: number;
  55269. frontUVs?: Vector4;
  55270. backUVs?: Vector4;
  55271. updatable?: boolean;
  55272. }, scene?: Nullable<Scene>): Mesh;
  55273. /**
  55274. * Creates a plane polygonal mesh. By default, this is a disc
  55275. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55276. * * 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
  55277. * * 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
  55278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55279. * * 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
  55280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55281. * @param name defines the name of the mesh
  55282. * @param options defines the options used to create the mesh
  55283. * @param scene defines the hosting scene
  55284. * @returns the plane polygonal mesh
  55285. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55286. */
  55287. static CreateDisc(name: string, options: {
  55288. radius?: number;
  55289. tessellation?: number;
  55290. arc?: number;
  55291. updatable?: boolean;
  55292. sideOrientation?: number;
  55293. frontUVs?: Vector4;
  55294. backUVs?: Vector4;
  55295. }, scene?: Nullable<Scene>): Mesh;
  55296. /**
  55297. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55298. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55299. * * 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`)
  55300. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55301. * * 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
  55302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55303. * * 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
  55304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55305. * @param name defines the name of the mesh
  55306. * @param options defines the options used to create the mesh
  55307. * @param scene defines the hosting scene
  55308. * @returns the icosahedron mesh
  55309. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55310. */
  55311. static CreateIcoSphere(name: string, options: {
  55312. radius?: number;
  55313. radiusX?: number;
  55314. radiusY?: number;
  55315. radiusZ?: number;
  55316. flat?: boolean;
  55317. subdivisions?: number;
  55318. sideOrientation?: number;
  55319. frontUVs?: Vector4;
  55320. backUVs?: Vector4;
  55321. updatable?: boolean;
  55322. }, scene?: Nullable<Scene>): Mesh;
  55323. /**
  55324. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55325. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55326. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55327. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55328. * * 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
  55329. * * 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
  55330. * * 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
  55331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55332. * * 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
  55333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55334. * * 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
  55335. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55336. * * 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
  55337. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55339. * @param name defines the name of the mesh
  55340. * @param options defines the options used to create the mesh
  55341. * @param scene defines the hosting scene
  55342. * @returns the ribbon mesh
  55343. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55345. */
  55346. static CreateRibbon(name: string, options: {
  55347. pathArray: Vector3[][];
  55348. closeArray?: boolean;
  55349. closePath?: boolean;
  55350. offset?: number;
  55351. updatable?: boolean;
  55352. sideOrientation?: number;
  55353. frontUVs?: Vector4;
  55354. backUVs?: Vector4;
  55355. instance?: Mesh;
  55356. invertUV?: boolean;
  55357. uvs?: Vector2[];
  55358. colors?: Color4[];
  55359. }, scene?: Nullable<Scene>): Mesh;
  55360. /**
  55361. * Creates a cylinder or a cone mesh
  55362. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55363. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55364. * * 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.
  55365. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55366. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55367. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55368. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55369. * * 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).
  55370. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55371. * * 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).
  55372. * * 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
  55373. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55374. * * 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
  55375. * * 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.
  55376. * * If `enclose` is false, a ring surface is one element.
  55377. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55378. * * 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
  55379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55380. * * 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
  55381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55382. * @param name defines the name of the mesh
  55383. * @param options defines the options used to create the mesh
  55384. * @param scene defines the hosting scene
  55385. * @returns the cylinder mesh
  55386. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55387. */
  55388. static CreateCylinder(name: string, options: {
  55389. height?: number;
  55390. diameterTop?: number;
  55391. diameterBottom?: number;
  55392. diameter?: number;
  55393. tessellation?: number;
  55394. subdivisions?: number;
  55395. arc?: number;
  55396. faceColors?: Color4[];
  55397. faceUV?: Vector4[];
  55398. updatable?: boolean;
  55399. hasRings?: boolean;
  55400. enclose?: boolean;
  55401. cap?: number;
  55402. sideOrientation?: number;
  55403. frontUVs?: Vector4;
  55404. backUVs?: Vector4;
  55405. }, scene?: Nullable<Scene>): Mesh;
  55406. /**
  55407. * Creates a torus mesh
  55408. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55409. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55410. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55412. * * 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
  55413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55414. * @param name defines the name of the mesh
  55415. * @param options defines the options used to create the mesh
  55416. * @param scene defines the hosting scene
  55417. * @returns the torus mesh
  55418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55419. */
  55420. static CreateTorus(name: string, options: {
  55421. diameter?: number;
  55422. thickness?: number;
  55423. tessellation?: number;
  55424. updatable?: boolean;
  55425. sideOrientation?: number;
  55426. frontUVs?: Vector4;
  55427. backUVs?: Vector4;
  55428. }, scene?: Nullable<Scene>): Mesh;
  55429. /**
  55430. * Creates a torus knot mesh
  55431. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55432. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55433. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55434. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55436. * * 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
  55437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55438. * @param name defines the name of the mesh
  55439. * @param options defines the options used to create the mesh
  55440. * @param scene defines the hosting scene
  55441. * @returns the torus knot mesh
  55442. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55443. */
  55444. static CreateTorusKnot(name: string, options: {
  55445. radius?: number;
  55446. tube?: number;
  55447. radialSegments?: number;
  55448. tubularSegments?: number;
  55449. p?: number;
  55450. q?: number;
  55451. updatable?: boolean;
  55452. sideOrientation?: number;
  55453. frontUVs?: Vector4;
  55454. backUVs?: Vector4;
  55455. }, scene?: Nullable<Scene>): Mesh;
  55456. /**
  55457. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55458. * * 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
  55459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55460. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55461. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55462. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55463. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55464. * * 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
  55465. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55468. * @param name defines the name of the new line system
  55469. * @param options defines the options used to create the line system
  55470. * @param scene defines the hosting scene
  55471. * @returns a new line system mesh
  55472. */
  55473. static CreateLineSystem(name: string, options: {
  55474. lines: Vector3[][];
  55475. updatable?: boolean;
  55476. instance?: Nullable<LinesMesh>;
  55477. colors?: Nullable<Color4[][]>;
  55478. useVertexAlpha?: boolean;
  55479. }, scene: Nullable<Scene>): LinesMesh;
  55480. /**
  55481. * Creates a line mesh
  55482. * 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
  55483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55484. * * The parameter `points` is an array successive Vector3
  55485. * * 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
  55486. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55487. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55488. * * When updating an instance, remember that only point positions can change, not the number of points
  55489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55491. * @param name defines the name of the new line system
  55492. * @param options defines the options used to create the line system
  55493. * @param scene defines the hosting scene
  55494. * @returns a new line mesh
  55495. */
  55496. static CreateLines(name: string, options: {
  55497. points: Vector3[];
  55498. updatable?: boolean;
  55499. instance?: Nullable<LinesMesh>;
  55500. colors?: Color4[];
  55501. useVertexAlpha?: boolean;
  55502. }, scene?: Nullable<Scene>): LinesMesh;
  55503. /**
  55504. * Creates a dashed line mesh
  55505. * * 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
  55506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55507. * * The parameter `points` is an array successive Vector3
  55508. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55509. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55510. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55511. * * 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
  55512. * * When updating an instance, remember that only point positions can change, not the number of points
  55513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55514. * @param name defines the name of the mesh
  55515. * @param options defines the options used to create the mesh
  55516. * @param scene defines the hosting scene
  55517. * @returns the dashed line mesh
  55518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55519. */
  55520. static CreateDashedLines(name: string, options: {
  55521. points: Vector3[];
  55522. dashSize?: number;
  55523. gapSize?: number;
  55524. dashNb?: number;
  55525. updatable?: boolean;
  55526. instance?: LinesMesh;
  55527. }, scene?: Nullable<Scene>): LinesMesh;
  55528. /**
  55529. * 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.
  55530. * * 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.
  55531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55532. * * 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.
  55533. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55534. * * 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
  55535. * * 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
  55536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55538. * * 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
  55539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55541. * @param name defines the name of the mesh
  55542. * @param options defines the options used to create the mesh
  55543. * @param scene defines the hosting scene
  55544. * @returns the extruded shape mesh
  55545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55547. */
  55548. static ExtrudeShape(name: string, options: {
  55549. shape: Vector3[];
  55550. path: Vector3[];
  55551. scale?: number;
  55552. rotation?: number;
  55553. cap?: number;
  55554. updatable?: boolean;
  55555. sideOrientation?: number;
  55556. frontUVs?: Vector4;
  55557. backUVs?: Vector4;
  55558. instance?: Mesh;
  55559. invertUV?: boolean;
  55560. }, scene?: Nullable<Scene>): Mesh;
  55561. /**
  55562. * Creates an custom extruded shape mesh.
  55563. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55564. * * 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.
  55565. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55566. * * 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
  55567. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55568. * * 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
  55569. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55570. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55571. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55572. * * 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
  55573. * * 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
  55574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55576. * * 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
  55577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55579. * @param name defines the name of the mesh
  55580. * @param options defines the options used to create the mesh
  55581. * @param scene defines the hosting scene
  55582. * @returns the custom extruded shape mesh
  55583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55586. */
  55587. static ExtrudeShapeCustom(name: string, options: {
  55588. shape: Vector3[];
  55589. path: Vector3[];
  55590. scaleFunction?: any;
  55591. rotationFunction?: any;
  55592. ribbonCloseArray?: boolean;
  55593. ribbonClosePath?: boolean;
  55594. cap?: number;
  55595. updatable?: boolean;
  55596. sideOrientation?: number;
  55597. frontUVs?: Vector4;
  55598. backUVs?: Vector4;
  55599. instance?: Mesh;
  55600. invertUV?: boolean;
  55601. }, scene?: Nullable<Scene>): Mesh;
  55602. /**
  55603. * Creates lathe mesh.
  55604. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55605. * * 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
  55606. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55607. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55608. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55609. * * 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
  55610. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55611. * * 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
  55612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55613. * * 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
  55614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55616. * @param name defines the name of the mesh
  55617. * @param options defines the options used to create the mesh
  55618. * @param scene defines the hosting scene
  55619. * @returns the lathe mesh
  55620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55621. */
  55622. static CreateLathe(name: string, options: {
  55623. shape: Vector3[];
  55624. radius?: number;
  55625. tessellation?: number;
  55626. clip?: number;
  55627. arc?: number;
  55628. closed?: boolean;
  55629. updatable?: boolean;
  55630. sideOrientation?: number;
  55631. frontUVs?: Vector4;
  55632. backUVs?: Vector4;
  55633. cap?: number;
  55634. invertUV?: boolean;
  55635. }, scene?: Nullable<Scene>): Mesh;
  55636. /**
  55637. * Creates a tiled plane mesh
  55638. * * You can set a limited pattern arrangement with the tiles
  55639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55640. * * 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
  55641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55642. * @param name defines the name of the mesh
  55643. * @param options defines the options used to create the mesh
  55644. * @param scene defines the hosting scene
  55645. * @returns the plane mesh
  55646. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55647. */
  55648. static CreateTiledPlane(name: string, options: {
  55649. pattern?: number;
  55650. tileSize?: number;
  55651. tileWidth?: number;
  55652. tileHeight?: number;
  55653. size?: number;
  55654. width?: number;
  55655. height?: number;
  55656. alignHorizontal?: number;
  55657. alignVertical?: number;
  55658. sideOrientation?: number;
  55659. frontUVs?: Vector4;
  55660. backUVs?: Vector4;
  55661. updatable?: boolean;
  55662. }, scene?: Nullable<Scene>): Mesh;
  55663. /**
  55664. * Creates a plane mesh
  55665. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55666. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55667. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55669. * * 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
  55670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55671. * @param name defines the name of the mesh
  55672. * @param options defines the options used to create the mesh
  55673. * @param scene defines the hosting scene
  55674. * @returns the plane mesh
  55675. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55676. */
  55677. static CreatePlane(name: string, options: {
  55678. size?: number;
  55679. width?: number;
  55680. height?: number;
  55681. sideOrientation?: number;
  55682. frontUVs?: Vector4;
  55683. backUVs?: Vector4;
  55684. updatable?: boolean;
  55685. sourcePlane?: Plane;
  55686. }, scene?: Nullable<Scene>): Mesh;
  55687. /**
  55688. * Creates a ground mesh
  55689. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55690. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55692. * @param name defines the name of the mesh
  55693. * @param options defines the options used to create the mesh
  55694. * @param scene defines the hosting scene
  55695. * @returns the ground mesh
  55696. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55697. */
  55698. static CreateGround(name: string, options: {
  55699. width?: number;
  55700. height?: number;
  55701. subdivisions?: number;
  55702. subdivisionsX?: number;
  55703. subdivisionsY?: number;
  55704. updatable?: boolean;
  55705. }, scene?: Nullable<Scene>): Mesh;
  55706. /**
  55707. * Creates a tiled ground mesh
  55708. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55709. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55710. * * 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
  55711. * * 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
  55712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55713. * @param name defines the name of the mesh
  55714. * @param options defines the options used to create the mesh
  55715. * @param scene defines the hosting scene
  55716. * @returns the tiled ground mesh
  55717. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55718. */
  55719. static CreateTiledGround(name: string, options: {
  55720. xmin: number;
  55721. zmin: number;
  55722. xmax: number;
  55723. zmax: number;
  55724. subdivisions?: {
  55725. w: number;
  55726. h: number;
  55727. };
  55728. precision?: {
  55729. w: number;
  55730. h: number;
  55731. };
  55732. updatable?: boolean;
  55733. }, scene?: Nullable<Scene>): Mesh;
  55734. /**
  55735. * Creates a ground mesh from a height map
  55736. * * The parameter `url` sets the URL of the height map image resource.
  55737. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55738. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55739. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55740. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55741. * * 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.
  55742. * * 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).
  55743. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55745. * @param name defines the name of the mesh
  55746. * @param url defines the url to the height map
  55747. * @param options defines the options used to create the mesh
  55748. * @param scene defines the hosting scene
  55749. * @returns the ground mesh
  55750. * @see https://doc.babylonjs.com/babylon101/height_map
  55751. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55752. */
  55753. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55754. width?: number;
  55755. height?: number;
  55756. subdivisions?: number;
  55757. minHeight?: number;
  55758. maxHeight?: number;
  55759. colorFilter?: Color3;
  55760. alphaFilter?: number;
  55761. updatable?: boolean;
  55762. onReady?: (mesh: GroundMesh) => void;
  55763. }, scene?: Nullable<Scene>): GroundMesh;
  55764. /**
  55765. * Creates a polygon mesh
  55766. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55767. * * 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
  55768. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55770. * * 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)
  55771. * * Remember you can only change the shape positions, not their number when updating a polygon
  55772. * @param name defines the name of the mesh
  55773. * @param options defines the options used to create the mesh
  55774. * @param scene defines the hosting scene
  55775. * @param earcutInjection can be used to inject your own earcut reference
  55776. * @returns the polygon mesh
  55777. */
  55778. static CreatePolygon(name: string, options: {
  55779. shape: Vector3[];
  55780. holes?: Vector3[][];
  55781. depth?: number;
  55782. faceUV?: Vector4[];
  55783. faceColors?: Color4[];
  55784. updatable?: boolean;
  55785. sideOrientation?: number;
  55786. frontUVs?: Vector4;
  55787. backUVs?: Vector4;
  55788. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55789. /**
  55790. * Creates an extruded polygon mesh, with depth in the Y direction.
  55791. * * 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)
  55792. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55793. * @param name defines the name of the mesh
  55794. * @param options defines the options used to create the mesh
  55795. * @param scene defines the hosting scene
  55796. * @param earcutInjection can be used to inject your own earcut reference
  55797. * @returns the polygon mesh
  55798. */
  55799. static ExtrudePolygon(name: string, options: {
  55800. shape: Vector3[];
  55801. holes?: Vector3[][];
  55802. depth?: number;
  55803. faceUV?: Vector4[];
  55804. faceColors?: Color4[];
  55805. updatable?: boolean;
  55806. sideOrientation?: number;
  55807. frontUVs?: Vector4;
  55808. backUVs?: Vector4;
  55809. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55810. /**
  55811. * Creates a tube mesh.
  55812. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55813. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55814. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55815. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55816. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55817. * * 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)
  55818. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55819. * * 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
  55820. * * 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
  55821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55822. * * 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
  55823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55825. * @param name defines the name of the mesh
  55826. * @param options defines the options used to create the mesh
  55827. * @param scene defines the hosting scene
  55828. * @returns the tube mesh
  55829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55830. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55831. */
  55832. static CreateTube(name: string, options: {
  55833. path: Vector3[];
  55834. radius?: number;
  55835. tessellation?: number;
  55836. radiusFunction?: {
  55837. (i: number, distance: number): number;
  55838. };
  55839. cap?: number;
  55840. arc?: number;
  55841. updatable?: boolean;
  55842. sideOrientation?: number;
  55843. frontUVs?: Vector4;
  55844. backUVs?: Vector4;
  55845. instance?: Mesh;
  55846. invertUV?: boolean;
  55847. }, scene?: Nullable<Scene>): Mesh;
  55848. /**
  55849. * Creates a polyhedron mesh
  55850. * * 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
  55851. * * The parameter `size` (positive float, default 1) sets the polygon size
  55852. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55853. * * 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`
  55854. * * 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
  55855. * * 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)`)
  55856. * * 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
  55857. * * 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
  55858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55859. * * 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
  55860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55861. * @param name defines the name of the mesh
  55862. * @param options defines the options used to create the mesh
  55863. * @param scene defines the hosting scene
  55864. * @returns the polyhedron mesh
  55865. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55866. */
  55867. static CreatePolyhedron(name: string, options: {
  55868. type?: number;
  55869. size?: number;
  55870. sizeX?: number;
  55871. sizeY?: number;
  55872. sizeZ?: number;
  55873. custom?: any;
  55874. faceUV?: Vector4[];
  55875. faceColors?: Color4[];
  55876. flat?: boolean;
  55877. updatable?: boolean;
  55878. sideOrientation?: number;
  55879. frontUVs?: Vector4;
  55880. backUVs?: Vector4;
  55881. }, scene?: Nullable<Scene>): Mesh;
  55882. /**
  55883. * Creates a decal mesh.
  55884. * 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
  55885. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55886. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55887. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55888. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55889. * @param name defines the name of the mesh
  55890. * @param sourceMesh defines the mesh where the decal must be applied
  55891. * @param options defines the options used to create the mesh
  55892. * @param scene defines the hosting scene
  55893. * @returns the decal mesh
  55894. * @see https://doc.babylonjs.com/how_to/decals
  55895. */
  55896. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55897. position?: Vector3;
  55898. normal?: Vector3;
  55899. size?: Vector3;
  55900. angle?: number;
  55901. }): Mesh;
  55902. }
  55903. }
  55904. declare module BABYLON {
  55905. /**
  55906. * A simplifier interface for future simplification implementations
  55907. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55908. */
  55909. export interface ISimplifier {
  55910. /**
  55911. * Simplification of a given mesh according to the given settings.
  55912. * Since this requires computation, it is assumed that the function runs async.
  55913. * @param settings The settings of the simplification, including quality and distance
  55914. * @param successCallback A callback that will be called after the mesh was simplified.
  55915. * @param errorCallback in case of an error, this callback will be called. optional.
  55916. */
  55917. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55918. }
  55919. /**
  55920. * Expected simplification settings.
  55921. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55923. */
  55924. export interface ISimplificationSettings {
  55925. /**
  55926. * Gets or sets the expected quality
  55927. */
  55928. quality: number;
  55929. /**
  55930. * Gets or sets the distance when this optimized version should be used
  55931. */
  55932. distance: number;
  55933. /**
  55934. * Gets an already optimized mesh
  55935. */
  55936. optimizeMesh?: boolean;
  55937. }
  55938. /**
  55939. * Class used to specify simplification options
  55940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55941. */
  55942. export class SimplificationSettings implements ISimplificationSettings {
  55943. /** expected quality */
  55944. quality: number;
  55945. /** distance when this optimized version should be used */
  55946. distance: number;
  55947. /** already optimized mesh */
  55948. optimizeMesh?: boolean | undefined;
  55949. /**
  55950. * Creates a SimplificationSettings
  55951. * @param quality expected quality
  55952. * @param distance distance when this optimized version should be used
  55953. * @param optimizeMesh already optimized mesh
  55954. */
  55955. constructor(
  55956. /** expected quality */
  55957. quality: number,
  55958. /** distance when this optimized version should be used */
  55959. distance: number,
  55960. /** already optimized mesh */
  55961. optimizeMesh?: boolean | undefined);
  55962. }
  55963. /**
  55964. * Interface used to define a simplification task
  55965. */
  55966. export interface ISimplificationTask {
  55967. /**
  55968. * Array of settings
  55969. */
  55970. settings: Array<ISimplificationSettings>;
  55971. /**
  55972. * Simplification type
  55973. */
  55974. simplificationType: SimplificationType;
  55975. /**
  55976. * Mesh to simplify
  55977. */
  55978. mesh: Mesh;
  55979. /**
  55980. * Callback called on success
  55981. */
  55982. successCallback?: () => void;
  55983. /**
  55984. * Defines if parallel processing can be used
  55985. */
  55986. parallelProcessing: boolean;
  55987. }
  55988. /**
  55989. * Queue used to order the simplification tasks
  55990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55991. */
  55992. export class SimplificationQueue {
  55993. private _simplificationArray;
  55994. /**
  55995. * Gets a boolean indicating that the process is still running
  55996. */
  55997. running: boolean;
  55998. /**
  55999. * Creates a new queue
  56000. */
  56001. constructor();
  56002. /**
  56003. * Adds a new simplification task
  56004. * @param task defines a task to add
  56005. */
  56006. addTask(task: ISimplificationTask): void;
  56007. /**
  56008. * Execute next task
  56009. */
  56010. executeNext(): void;
  56011. /**
  56012. * Execute a simplification task
  56013. * @param task defines the task to run
  56014. */
  56015. runSimplification(task: ISimplificationTask): void;
  56016. private getSimplifier;
  56017. }
  56018. /**
  56019. * The implemented types of simplification
  56020. * At the moment only Quadratic Error Decimation is implemented
  56021. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56022. */
  56023. export enum SimplificationType {
  56024. /** Quadratic error decimation */
  56025. QUADRATIC = 0
  56026. }
  56027. }
  56028. declare module BABYLON {
  56029. interface Scene {
  56030. /** @hidden (Backing field) */
  56031. _simplificationQueue: SimplificationQueue;
  56032. /**
  56033. * Gets or sets the simplification queue attached to the scene
  56034. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56035. */
  56036. simplificationQueue: SimplificationQueue;
  56037. }
  56038. interface Mesh {
  56039. /**
  56040. * Simplify the mesh according to the given array of settings.
  56041. * Function will return immediately and will simplify async
  56042. * @param settings a collection of simplification settings
  56043. * @param parallelProcessing should all levels calculate parallel or one after the other
  56044. * @param simplificationType the type of simplification to run
  56045. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56046. * @returns the current mesh
  56047. */
  56048. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56049. }
  56050. /**
  56051. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56052. * created in a scene
  56053. */
  56054. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56055. /**
  56056. * The component name helpfull to identify the component in the list of scene components.
  56057. */
  56058. readonly name: string;
  56059. /**
  56060. * The scene the component belongs to.
  56061. */
  56062. scene: Scene;
  56063. /**
  56064. * Creates a new instance of the component for the given scene
  56065. * @param scene Defines the scene to register the component in
  56066. */
  56067. constructor(scene: Scene);
  56068. /**
  56069. * Registers the component in a given scene
  56070. */
  56071. register(): void;
  56072. /**
  56073. * Rebuilds the elements related to this component in case of
  56074. * context lost for instance.
  56075. */
  56076. rebuild(): void;
  56077. /**
  56078. * Disposes the component and the associated ressources
  56079. */
  56080. dispose(): void;
  56081. private _beforeCameraUpdate;
  56082. }
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56087. */
  56088. export interface INavigationEnginePlugin {
  56089. /**
  56090. * plugin name
  56091. */
  56092. name: string;
  56093. /**
  56094. * Creates a navigation mesh
  56095. * @param meshes array of all the geometry used to compute the navigatio mesh
  56096. * @param parameters bunch of parameters used to filter geometry
  56097. */
  56098. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56099. /**
  56100. * Create a navigation mesh debug mesh
  56101. * @param scene is where the mesh will be added
  56102. * @returns debug display mesh
  56103. */
  56104. createDebugNavMesh(scene: Scene): Mesh;
  56105. /**
  56106. * Get a navigation mesh constrained position, closest to the parameter position
  56107. * @param position world position
  56108. * @returns the closest point to position constrained by the navigation mesh
  56109. */
  56110. getClosestPoint(position: Vector3): Vector3;
  56111. /**
  56112. * Get a navigation mesh constrained position, within a particular radius
  56113. * @param position world position
  56114. * @param maxRadius the maximum distance to the constrained world position
  56115. * @returns the closest point to position constrained by the navigation mesh
  56116. */
  56117. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56118. /**
  56119. * Compute the final position from a segment made of destination-position
  56120. * @param position world position
  56121. * @param destination world position
  56122. * @returns the resulting point along the navmesh
  56123. */
  56124. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56125. /**
  56126. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56127. * @param start world position
  56128. * @param end world position
  56129. * @returns array containing world position composing the path
  56130. */
  56131. computePath(start: Vector3, end: Vector3): Vector3[];
  56132. /**
  56133. * If this plugin is supported
  56134. * @returns true if plugin is supported
  56135. */
  56136. isSupported(): boolean;
  56137. /**
  56138. * Create a new Crowd so you can add agents
  56139. * @param maxAgents the maximum agent count in the crowd
  56140. * @param maxAgentRadius the maximum radius an agent can have
  56141. * @param scene to attach the crowd to
  56142. * @returns the crowd you can add agents to
  56143. */
  56144. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56145. /**
  56146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56147. * The queries will try to find a solution within those bounds
  56148. * default is (1,1,1)
  56149. * @param extent x,y,z value that define the extent around the queries point of reference
  56150. */
  56151. setDefaultQueryExtent(extent: Vector3): void;
  56152. /**
  56153. * Get the Bounding box extent specified by setDefaultQueryExtent
  56154. * @returns the box extent values
  56155. */
  56156. getDefaultQueryExtent(): Vector3;
  56157. /**
  56158. * Release all resources
  56159. */
  56160. dispose(): void;
  56161. }
  56162. /**
  56163. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56164. */
  56165. export interface ICrowd {
  56166. /**
  56167. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56168. * You can attach anything to that node. The node position is updated in the scene update tick.
  56169. * @param pos world position that will be constrained by the navigation mesh
  56170. * @param parameters agent parameters
  56171. * @param transform hooked to the agent that will be update by the scene
  56172. * @returns agent index
  56173. */
  56174. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56175. /**
  56176. * Returns the agent position in world space
  56177. * @param index agent index returned by addAgent
  56178. * @returns world space position
  56179. */
  56180. getAgentPosition(index: number): Vector3;
  56181. /**
  56182. * Gets the agent velocity in world space
  56183. * @param index agent index returned by addAgent
  56184. * @returns world space velocity
  56185. */
  56186. getAgentVelocity(index: number): Vector3;
  56187. /**
  56188. * remove a particular agent previously created
  56189. * @param index agent index returned by addAgent
  56190. */
  56191. removeAgent(index: number): void;
  56192. /**
  56193. * get the list of all agents attached to this crowd
  56194. * @returns list of agent indices
  56195. */
  56196. getAgents(): number[];
  56197. /**
  56198. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56199. * @param deltaTime in seconds
  56200. */
  56201. update(deltaTime: number): void;
  56202. /**
  56203. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56204. * @param index agent index returned by addAgent
  56205. * @param destination targeted world position
  56206. */
  56207. agentGoto(index: number, destination: Vector3): void;
  56208. /**
  56209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56210. * The queries will try to find a solution within those bounds
  56211. * default is (1,1,1)
  56212. * @param extent x,y,z value that define the extent around the queries point of reference
  56213. */
  56214. setDefaultQueryExtent(extent: Vector3): void;
  56215. /**
  56216. * Get the Bounding box extent specified by setDefaultQueryExtent
  56217. * @returns the box extent values
  56218. */
  56219. getDefaultQueryExtent(): Vector3;
  56220. /**
  56221. * Release all resources
  56222. */
  56223. dispose(): void;
  56224. }
  56225. /**
  56226. * Configures an agent
  56227. */
  56228. export interface IAgentParameters {
  56229. /**
  56230. * Agent radius. [Limit: >= 0]
  56231. */
  56232. radius: number;
  56233. /**
  56234. * Agent height. [Limit: > 0]
  56235. */
  56236. height: number;
  56237. /**
  56238. * Maximum allowed acceleration. [Limit: >= 0]
  56239. */
  56240. maxAcceleration: number;
  56241. /**
  56242. * Maximum allowed speed. [Limit: >= 0]
  56243. */
  56244. maxSpeed: number;
  56245. /**
  56246. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56247. */
  56248. collisionQueryRange: number;
  56249. /**
  56250. * The path visibility optimization range. [Limit: > 0]
  56251. */
  56252. pathOptimizationRange: number;
  56253. /**
  56254. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56255. */
  56256. separationWeight: number;
  56257. }
  56258. /**
  56259. * Configures the navigation mesh creation
  56260. */
  56261. export interface INavMeshParameters {
  56262. /**
  56263. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56264. */
  56265. cs: number;
  56266. /**
  56267. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56268. */
  56269. ch: number;
  56270. /**
  56271. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56272. */
  56273. walkableSlopeAngle: number;
  56274. /**
  56275. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56276. * be considered walkable. [Limit: >= 3] [Units: vx]
  56277. */
  56278. walkableHeight: number;
  56279. /**
  56280. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56281. */
  56282. walkableClimb: number;
  56283. /**
  56284. * The distance to erode/shrink the walkable area of the heightfield away from
  56285. * obstructions. [Limit: >=0] [Units: vx]
  56286. */
  56287. walkableRadius: number;
  56288. /**
  56289. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56290. */
  56291. maxEdgeLen: number;
  56292. /**
  56293. * The maximum distance a simplfied contour's border edges should deviate
  56294. * the original raw contour. [Limit: >=0] [Units: vx]
  56295. */
  56296. maxSimplificationError: number;
  56297. /**
  56298. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56299. */
  56300. minRegionArea: number;
  56301. /**
  56302. * Any regions with a span count smaller than this value will, if possible,
  56303. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56304. */
  56305. mergeRegionArea: number;
  56306. /**
  56307. * The maximum number of vertices allowed for polygons generated during the
  56308. * contour to polygon conversion process. [Limit: >= 3]
  56309. */
  56310. maxVertsPerPoly: number;
  56311. /**
  56312. * Sets the sampling distance to use when generating the detail mesh.
  56313. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56314. */
  56315. detailSampleDist: number;
  56316. /**
  56317. * The maximum distance the detail mesh surface should deviate from heightfield
  56318. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56319. */
  56320. detailSampleMaxError: number;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * RecastJS navigation plugin
  56326. */
  56327. export class RecastJSPlugin implements INavigationEnginePlugin {
  56328. /**
  56329. * Reference to the Recast library
  56330. */
  56331. bjsRECAST: any;
  56332. /**
  56333. * plugin name
  56334. */
  56335. name: string;
  56336. /**
  56337. * the first navmesh created. We might extend this to support multiple navmeshes
  56338. */
  56339. navMesh: any;
  56340. /**
  56341. * Initializes the recastJS plugin
  56342. * @param recastInjection can be used to inject your own recast reference
  56343. */
  56344. constructor(recastInjection?: any);
  56345. /**
  56346. * Creates a navigation mesh
  56347. * @param meshes array of all the geometry used to compute the navigatio mesh
  56348. * @param parameters bunch of parameters used to filter geometry
  56349. */
  56350. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56351. /**
  56352. * Create a navigation mesh debug mesh
  56353. * @param scene is where the mesh will be added
  56354. * @returns debug display mesh
  56355. */
  56356. createDebugNavMesh(scene: Scene): Mesh;
  56357. /**
  56358. * Get a navigation mesh constrained position, closest to the parameter position
  56359. * @param position world position
  56360. * @returns the closest point to position constrained by the navigation mesh
  56361. */
  56362. getClosestPoint(position: Vector3): Vector3;
  56363. /**
  56364. * Get a navigation mesh constrained position, within a particular radius
  56365. * @param position world position
  56366. * @param maxRadius the maximum distance to the constrained world position
  56367. * @returns the closest point to position constrained by the navigation mesh
  56368. */
  56369. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56370. /**
  56371. * Compute the final position from a segment made of destination-position
  56372. * @param position world position
  56373. * @param destination world position
  56374. * @returns the resulting point along the navmesh
  56375. */
  56376. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56377. /**
  56378. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56379. * @param start world position
  56380. * @param end world position
  56381. * @returns array containing world position composing the path
  56382. */
  56383. computePath(start: Vector3, end: Vector3): Vector3[];
  56384. /**
  56385. * Create a new Crowd so you can add agents
  56386. * @param maxAgents the maximum agent count in the crowd
  56387. * @param maxAgentRadius the maximum radius an agent can have
  56388. * @param scene to attach the crowd to
  56389. * @returns the crowd you can add agents to
  56390. */
  56391. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56392. /**
  56393. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56394. * The queries will try to find a solution within those bounds
  56395. * default is (1,1,1)
  56396. * @param extent x,y,z value that define the extent around the queries point of reference
  56397. */
  56398. setDefaultQueryExtent(extent: Vector3): void;
  56399. /**
  56400. * Get the Bounding box extent specified by setDefaultQueryExtent
  56401. * @returns the box extent values
  56402. */
  56403. getDefaultQueryExtent(): Vector3;
  56404. /**
  56405. * Disposes
  56406. */
  56407. dispose(): void;
  56408. /**
  56409. * If this plugin is supported
  56410. * @returns true if plugin is supported
  56411. */
  56412. isSupported(): boolean;
  56413. }
  56414. /**
  56415. * Recast detour crowd implementation
  56416. */
  56417. export class RecastJSCrowd implements ICrowd {
  56418. /**
  56419. * Recast/detour plugin
  56420. */
  56421. bjsRECASTPlugin: RecastJSPlugin;
  56422. /**
  56423. * Link to the detour crowd
  56424. */
  56425. recastCrowd: any;
  56426. /**
  56427. * One transform per agent
  56428. */
  56429. transforms: TransformNode[];
  56430. /**
  56431. * All agents created
  56432. */
  56433. agents: number[];
  56434. /**
  56435. * Link to the scene is kept to unregister the crowd from the scene
  56436. */
  56437. private _scene;
  56438. /**
  56439. * Observer for crowd updates
  56440. */
  56441. private _onBeforeAnimationsObserver;
  56442. /**
  56443. * Constructor
  56444. * @param plugin recastJS plugin
  56445. * @param maxAgents the maximum agent count in the crowd
  56446. * @param maxAgentRadius the maximum radius an agent can have
  56447. * @param scene to attach the crowd to
  56448. * @returns the crowd you can add agents to
  56449. */
  56450. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56451. /**
  56452. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56453. * You can attach anything to that node. The node position is updated in the scene update tick.
  56454. * @param pos world position that will be constrained by the navigation mesh
  56455. * @param parameters agent parameters
  56456. * @param transform hooked to the agent that will be update by the scene
  56457. * @returns agent index
  56458. */
  56459. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56460. /**
  56461. * Returns the agent position in world space
  56462. * @param index agent index returned by addAgent
  56463. * @returns world space position
  56464. */
  56465. getAgentPosition(index: number): Vector3;
  56466. /**
  56467. * Returns the agent velocity in world space
  56468. * @param index agent index returned by addAgent
  56469. * @returns world space velocity
  56470. */
  56471. getAgentVelocity(index: number): Vector3;
  56472. /**
  56473. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56474. * @param index agent index returned by addAgent
  56475. * @param destination targeted world position
  56476. */
  56477. agentGoto(index: number, destination: Vector3): void;
  56478. /**
  56479. * remove a particular agent previously created
  56480. * @param index agent index returned by addAgent
  56481. */
  56482. removeAgent(index: number): void;
  56483. /**
  56484. * get the list of all agents attached to this crowd
  56485. * @returns list of agent indices
  56486. */
  56487. getAgents(): number[];
  56488. /**
  56489. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56490. * @param deltaTime in seconds
  56491. */
  56492. update(deltaTime: number): void;
  56493. /**
  56494. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56495. * The queries will try to find a solution within those bounds
  56496. * default is (1,1,1)
  56497. * @param extent x,y,z value that define the extent around the queries point of reference
  56498. */
  56499. setDefaultQueryExtent(extent: Vector3): void;
  56500. /**
  56501. * Get the Bounding box extent specified by setDefaultQueryExtent
  56502. * @returns the box extent values
  56503. */
  56504. getDefaultQueryExtent(): Vector3;
  56505. /**
  56506. * Release all resources
  56507. */
  56508. dispose(): void;
  56509. }
  56510. }
  56511. declare module BABYLON {
  56512. /**
  56513. * Class used to enable access to IndexedDB
  56514. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56515. */
  56516. export class Database implements IOfflineProvider {
  56517. private _callbackManifestChecked;
  56518. private _currentSceneUrl;
  56519. private _db;
  56520. private _enableSceneOffline;
  56521. private _enableTexturesOffline;
  56522. private _manifestVersionFound;
  56523. private _mustUpdateRessources;
  56524. private _hasReachedQuota;
  56525. private _isSupported;
  56526. private _idbFactory;
  56527. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56528. private static IsUASupportingBlobStorage;
  56529. /**
  56530. * Gets a boolean indicating if Database storate is enabled (off by default)
  56531. */
  56532. static IDBStorageEnabled: boolean;
  56533. /**
  56534. * Gets a boolean indicating if scene must be saved in the database
  56535. */
  56536. readonly enableSceneOffline: boolean;
  56537. /**
  56538. * Gets a boolean indicating if textures must be saved in the database
  56539. */
  56540. readonly enableTexturesOffline: boolean;
  56541. /**
  56542. * Creates a new Database
  56543. * @param urlToScene defines the url to load the scene
  56544. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56545. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56546. */
  56547. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56548. private static _ParseURL;
  56549. private static _ReturnFullUrlLocation;
  56550. private _checkManifestFile;
  56551. /**
  56552. * Open the database and make it available
  56553. * @param successCallback defines the callback to call on success
  56554. * @param errorCallback defines the callback to call on error
  56555. */
  56556. open(successCallback: () => void, errorCallback: () => void): void;
  56557. /**
  56558. * Loads an image from the database
  56559. * @param url defines the url to load from
  56560. * @param image defines the target DOM image
  56561. */
  56562. loadImage(url: string, image: HTMLImageElement): void;
  56563. private _loadImageFromDBAsync;
  56564. private _saveImageIntoDBAsync;
  56565. private _checkVersionFromDB;
  56566. private _loadVersionFromDBAsync;
  56567. private _saveVersionIntoDBAsync;
  56568. /**
  56569. * Loads a file from database
  56570. * @param url defines the URL to load from
  56571. * @param sceneLoaded defines a callback to call on success
  56572. * @param progressCallBack defines a callback to call when progress changed
  56573. * @param errorCallback defines a callback to call on error
  56574. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56575. */
  56576. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56577. private _loadFileAsync;
  56578. private _saveFileAsync;
  56579. /**
  56580. * Validates if xhr data is correct
  56581. * @param xhr defines the request to validate
  56582. * @param dataType defines the expected data type
  56583. * @returns true if data is correct
  56584. */
  56585. private static _ValidateXHRData;
  56586. }
  56587. }
  56588. declare module BABYLON {
  56589. /** @hidden */
  56590. export var gpuUpdateParticlesPixelShader: {
  56591. name: string;
  56592. shader: string;
  56593. };
  56594. }
  56595. declare module BABYLON {
  56596. /** @hidden */
  56597. export var gpuUpdateParticlesVertexShader: {
  56598. name: string;
  56599. shader: string;
  56600. };
  56601. }
  56602. declare module BABYLON {
  56603. /** @hidden */
  56604. export var clipPlaneFragmentDeclaration2: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module BABYLON {
  56610. /** @hidden */
  56611. export var gpuRenderParticlesPixelShader: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module BABYLON {
  56617. /** @hidden */
  56618. export var clipPlaneVertexDeclaration2: {
  56619. name: string;
  56620. shader: string;
  56621. };
  56622. }
  56623. declare module BABYLON {
  56624. /** @hidden */
  56625. export var gpuRenderParticlesVertexShader: {
  56626. name: string;
  56627. shader: string;
  56628. };
  56629. }
  56630. declare module BABYLON {
  56631. /**
  56632. * This represents a GPU particle system in Babylon
  56633. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56634. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56635. */
  56636. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56637. /**
  56638. * The layer mask we are rendering the particles through.
  56639. */
  56640. layerMask: number;
  56641. private _capacity;
  56642. private _activeCount;
  56643. private _currentActiveCount;
  56644. private _accumulatedCount;
  56645. private _renderEffect;
  56646. private _updateEffect;
  56647. private _buffer0;
  56648. private _buffer1;
  56649. private _spriteBuffer;
  56650. private _updateVAO;
  56651. private _renderVAO;
  56652. private _targetIndex;
  56653. private _sourceBuffer;
  56654. private _targetBuffer;
  56655. private _engine;
  56656. private _currentRenderId;
  56657. private _started;
  56658. private _stopped;
  56659. private _timeDelta;
  56660. private _randomTexture;
  56661. private _randomTexture2;
  56662. private _attributesStrideSize;
  56663. private _updateEffectOptions;
  56664. private _randomTextureSize;
  56665. private _actualFrame;
  56666. private readonly _rawTextureWidth;
  56667. /**
  56668. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56669. */
  56670. static readonly IsSupported: boolean;
  56671. /**
  56672. * An event triggered when the system is disposed.
  56673. */
  56674. onDisposeObservable: Observable<GPUParticleSystem>;
  56675. /**
  56676. * Gets the maximum number of particles active at the same time.
  56677. * @returns The max number of active particles.
  56678. */
  56679. getCapacity(): number;
  56680. /**
  56681. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56682. * to override the particles.
  56683. */
  56684. forceDepthWrite: boolean;
  56685. /**
  56686. * Gets or set the number of active particles
  56687. */
  56688. activeParticleCount: number;
  56689. private _preWarmDone;
  56690. /**
  56691. * Is this system ready to be used/rendered
  56692. * @return true if the system is ready
  56693. */
  56694. isReady(): boolean;
  56695. /**
  56696. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56697. * @returns True if it has been started, otherwise false.
  56698. */
  56699. isStarted(): boolean;
  56700. /**
  56701. * Starts the particle system and begins to emit
  56702. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56703. */
  56704. start(delay?: number): void;
  56705. /**
  56706. * Stops the particle system.
  56707. */
  56708. stop(): void;
  56709. /**
  56710. * Remove all active particles
  56711. */
  56712. reset(): void;
  56713. /**
  56714. * Returns the string "GPUParticleSystem"
  56715. * @returns a string containing the class name
  56716. */
  56717. getClassName(): string;
  56718. private _colorGradientsTexture;
  56719. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56720. /**
  56721. * Adds a new color gradient
  56722. * @param gradient defines the gradient to use (between 0 and 1)
  56723. * @param color1 defines the color to affect to the specified gradient
  56724. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56725. * @returns the current particle system
  56726. */
  56727. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56728. /**
  56729. * Remove a specific color gradient
  56730. * @param gradient defines the gradient to remove
  56731. * @returns the current particle system
  56732. */
  56733. removeColorGradient(gradient: number): GPUParticleSystem;
  56734. private _angularSpeedGradientsTexture;
  56735. private _sizeGradientsTexture;
  56736. private _velocityGradientsTexture;
  56737. private _limitVelocityGradientsTexture;
  56738. private _dragGradientsTexture;
  56739. private _addFactorGradient;
  56740. /**
  56741. * Adds a new size gradient
  56742. * @param gradient defines the gradient to use (between 0 and 1)
  56743. * @param factor defines the size factor to affect to the specified gradient
  56744. * @returns the current particle system
  56745. */
  56746. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56747. /**
  56748. * Remove a specific size gradient
  56749. * @param gradient defines the gradient to remove
  56750. * @returns the current particle system
  56751. */
  56752. removeSizeGradient(gradient: number): GPUParticleSystem;
  56753. /**
  56754. * Adds a new angular speed gradient
  56755. * @param gradient defines the gradient to use (between 0 and 1)
  56756. * @param factor defines the angular speed to affect to the specified gradient
  56757. * @returns the current particle system
  56758. */
  56759. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56760. /**
  56761. * Remove a specific angular speed gradient
  56762. * @param gradient defines the gradient to remove
  56763. * @returns the current particle system
  56764. */
  56765. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56766. /**
  56767. * Adds a new velocity gradient
  56768. * @param gradient defines the gradient to use (between 0 and 1)
  56769. * @param factor defines the velocity to affect to the specified gradient
  56770. * @returns the current particle system
  56771. */
  56772. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56773. /**
  56774. * Remove a specific velocity gradient
  56775. * @param gradient defines the gradient to remove
  56776. * @returns the current particle system
  56777. */
  56778. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56779. /**
  56780. * Adds a new limit velocity gradient
  56781. * @param gradient defines the gradient to use (between 0 and 1)
  56782. * @param factor defines the limit velocity value to affect to the specified gradient
  56783. * @returns the current particle system
  56784. */
  56785. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56786. /**
  56787. * Remove a specific limit velocity gradient
  56788. * @param gradient defines the gradient to remove
  56789. * @returns the current particle system
  56790. */
  56791. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56792. /**
  56793. * Adds a new drag gradient
  56794. * @param gradient defines the gradient to use (between 0 and 1)
  56795. * @param factor defines the drag value to affect to the specified gradient
  56796. * @returns the current particle system
  56797. */
  56798. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56799. /**
  56800. * Remove a specific drag gradient
  56801. * @param gradient defines the gradient to remove
  56802. * @returns the current particle system
  56803. */
  56804. removeDragGradient(gradient: number): GPUParticleSystem;
  56805. /**
  56806. * Not supported by GPUParticleSystem
  56807. * @param gradient defines the gradient to use (between 0 and 1)
  56808. * @param factor defines the emit rate value to affect to the specified gradient
  56809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56810. * @returns the current particle system
  56811. */
  56812. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56813. /**
  56814. * Not supported by GPUParticleSystem
  56815. * @param gradient defines the gradient to remove
  56816. * @returns the current particle system
  56817. */
  56818. removeEmitRateGradient(gradient: number): IParticleSystem;
  56819. /**
  56820. * Not supported by GPUParticleSystem
  56821. * @param gradient defines the gradient to use (between 0 and 1)
  56822. * @param factor defines the start size value to affect to the specified gradient
  56823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56824. * @returns the current particle system
  56825. */
  56826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56827. /**
  56828. * Not supported by GPUParticleSystem
  56829. * @param gradient defines the gradient to remove
  56830. * @returns the current particle system
  56831. */
  56832. removeStartSizeGradient(gradient: number): IParticleSystem;
  56833. /**
  56834. * Not supported by GPUParticleSystem
  56835. * @param gradient defines the gradient to use (between 0 and 1)
  56836. * @param min defines the color remap minimal range
  56837. * @param max defines the color remap maximal range
  56838. * @returns the current particle system
  56839. */
  56840. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56841. /**
  56842. * Not supported by GPUParticleSystem
  56843. * @param gradient defines the gradient to remove
  56844. * @returns the current particle system
  56845. */
  56846. removeColorRemapGradient(): IParticleSystem;
  56847. /**
  56848. * Not supported by GPUParticleSystem
  56849. * @param gradient defines the gradient to use (between 0 and 1)
  56850. * @param min defines the alpha remap minimal range
  56851. * @param max defines the alpha remap maximal range
  56852. * @returns the current particle system
  56853. */
  56854. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56855. /**
  56856. * Not supported by GPUParticleSystem
  56857. * @param gradient defines the gradient to remove
  56858. * @returns the current particle system
  56859. */
  56860. removeAlphaRemapGradient(): IParticleSystem;
  56861. /**
  56862. * Not supported by GPUParticleSystem
  56863. * @param gradient defines the gradient to use (between 0 and 1)
  56864. * @param color defines the color to affect to the specified gradient
  56865. * @returns the current particle system
  56866. */
  56867. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56868. /**
  56869. * Not supported by GPUParticleSystem
  56870. * @param gradient defines the gradient to remove
  56871. * @returns the current particle system
  56872. */
  56873. removeRampGradient(): IParticleSystem;
  56874. /**
  56875. * Not supported by GPUParticleSystem
  56876. * @returns the list of ramp gradients
  56877. */
  56878. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56879. /**
  56880. * Not supported by GPUParticleSystem
  56881. * Gets or sets a boolean indicating that ramp gradients must be used
  56882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56883. */
  56884. useRampGradients: boolean;
  56885. /**
  56886. * Not supported by GPUParticleSystem
  56887. * @param gradient defines the gradient to use (between 0 and 1)
  56888. * @param factor defines the life time factor to affect to the specified gradient
  56889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56890. * @returns the current particle system
  56891. */
  56892. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56893. /**
  56894. * Not supported by GPUParticleSystem
  56895. * @param gradient defines the gradient to remove
  56896. * @returns the current particle system
  56897. */
  56898. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56899. /**
  56900. * Instantiates a GPU particle system.
  56901. * 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.
  56902. * @param name The name of the particle system
  56903. * @param options The options used to create the system
  56904. * @param scene The scene the particle system belongs to
  56905. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56906. */
  56907. constructor(name: string, options: Partial<{
  56908. capacity: number;
  56909. randomTextureSize: number;
  56910. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56911. protected _reset(): void;
  56912. private _createUpdateVAO;
  56913. private _createRenderVAO;
  56914. private _initialize;
  56915. /** @hidden */
  56916. _recreateUpdateEffect(): void;
  56917. /** @hidden */
  56918. _recreateRenderEffect(): void;
  56919. /**
  56920. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56921. * @param preWarm defines if we are in the pre-warmimg phase
  56922. */
  56923. animate(preWarm?: boolean): void;
  56924. private _createFactorGradientTexture;
  56925. private _createSizeGradientTexture;
  56926. private _createAngularSpeedGradientTexture;
  56927. private _createVelocityGradientTexture;
  56928. private _createLimitVelocityGradientTexture;
  56929. private _createDragGradientTexture;
  56930. private _createColorGradientTexture;
  56931. /**
  56932. * Renders the particle system in its current state
  56933. * @param preWarm defines if the system should only update the particles but not render them
  56934. * @returns the current number of particles
  56935. */
  56936. render(preWarm?: boolean): number;
  56937. /**
  56938. * Rebuilds the particle system
  56939. */
  56940. rebuild(): void;
  56941. private _releaseBuffers;
  56942. private _releaseVAOs;
  56943. /**
  56944. * Disposes the particle system and free the associated resources
  56945. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56946. */
  56947. dispose(disposeTexture?: boolean): void;
  56948. /**
  56949. * Clones the particle system.
  56950. * @param name The name of the cloned object
  56951. * @param newEmitter The new emitter to use
  56952. * @returns the cloned particle system
  56953. */
  56954. clone(name: string, newEmitter: any): GPUParticleSystem;
  56955. /**
  56956. * Serializes the particle system to a JSON object.
  56957. * @returns the JSON object
  56958. */
  56959. serialize(): any;
  56960. /**
  56961. * Parses a JSON object to create a GPU particle system.
  56962. * @param parsedParticleSystem The JSON object to parse
  56963. * @param scene The scene to create the particle system in
  56964. * @param rootUrl The root url to use to load external dependencies like texture
  56965. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56966. * @returns the parsed GPU particle system
  56967. */
  56968. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * Represents a set of particle systems working together to create a specific effect
  56974. */
  56975. export class ParticleSystemSet implements IDisposable {
  56976. private _emitterCreationOptions;
  56977. private _emitterNode;
  56978. /**
  56979. * Gets the particle system list
  56980. */
  56981. systems: IParticleSystem[];
  56982. /**
  56983. * Gets the emitter node used with this set
  56984. */
  56985. readonly emitterNode: Nullable<TransformNode>;
  56986. /**
  56987. * Creates a new emitter mesh as a sphere
  56988. * @param options defines the options used to create the sphere
  56989. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56990. * @param scene defines the hosting scene
  56991. */
  56992. setEmitterAsSphere(options: {
  56993. diameter: number;
  56994. segments: number;
  56995. color: Color3;
  56996. }, renderingGroupId: number, scene: Scene): void;
  56997. /**
  56998. * Starts all particle systems of the set
  56999. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57000. */
  57001. start(emitter?: AbstractMesh): void;
  57002. /**
  57003. * Release all associated resources
  57004. */
  57005. dispose(): void;
  57006. /**
  57007. * Serialize the set into a JSON compatible object
  57008. * @returns a JSON compatible representation of the set
  57009. */
  57010. serialize(): any;
  57011. /**
  57012. * Parse a new ParticleSystemSet from a serialized source
  57013. * @param data defines a JSON compatible representation of the set
  57014. * @param scene defines the hosting scene
  57015. * @param gpu defines if we want GPU particles or CPU particles
  57016. * @returns a new ParticleSystemSet
  57017. */
  57018. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /**
  57023. * This class is made for on one-liner static method to help creating particle system set.
  57024. */
  57025. export class ParticleHelper {
  57026. /**
  57027. * Gets or sets base Assets URL
  57028. */
  57029. static BaseAssetsUrl: string;
  57030. /**
  57031. * Create a default particle system that you can tweak
  57032. * @param emitter defines the emitter to use
  57033. * @param capacity defines the system capacity (default is 500 particles)
  57034. * @param scene defines the hosting scene
  57035. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57036. * @returns the new Particle system
  57037. */
  57038. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57039. /**
  57040. * This is the main static method (one-liner) of this helper to create different particle systems
  57041. * @param type This string represents the type to the particle system to create
  57042. * @param scene The scene where the particle system should live
  57043. * @param gpu If the system will use gpu
  57044. * @returns the ParticleSystemSet created
  57045. */
  57046. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57047. /**
  57048. * Static function used to export a particle system to a ParticleSystemSet variable.
  57049. * Please note that the emitter shape is not exported
  57050. * @param systems defines the particle systems to export
  57051. * @returns the created particle system set
  57052. */
  57053. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57054. }
  57055. }
  57056. declare module BABYLON {
  57057. interface Engine {
  57058. /**
  57059. * Create an effect to use with particle systems.
  57060. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57061. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57062. * @param uniformsNames defines a list of attribute names
  57063. * @param samplers defines an array of string used to represent textures
  57064. * @param defines defines the string containing the defines to use to compile the shaders
  57065. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57066. * @param onCompiled defines a function to call when the effect creation is successful
  57067. * @param onError defines a function to call when the effect creation has failed
  57068. * @returns the new Effect
  57069. */
  57070. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57071. }
  57072. interface Mesh {
  57073. /**
  57074. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57075. * @returns an array of IParticleSystem
  57076. */
  57077. getEmittedParticleSystems(): IParticleSystem[];
  57078. /**
  57079. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57080. * @returns an array of IParticleSystem
  57081. */
  57082. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57083. }
  57084. /**
  57085. * @hidden
  57086. */
  57087. export var _IDoNeedToBeInTheBuild: number;
  57088. }
  57089. declare module BABYLON {
  57090. interface Scene {
  57091. /** @hidden (Backing field) */
  57092. _physicsEngine: Nullable<IPhysicsEngine>;
  57093. /**
  57094. * Gets the current physics engine
  57095. * @returns a IPhysicsEngine or null if none attached
  57096. */
  57097. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57098. /**
  57099. * Enables physics to the current scene
  57100. * @param gravity defines the scene's gravity for the physics engine
  57101. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57102. * @return a boolean indicating if the physics engine was initialized
  57103. */
  57104. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57105. /**
  57106. * Disables and disposes the physics engine associated with the scene
  57107. */
  57108. disablePhysicsEngine(): void;
  57109. /**
  57110. * Gets a boolean indicating if there is an active physics engine
  57111. * @returns a boolean indicating if there is an active physics engine
  57112. */
  57113. isPhysicsEnabled(): boolean;
  57114. /**
  57115. * Deletes a physics compound impostor
  57116. * @param compound defines the compound to delete
  57117. */
  57118. deleteCompoundImpostor(compound: any): void;
  57119. /**
  57120. * An event triggered when physic simulation is about to be run
  57121. */
  57122. onBeforePhysicsObservable: Observable<Scene>;
  57123. /**
  57124. * An event triggered when physic simulation has been done
  57125. */
  57126. onAfterPhysicsObservable: Observable<Scene>;
  57127. }
  57128. interface AbstractMesh {
  57129. /** @hidden */
  57130. _physicsImpostor: Nullable<PhysicsImpostor>;
  57131. /**
  57132. * Gets or sets impostor used for physic simulation
  57133. * @see http://doc.babylonjs.com/features/physics_engine
  57134. */
  57135. physicsImpostor: Nullable<PhysicsImpostor>;
  57136. /**
  57137. * Gets the current physics impostor
  57138. * @see http://doc.babylonjs.com/features/physics_engine
  57139. * @returns a physics impostor or null
  57140. */
  57141. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57142. /** Apply a physic impulse to the mesh
  57143. * @param force defines the force to apply
  57144. * @param contactPoint defines where to apply the force
  57145. * @returns the current mesh
  57146. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57147. */
  57148. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57149. /**
  57150. * Creates a physic joint between two meshes
  57151. * @param otherMesh defines the other mesh to use
  57152. * @param pivot1 defines the pivot to use on this mesh
  57153. * @param pivot2 defines the pivot to use on the other mesh
  57154. * @param options defines additional options (can be plugin dependent)
  57155. * @returns the current mesh
  57156. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57157. */
  57158. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57159. /** @hidden */
  57160. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57161. }
  57162. /**
  57163. * Defines the physics engine scene component responsible to manage a physics engine
  57164. */
  57165. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57166. /**
  57167. * The component name helpful to identify the component in the list of scene components.
  57168. */
  57169. readonly name: string;
  57170. /**
  57171. * The scene the component belongs to.
  57172. */
  57173. scene: Scene;
  57174. /**
  57175. * Creates a new instance of the component for the given scene
  57176. * @param scene Defines the scene to register the component in
  57177. */
  57178. constructor(scene: Scene);
  57179. /**
  57180. * Registers the component in a given scene
  57181. */
  57182. register(): void;
  57183. /**
  57184. * Rebuilds the elements related to this component in case of
  57185. * context lost for instance.
  57186. */
  57187. rebuild(): void;
  57188. /**
  57189. * Disposes the component and the associated ressources
  57190. */
  57191. dispose(): void;
  57192. }
  57193. }
  57194. declare module BABYLON {
  57195. /**
  57196. * A helper for physics simulations
  57197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57198. */
  57199. export class PhysicsHelper {
  57200. private _scene;
  57201. private _physicsEngine;
  57202. /**
  57203. * Initializes the Physics helper
  57204. * @param scene Babylon.js scene
  57205. */
  57206. constructor(scene: Scene);
  57207. /**
  57208. * Applies a radial explosion impulse
  57209. * @param origin the origin of the explosion
  57210. * @param radiusOrEventOptions the radius or the options of radial explosion
  57211. * @param strength the explosion strength
  57212. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57213. * @returns A physics radial explosion event, or null
  57214. */
  57215. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57216. /**
  57217. * Applies a radial explosion force
  57218. * @param origin the origin of the explosion
  57219. * @param radiusOrEventOptions the radius or the options of radial explosion
  57220. * @param strength the explosion strength
  57221. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57222. * @returns A physics radial explosion event, or null
  57223. */
  57224. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57225. /**
  57226. * Creates a gravitational field
  57227. * @param origin the origin of the explosion
  57228. * @param radiusOrEventOptions the radius or the options of radial explosion
  57229. * @param strength the explosion strength
  57230. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57231. * @returns A physics gravitational field event, or null
  57232. */
  57233. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57234. /**
  57235. * Creates a physics updraft event
  57236. * @param origin the origin of the updraft
  57237. * @param radiusOrEventOptions the radius or the options of the updraft
  57238. * @param strength the strength of the updraft
  57239. * @param height the height of the updraft
  57240. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57241. * @returns A physics updraft event, or null
  57242. */
  57243. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57244. /**
  57245. * Creates a physics vortex event
  57246. * @param origin the of the vortex
  57247. * @param radiusOrEventOptions the radius or the options of the vortex
  57248. * @param strength the strength of the vortex
  57249. * @param height the height of the vortex
  57250. * @returns a Physics vortex event, or null
  57251. * A physics vortex event or null
  57252. */
  57253. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57254. }
  57255. /**
  57256. * Represents a physics radial explosion event
  57257. */
  57258. class PhysicsRadialExplosionEvent {
  57259. private _scene;
  57260. private _options;
  57261. private _sphere;
  57262. private _dataFetched;
  57263. /**
  57264. * Initializes a radial explosioin event
  57265. * @param _scene BabylonJS scene
  57266. * @param _options The options for the vortex event
  57267. */
  57268. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57269. /**
  57270. * Returns the data related to the radial explosion event (sphere).
  57271. * @returns The radial explosion event data
  57272. */
  57273. getData(): PhysicsRadialExplosionEventData;
  57274. /**
  57275. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57276. * @param impostor A physics imposter
  57277. * @param origin the origin of the explosion
  57278. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57279. */
  57280. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57281. /**
  57282. * Triggers affecterd impostors callbacks
  57283. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57284. */
  57285. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57286. /**
  57287. * Disposes the sphere.
  57288. * @param force Specifies if the sphere should be disposed by force
  57289. */
  57290. dispose(force?: boolean): void;
  57291. /*** Helpers ***/
  57292. private _prepareSphere;
  57293. private _intersectsWithSphere;
  57294. }
  57295. /**
  57296. * Represents a gravitational field event
  57297. */
  57298. class PhysicsGravitationalFieldEvent {
  57299. private _physicsHelper;
  57300. private _scene;
  57301. private _origin;
  57302. private _options;
  57303. private _tickCallback;
  57304. private _sphere;
  57305. private _dataFetched;
  57306. /**
  57307. * Initializes the physics gravitational field event
  57308. * @param _physicsHelper A physics helper
  57309. * @param _scene BabylonJS scene
  57310. * @param _origin The origin position of the gravitational field event
  57311. * @param _options The options for the vortex event
  57312. */
  57313. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57314. /**
  57315. * Returns the data related to the gravitational field event (sphere).
  57316. * @returns A gravitational field event
  57317. */
  57318. getData(): PhysicsGravitationalFieldEventData;
  57319. /**
  57320. * Enables the gravitational field.
  57321. */
  57322. enable(): void;
  57323. /**
  57324. * Disables the gravitational field.
  57325. */
  57326. disable(): void;
  57327. /**
  57328. * Disposes the sphere.
  57329. * @param force The force to dispose from the gravitational field event
  57330. */
  57331. dispose(force?: boolean): void;
  57332. private _tick;
  57333. }
  57334. /**
  57335. * Represents a physics updraft event
  57336. */
  57337. class PhysicsUpdraftEvent {
  57338. private _scene;
  57339. private _origin;
  57340. private _options;
  57341. private _physicsEngine;
  57342. private _originTop;
  57343. private _originDirection;
  57344. private _tickCallback;
  57345. private _cylinder;
  57346. private _cylinderPosition;
  57347. private _dataFetched;
  57348. /**
  57349. * Initializes the physics updraft event
  57350. * @param _scene BabylonJS scene
  57351. * @param _origin The origin position of the updraft
  57352. * @param _options The options for the updraft event
  57353. */
  57354. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57355. /**
  57356. * Returns the data related to the updraft event (cylinder).
  57357. * @returns A physics updraft event
  57358. */
  57359. getData(): PhysicsUpdraftEventData;
  57360. /**
  57361. * Enables the updraft.
  57362. */
  57363. enable(): void;
  57364. /**
  57365. * Disables the updraft.
  57366. */
  57367. disable(): void;
  57368. /**
  57369. * Disposes the cylinder.
  57370. * @param force Specifies if the updraft should be disposed by force
  57371. */
  57372. dispose(force?: boolean): void;
  57373. private getImpostorHitData;
  57374. private _tick;
  57375. /*** Helpers ***/
  57376. private _prepareCylinder;
  57377. private _intersectsWithCylinder;
  57378. }
  57379. /**
  57380. * Represents a physics vortex event
  57381. */
  57382. class PhysicsVortexEvent {
  57383. private _scene;
  57384. private _origin;
  57385. private _options;
  57386. private _physicsEngine;
  57387. private _originTop;
  57388. private _tickCallback;
  57389. private _cylinder;
  57390. private _cylinderPosition;
  57391. private _dataFetched;
  57392. /**
  57393. * Initializes the physics vortex event
  57394. * @param _scene The BabylonJS scene
  57395. * @param _origin The origin position of the vortex
  57396. * @param _options The options for the vortex event
  57397. */
  57398. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57399. /**
  57400. * Returns the data related to the vortex event (cylinder).
  57401. * @returns The physics vortex event data
  57402. */
  57403. getData(): PhysicsVortexEventData;
  57404. /**
  57405. * Enables the vortex.
  57406. */
  57407. enable(): void;
  57408. /**
  57409. * Disables the cortex.
  57410. */
  57411. disable(): void;
  57412. /**
  57413. * Disposes the sphere.
  57414. * @param force
  57415. */
  57416. dispose(force?: boolean): void;
  57417. private getImpostorHitData;
  57418. private _tick;
  57419. /*** Helpers ***/
  57420. private _prepareCylinder;
  57421. private _intersectsWithCylinder;
  57422. }
  57423. /**
  57424. * Options fot the radial explosion event
  57425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57426. */
  57427. export class PhysicsRadialExplosionEventOptions {
  57428. /**
  57429. * The radius of the sphere for the radial explosion.
  57430. */
  57431. radius: number;
  57432. /**
  57433. * The strenth of the explosion.
  57434. */
  57435. strength: number;
  57436. /**
  57437. * The strenght of the force in correspondence to the distance of the affected object
  57438. */
  57439. falloff: PhysicsRadialImpulseFalloff;
  57440. /**
  57441. * Sphere options for the radial explosion.
  57442. */
  57443. sphere: {
  57444. segments: number;
  57445. diameter: number;
  57446. };
  57447. /**
  57448. * Sphere options for the radial explosion.
  57449. */
  57450. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57451. }
  57452. /**
  57453. * Options fot the updraft event
  57454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57455. */
  57456. export class PhysicsUpdraftEventOptions {
  57457. /**
  57458. * The radius of the cylinder for the vortex
  57459. */
  57460. radius: number;
  57461. /**
  57462. * The strenth of the updraft.
  57463. */
  57464. strength: number;
  57465. /**
  57466. * The height of the cylinder for the updraft.
  57467. */
  57468. height: number;
  57469. /**
  57470. * The mode for the the updraft.
  57471. */
  57472. updraftMode: PhysicsUpdraftMode;
  57473. }
  57474. /**
  57475. * Options fot the vortex event
  57476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57477. */
  57478. export class PhysicsVortexEventOptions {
  57479. /**
  57480. * The radius of the cylinder for the vortex
  57481. */
  57482. radius: number;
  57483. /**
  57484. * The strenth of the vortex.
  57485. */
  57486. strength: number;
  57487. /**
  57488. * The height of the cylinder for the vortex.
  57489. */
  57490. height: number;
  57491. /**
  57492. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57493. */
  57494. centripetalForceThreshold: number;
  57495. /**
  57496. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57497. */
  57498. centripetalForceMultiplier: number;
  57499. /**
  57500. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57501. */
  57502. centrifugalForceMultiplier: number;
  57503. /**
  57504. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57505. */
  57506. updraftForceMultiplier: number;
  57507. }
  57508. /**
  57509. * The strenght of the force in correspondence to the distance of the affected object
  57510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57511. */
  57512. export enum PhysicsRadialImpulseFalloff {
  57513. /** Defines that impulse is constant in strength across it's whole radius */
  57514. Constant = 0,
  57515. /** Defines that impulse gets weaker if it's further from the origin */
  57516. Linear = 1
  57517. }
  57518. /**
  57519. * The strength of the force in correspondence to the distance of the affected object
  57520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57521. */
  57522. export enum PhysicsUpdraftMode {
  57523. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57524. Center = 0,
  57525. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57526. Perpendicular = 1
  57527. }
  57528. /**
  57529. * Interface for a physics hit data
  57530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57531. */
  57532. export interface PhysicsHitData {
  57533. /**
  57534. * The force applied at the contact point
  57535. */
  57536. force: Vector3;
  57537. /**
  57538. * The contact point
  57539. */
  57540. contactPoint: Vector3;
  57541. /**
  57542. * The distance from the origin to the contact point
  57543. */
  57544. distanceFromOrigin: number;
  57545. }
  57546. /**
  57547. * Interface for radial explosion event data
  57548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57549. */
  57550. export interface PhysicsRadialExplosionEventData {
  57551. /**
  57552. * A sphere used for the radial explosion event
  57553. */
  57554. sphere: Mesh;
  57555. }
  57556. /**
  57557. * Interface for gravitational field event data
  57558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57559. */
  57560. export interface PhysicsGravitationalFieldEventData {
  57561. /**
  57562. * A sphere mesh used for the gravitational field event
  57563. */
  57564. sphere: Mesh;
  57565. }
  57566. /**
  57567. * Interface for updraft event data
  57568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57569. */
  57570. export interface PhysicsUpdraftEventData {
  57571. /**
  57572. * A cylinder used for the updraft event
  57573. */
  57574. cylinder: Mesh;
  57575. }
  57576. /**
  57577. * Interface for vortex event data
  57578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57579. */
  57580. export interface PhysicsVortexEventData {
  57581. /**
  57582. * A cylinder used for the vortex event
  57583. */
  57584. cylinder: Mesh;
  57585. }
  57586. /**
  57587. * Interface for an affected physics impostor
  57588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57589. */
  57590. export interface PhysicsAffectedImpostorWithData {
  57591. /**
  57592. * The impostor affected by the effect
  57593. */
  57594. impostor: PhysicsImpostor;
  57595. /**
  57596. * The data about the hit/horce from the explosion
  57597. */
  57598. hitData: PhysicsHitData;
  57599. }
  57600. }
  57601. declare module BABYLON {
  57602. /** @hidden */
  57603. export var blackAndWhitePixelShader: {
  57604. name: string;
  57605. shader: string;
  57606. };
  57607. }
  57608. declare module BABYLON {
  57609. /**
  57610. * Post process used to render in black and white
  57611. */
  57612. export class BlackAndWhitePostProcess extends PostProcess {
  57613. /**
  57614. * Linear about to convert he result to black and white (default: 1)
  57615. */
  57616. degree: number;
  57617. /**
  57618. * Creates a black and white post process
  57619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57620. * @param name The name of the effect.
  57621. * @param options The required width/height ratio to downsize to before computing the render pass.
  57622. * @param camera The camera to apply the render pass to.
  57623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57624. * @param engine The engine which the post process will be applied. (default: current engine)
  57625. * @param reusable If the post process can be reused on the same frame. (default: false)
  57626. */
  57627. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57628. }
  57629. }
  57630. declare module BABYLON {
  57631. /**
  57632. * This represents a set of one or more post processes in Babylon.
  57633. * A post process can be used to apply a shader to a texture after it is rendered.
  57634. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57635. */
  57636. export class PostProcessRenderEffect {
  57637. private _postProcesses;
  57638. private _getPostProcesses;
  57639. private _singleInstance;
  57640. private _cameras;
  57641. private _indicesForCamera;
  57642. /**
  57643. * Name of the effect
  57644. * @hidden
  57645. */
  57646. _name: string;
  57647. /**
  57648. * Instantiates a post process render effect.
  57649. * A post process can be used to apply a shader to a texture after it is rendered.
  57650. * @param engine The engine the effect is tied to
  57651. * @param name The name of the effect
  57652. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57653. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57654. */
  57655. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57656. /**
  57657. * Checks if all the post processes in the effect are supported.
  57658. */
  57659. readonly isSupported: boolean;
  57660. /**
  57661. * Updates the current state of the effect
  57662. * @hidden
  57663. */
  57664. _update(): void;
  57665. /**
  57666. * Attaches the effect on cameras
  57667. * @param cameras The camera to attach to.
  57668. * @hidden
  57669. */
  57670. _attachCameras(cameras: Camera): void;
  57671. /**
  57672. * Attaches the effect on cameras
  57673. * @param cameras The camera to attach to.
  57674. * @hidden
  57675. */
  57676. _attachCameras(cameras: Camera[]): void;
  57677. /**
  57678. * Detaches the effect on cameras
  57679. * @param cameras The camera to detatch from.
  57680. * @hidden
  57681. */
  57682. _detachCameras(cameras: Camera): void;
  57683. /**
  57684. * Detatches the effect on cameras
  57685. * @param cameras The camera to detatch from.
  57686. * @hidden
  57687. */
  57688. _detachCameras(cameras: Camera[]): void;
  57689. /**
  57690. * Enables the effect on given cameras
  57691. * @param cameras The camera to enable.
  57692. * @hidden
  57693. */
  57694. _enable(cameras: Camera): void;
  57695. /**
  57696. * Enables the effect on given cameras
  57697. * @param cameras The camera to enable.
  57698. * @hidden
  57699. */
  57700. _enable(cameras: Nullable<Camera[]>): void;
  57701. /**
  57702. * Disables the effect on the given cameras
  57703. * @param cameras The camera to disable.
  57704. * @hidden
  57705. */
  57706. _disable(cameras: Camera): void;
  57707. /**
  57708. * Disables the effect on the given cameras
  57709. * @param cameras The camera to disable.
  57710. * @hidden
  57711. */
  57712. _disable(cameras: Nullable<Camera[]>): void;
  57713. /**
  57714. * Gets a list of the post processes contained in the effect.
  57715. * @param camera The camera to get the post processes on.
  57716. * @returns The list of the post processes in the effect.
  57717. */
  57718. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57719. }
  57720. }
  57721. declare module BABYLON {
  57722. /** @hidden */
  57723. export var extractHighlightsPixelShader: {
  57724. name: string;
  57725. shader: string;
  57726. };
  57727. }
  57728. declare module BABYLON {
  57729. /**
  57730. * 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.
  57731. */
  57732. export class ExtractHighlightsPostProcess extends PostProcess {
  57733. /**
  57734. * The luminance threshold, pixels below this value will be set to black.
  57735. */
  57736. threshold: number;
  57737. /** @hidden */
  57738. _exposure: number;
  57739. /**
  57740. * Post process which has the input texture to be used when performing highlight extraction
  57741. * @hidden
  57742. */
  57743. _inputPostProcess: Nullable<PostProcess>;
  57744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57745. }
  57746. }
  57747. declare module BABYLON {
  57748. /** @hidden */
  57749. export var bloomMergePixelShader: {
  57750. name: string;
  57751. shader: string;
  57752. };
  57753. }
  57754. declare module BABYLON {
  57755. /**
  57756. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57757. */
  57758. export class BloomMergePostProcess extends PostProcess {
  57759. /** Weight of the bloom to be added to the original input. */
  57760. weight: number;
  57761. /**
  57762. * Creates a new instance of @see BloomMergePostProcess
  57763. * @param name The name of the effect.
  57764. * @param originalFromInput Post process which's input will be used for the merge.
  57765. * @param blurred Blurred highlights post process which's output will be used.
  57766. * @param weight Weight of the bloom to be added to the original input.
  57767. * @param options The required width/height ratio to downsize to before computing the render pass.
  57768. * @param camera The camera to apply the render pass to.
  57769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57770. * @param engine The engine which the post process will be applied. (default: current engine)
  57771. * @param reusable If the post process can be reused on the same frame. (default: false)
  57772. * @param textureType Type of textures used when performing the post process. (default: 0)
  57773. * @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)
  57774. */
  57775. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57776. /** Weight of the bloom to be added to the original input. */
  57777. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57778. }
  57779. }
  57780. declare module BABYLON {
  57781. /**
  57782. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57783. */
  57784. export class BloomEffect extends PostProcessRenderEffect {
  57785. private bloomScale;
  57786. /**
  57787. * @hidden Internal
  57788. */
  57789. _effects: Array<PostProcess>;
  57790. /**
  57791. * @hidden Internal
  57792. */
  57793. _downscale: ExtractHighlightsPostProcess;
  57794. private _blurX;
  57795. private _blurY;
  57796. private _merge;
  57797. /**
  57798. * The luminance threshold to find bright areas of the image to bloom.
  57799. */
  57800. threshold: number;
  57801. /**
  57802. * The strength of the bloom.
  57803. */
  57804. weight: number;
  57805. /**
  57806. * Specifies the size of the bloom blur kernel, relative to the final output size
  57807. */
  57808. kernel: number;
  57809. /**
  57810. * Creates a new instance of @see BloomEffect
  57811. * @param scene The scene the effect belongs to.
  57812. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57813. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57814. * @param bloomWeight The the strength of bloom.
  57815. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57816. * @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)
  57817. */
  57818. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57819. /**
  57820. * Disposes each of the internal effects for a given camera.
  57821. * @param camera The camera to dispose the effect on.
  57822. */
  57823. disposeEffects(camera: Camera): void;
  57824. /**
  57825. * @hidden Internal
  57826. */
  57827. _updateEffects(): void;
  57828. /**
  57829. * Internal
  57830. * @returns if all the contained post processes are ready.
  57831. * @hidden
  57832. */
  57833. _isReady(): boolean;
  57834. }
  57835. }
  57836. declare module BABYLON {
  57837. /** @hidden */
  57838. export var chromaticAberrationPixelShader: {
  57839. name: string;
  57840. shader: string;
  57841. };
  57842. }
  57843. declare module BABYLON {
  57844. /**
  57845. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57846. */
  57847. export class ChromaticAberrationPostProcess extends PostProcess {
  57848. /**
  57849. * The amount of seperation of rgb channels (default: 30)
  57850. */
  57851. aberrationAmount: number;
  57852. /**
  57853. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57854. */
  57855. radialIntensity: number;
  57856. /**
  57857. * 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))
  57858. */
  57859. direction: Vector2;
  57860. /**
  57861. * 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))
  57862. */
  57863. centerPosition: Vector2;
  57864. /**
  57865. * Creates a new instance ChromaticAberrationPostProcess
  57866. * @param name The name of the effect.
  57867. * @param screenWidth The width of the screen to apply the effect on.
  57868. * @param screenHeight The height of the screen to apply the effect on.
  57869. * @param options The required width/height ratio to downsize to before computing the render pass.
  57870. * @param camera The camera to apply the render pass to.
  57871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57872. * @param engine The engine which the post process will be applied. (default: current engine)
  57873. * @param reusable If the post process can be reused on the same frame. (default: false)
  57874. * @param textureType Type of textures used when performing the post process. (default: 0)
  57875. * @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)
  57876. */
  57877. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57878. }
  57879. }
  57880. declare module BABYLON {
  57881. /** @hidden */
  57882. export var circleOfConfusionPixelShader: {
  57883. name: string;
  57884. shader: string;
  57885. };
  57886. }
  57887. declare module BABYLON {
  57888. /**
  57889. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57890. */
  57891. export class CircleOfConfusionPostProcess extends PostProcess {
  57892. /**
  57893. * 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.
  57894. */
  57895. lensSize: number;
  57896. /**
  57897. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57898. */
  57899. fStop: number;
  57900. /**
  57901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57902. */
  57903. focusDistance: number;
  57904. /**
  57905. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57906. */
  57907. focalLength: number;
  57908. private _depthTexture;
  57909. /**
  57910. * Creates a new instance CircleOfConfusionPostProcess
  57911. * @param name The name of the effect.
  57912. * @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.
  57913. * @param options The required width/height ratio to downsize to before computing the render pass.
  57914. * @param camera The camera to apply the render pass to.
  57915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57916. * @param engine The engine which the post process will be applied. (default: current engine)
  57917. * @param reusable If the post process can be reused on the same frame. (default: false)
  57918. * @param textureType Type of textures used when performing the post process. (default: 0)
  57919. * @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)
  57920. */
  57921. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57922. /**
  57923. * 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.
  57924. */
  57925. depthTexture: RenderTargetTexture;
  57926. }
  57927. }
  57928. declare module BABYLON {
  57929. /** @hidden */
  57930. export var colorCorrectionPixelShader: {
  57931. name: string;
  57932. shader: string;
  57933. };
  57934. }
  57935. declare module BABYLON {
  57936. /**
  57937. *
  57938. * This post-process allows the modification of rendered colors by using
  57939. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57940. *
  57941. * The object needs to be provided an url to a texture containing the color
  57942. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57943. * Use an image editing software to tweak the LUT to match your needs.
  57944. *
  57945. * For an example of a color LUT, see here:
  57946. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57947. * For explanations on color grading, see here:
  57948. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57949. *
  57950. */
  57951. export class ColorCorrectionPostProcess extends PostProcess {
  57952. private _colorTableTexture;
  57953. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57954. }
  57955. }
  57956. declare module BABYLON {
  57957. /** @hidden */
  57958. export var convolutionPixelShader: {
  57959. name: string;
  57960. shader: string;
  57961. };
  57962. }
  57963. declare module BABYLON {
  57964. /**
  57965. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57966. * input texture to perform effects such as edge detection or sharpening
  57967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57968. */
  57969. export class ConvolutionPostProcess extends PostProcess {
  57970. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57971. kernel: number[];
  57972. /**
  57973. * Creates a new instance ConvolutionPostProcess
  57974. * @param name The name of the effect.
  57975. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57976. * @param options The required width/height ratio to downsize to before computing the render pass.
  57977. * @param camera The camera to apply the render pass to.
  57978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57979. * @param engine The engine which the post process will be applied. (default: current engine)
  57980. * @param reusable If the post process can be reused on the same frame. (default: false)
  57981. * @param textureType Type of textures used when performing the post process. (default: 0)
  57982. */
  57983. constructor(name: string,
  57984. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57985. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57986. /**
  57987. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57988. */
  57989. static EdgeDetect0Kernel: number[];
  57990. /**
  57991. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57992. */
  57993. static EdgeDetect1Kernel: number[];
  57994. /**
  57995. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57996. */
  57997. static EdgeDetect2Kernel: number[];
  57998. /**
  57999. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58000. */
  58001. static SharpenKernel: number[];
  58002. /**
  58003. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58004. */
  58005. static EmbossKernel: number[];
  58006. /**
  58007. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58008. */
  58009. static GaussianKernel: number[];
  58010. }
  58011. }
  58012. declare module BABYLON {
  58013. /**
  58014. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58015. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58016. * based on samples that have a large difference in distance than the center pixel.
  58017. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58018. */
  58019. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58020. direction: Vector2;
  58021. /**
  58022. * Creates a new instance CircleOfConfusionPostProcess
  58023. * @param name The name of the effect.
  58024. * @param scene The scene the effect belongs to.
  58025. * @param direction The direction the blur should be applied.
  58026. * @param kernel The size of the kernel used to blur.
  58027. * @param options The required width/height ratio to downsize to before computing the render pass.
  58028. * @param camera The camera to apply the render pass to.
  58029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58032. * @param engine The engine which the post process will be applied. (default: current engine)
  58033. * @param reusable If the post process can be reused on the same frame. (default: false)
  58034. * @param textureType Type of textures used when performing the post process. (default: 0)
  58035. * @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)
  58036. */
  58037. 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);
  58038. }
  58039. }
  58040. declare module BABYLON {
  58041. /** @hidden */
  58042. export var depthOfFieldMergePixelShader: {
  58043. name: string;
  58044. shader: string;
  58045. };
  58046. }
  58047. declare module BABYLON {
  58048. /**
  58049. * Options to be set when merging outputs from the default pipeline.
  58050. */
  58051. export class DepthOfFieldMergePostProcessOptions {
  58052. /**
  58053. * The original image to merge on top of
  58054. */
  58055. originalFromInput: PostProcess;
  58056. /**
  58057. * Parameters to perform the merge of the depth of field effect
  58058. */
  58059. depthOfField?: {
  58060. circleOfConfusion: PostProcess;
  58061. blurSteps: Array<PostProcess>;
  58062. };
  58063. /**
  58064. * Parameters to perform the merge of bloom effect
  58065. */
  58066. bloom?: {
  58067. blurred: PostProcess;
  58068. weight: number;
  58069. };
  58070. }
  58071. /**
  58072. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58073. */
  58074. export class DepthOfFieldMergePostProcess extends PostProcess {
  58075. private blurSteps;
  58076. /**
  58077. * Creates a new instance of DepthOfFieldMergePostProcess
  58078. * @param name The name of the effect.
  58079. * @param originalFromInput Post process which's input will be used for the merge.
  58080. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58081. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58082. * @param options The required width/height ratio to downsize to before computing the render pass.
  58083. * @param camera The camera to apply the render pass to.
  58084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58085. * @param engine The engine which the post process will be applied. (default: current engine)
  58086. * @param reusable If the post process can be reused on the same frame. (default: false)
  58087. * @param textureType Type of textures used when performing the post process. (default: 0)
  58088. * @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)
  58089. */
  58090. 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);
  58091. /**
  58092. * Updates the effect with the current post process compile time values and recompiles the shader.
  58093. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58094. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58095. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58096. * @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
  58097. * @param onCompiled Called when the shader has been compiled.
  58098. * @param onError Called if there is an error when compiling a shader.
  58099. */
  58100. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58101. }
  58102. }
  58103. declare module BABYLON {
  58104. /**
  58105. * Specifies the level of max blur that should be applied when using the depth of field effect
  58106. */
  58107. export enum DepthOfFieldEffectBlurLevel {
  58108. /**
  58109. * Subtle blur
  58110. */
  58111. Low = 0,
  58112. /**
  58113. * Medium blur
  58114. */
  58115. Medium = 1,
  58116. /**
  58117. * Large blur
  58118. */
  58119. High = 2
  58120. }
  58121. /**
  58122. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58123. */
  58124. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58125. private _circleOfConfusion;
  58126. /**
  58127. * @hidden Internal, blurs from high to low
  58128. */
  58129. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58130. private _depthOfFieldBlurY;
  58131. private _dofMerge;
  58132. /**
  58133. * @hidden Internal post processes in depth of field effect
  58134. */
  58135. _effects: Array<PostProcess>;
  58136. /**
  58137. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58138. */
  58139. focalLength: number;
  58140. /**
  58141. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58142. */
  58143. fStop: number;
  58144. /**
  58145. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58146. */
  58147. focusDistance: number;
  58148. /**
  58149. * 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.
  58150. */
  58151. lensSize: number;
  58152. /**
  58153. * Creates a new instance DepthOfFieldEffect
  58154. * @param scene The scene the effect belongs to.
  58155. * @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.
  58156. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58157. * @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)
  58158. */
  58159. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58160. /**
  58161. * Get the current class name of the current effet
  58162. * @returns "DepthOfFieldEffect"
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * 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.
  58167. */
  58168. depthTexture: RenderTargetTexture;
  58169. /**
  58170. * Disposes each of the internal effects for a given camera.
  58171. * @param camera The camera to dispose the effect on.
  58172. */
  58173. disposeEffects(camera: Camera): void;
  58174. /**
  58175. * @hidden Internal
  58176. */
  58177. _updateEffects(): void;
  58178. /**
  58179. * Internal
  58180. * @returns if all the contained post processes are ready.
  58181. * @hidden
  58182. */
  58183. _isReady(): boolean;
  58184. }
  58185. }
  58186. declare module BABYLON {
  58187. /** @hidden */
  58188. export var displayPassPixelShader: {
  58189. name: string;
  58190. shader: string;
  58191. };
  58192. }
  58193. declare module BABYLON {
  58194. /**
  58195. * DisplayPassPostProcess which produces an output the same as it's input
  58196. */
  58197. export class DisplayPassPostProcess extends PostProcess {
  58198. /**
  58199. * Creates the DisplayPassPostProcess
  58200. * @param name The name of the effect.
  58201. * @param options The required width/height ratio to downsize to before computing the render pass.
  58202. * @param camera The camera to apply the render pass to.
  58203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58204. * @param engine The engine which the post process will be applied. (default: current engine)
  58205. * @param reusable If the post process can be reused on the same frame. (default: false)
  58206. */
  58207. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58208. }
  58209. }
  58210. declare module BABYLON {
  58211. /** @hidden */
  58212. export var filterPixelShader: {
  58213. name: string;
  58214. shader: string;
  58215. };
  58216. }
  58217. declare module BABYLON {
  58218. /**
  58219. * Applies a kernel filter to the image
  58220. */
  58221. export class FilterPostProcess extends PostProcess {
  58222. /** The matrix to be applied to the image */
  58223. kernelMatrix: Matrix;
  58224. /**
  58225. *
  58226. * @param name The name of the effect.
  58227. * @param kernelMatrix The matrix to be applied to the image
  58228. * @param options The required width/height ratio to downsize to before computing the render pass.
  58229. * @param camera The camera to apply the render pass to.
  58230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58231. * @param engine The engine which the post process will be applied. (default: current engine)
  58232. * @param reusable If the post process can be reused on the same frame. (default: false)
  58233. */
  58234. constructor(name: string,
  58235. /** The matrix to be applied to the image */
  58236. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58237. }
  58238. }
  58239. declare module BABYLON {
  58240. /** @hidden */
  58241. export var fxaaPixelShader: {
  58242. name: string;
  58243. shader: string;
  58244. };
  58245. }
  58246. declare module BABYLON {
  58247. /** @hidden */
  58248. export var fxaaVertexShader: {
  58249. name: string;
  58250. shader: string;
  58251. };
  58252. }
  58253. declare module BABYLON {
  58254. /**
  58255. * Fxaa post process
  58256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58257. */
  58258. export class FxaaPostProcess extends PostProcess {
  58259. /** @hidden */
  58260. texelWidth: number;
  58261. /** @hidden */
  58262. texelHeight: number;
  58263. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58264. private _getDefines;
  58265. }
  58266. }
  58267. declare module BABYLON {
  58268. /** @hidden */
  58269. export var grainPixelShader: {
  58270. name: string;
  58271. shader: string;
  58272. };
  58273. }
  58274. declare module BABYLON {
  58275. /**
  58276. * The GrainPostProcess adds noise to the image at mid luminance levels
  58277. */
  58278. export class GrainPostProcess extends PostProcess {
  58279. /**
  58280. * The intensity of the grain added (default: 30)
  58281. */
  58282. intensity: number;
  58283. /**
  58284. * If the grain should be randomized on every frame
  58285. */
  58286. animated: boolean;
  58287. /**
  58288. * Creates a new instance of @see GrainPostProcess
  58289. * @param name The name of the effect.
  58290. * @param options The required width/height ratio to downsize to before computing the render pass.
  58291. * @param camera The camera to apply the render pass to.
  58292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58293. * @param engine The engine which the post process will be applied. (default: current engine)
  58294. * @param reusable If the post process can be reused on the same frame. (default: false)
  58295. * @param textureType Type of textures used when performing the post process. (default: 0)
  58296. * @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)
  58297. */
  58298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58299. }
  58300. }
  58301. declare module BABYLON {
  58302. /** @hidden */
  58303. export var highlightsPixelShader: {
  58304. name: string;
  58305. shader: string;
  58306. };
  58307. }
  58308. declare module BABYLON {
  58309. /**
  58310. * Extracts highlights from the image
  58311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58312. */
  58313. export class HighlightsPostProcess extends PostProcess {
  58314. /**
  58315. * Extracts highlights from the image
  58316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58317. * @param name The name of the effect.
  58318. * @param options The required width/height ratio to downsize to before computing the render pass.
  58319. * @param camera The camera to apply the render pass to.
  58320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58321. * @param engine The engine which the post process will be applied. (default: current engine)
  58322. * @param reusable If the post process can be reused on the same frame. (default: false)
  58323. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58324. */
  58325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58326. }
  58327. }
  58328. declare module BABYLON {
  58329. /** @hidden */
  58330. export var mrtFragmentDeclaration: {
  58331. name: string;
  58332. shader: string;
  58333. };
  58334. }
  58335. declare module BABYLON {
  58336. /** @hidden */
  58337. export var geometryPixelShader: {
  58338. name: string;
  58339. shader: string;
  58340. };
  58341. }
  58342. declare module BABYLON {
  58343. /** @hidden */
  58344. export var geometryVertexShader: {
  58345. name: string;
  58346. shader: string;
  58347. };
  58348. }
  58349. declare module BABYLON {
  58350. /** @hidden */
  58351. interface ISavedTransformationMatrix {
  58352. world: Matrix;
  58353. viewProjection: Matrix;
  58354. }
  58355. /**
  58356. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58357. */
  58358. export class GeometryBufferRenderer {
  58359. /**
  58360. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58361. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58362. */
  58363. static readonly POSITION_TEXTURE_TYPE: number;
  58364. /**
  58365. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58366. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58367. */
  58368. static readonly VELOCITY_TEXTURE_TYPE: number;
  58369. /**
  58370. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58371. * in order to compute objects velocities when enableVelocity is set to "true"
  58372. * @hidden
  58373. */
  58374. _previousTransformationMatrices: {
  58375. [index: number]: ISavedTransformationMatrix;
  58376. };
  58377. /**
  58378. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58379. * in order to compute objects velocities when enableVelocity is set to "true"
  58380. * @hidden
  58381. */
  58382. _previousBonesTransformationMatrices: {
  58383. [index: number]: Float32Array;
  58384. };
  58385. /**
  58386. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58387. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58388. */
  58389. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58390. private _scene;
  58391. private _multiRenderTarget;
  58392. private _ratio;
  58393. private _enablePosition;
  58394. private _enableVelocity;
  58395. private _positionIndex;
  58396. private _velocityIndex;
  58397. protected _effect: Effect;
  58398. protected _cachedDefines: string;
  58399. /**
  58400. * Set the render list (meshes to be rendered) used in the G buffer.
  58401. */
  58402. renderList: Mesh[];
  58403. /**
  58404. * Gets wether or not G buffer are supported by the running hardware.
  58405. * This requires draw buffer supports
  58406. */
  58407. readonly isSupported: boolean;
  58408. /**
  58409. * Returns the index of the given texture type in the G-Buffer textures array
  58410. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58411. * @returns the index of the given texture type in the G-Buffer textures array
  58412. */
  58413. getTextureIndex(textureType: number): number;
  58414. /**
  58415. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58416. */
  58417. /**
  58418. * Sets whether or not objects positions are enabled for the G buffer.
  58419. */
  58420. enablePosition: boolean;
  58421. /**
  58422. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58423. */
  58424. /**
  58425. * Sets wether or not objects velocities are enabled for the G buffer.
  58426. */
  58427. enableVelocity: boolean;
  58428. /**
  58429. * Gets the scene associated with the buffer.
  58430. */
  58431. readonly scene: Scene;
  58432. /**
  58433. * Gets the ratio used by the buffer during its creation.
  58434. * How big is the buffer related to the main canvas.
  58435. */
  58436. readonly ratio: number;
  58437. /** @hidden */
  58438. static _SceneComponentInitialization: (scene: Scene) => void;
  58439. /**
  58440. * Creates a new G Buffer for the scene
  58441. * @param scene The scene the buffer belongs to
  58442. * @param ratio How big is the buffer related to the main canvas.
  58443. */
  58444. constructor(scene: Scene, ratio?: number);
  58445. /**
  58446. * Checks wether everything is ready to render a submesh to the G buffer.
  58447. * @param subMesh the submesh to check readiness for
  58448. * @param useInstances is the mesh drawn using instance or not
  58449. * @returns true if ready otherwise false
  58450. */
  58451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58452. /**
  58453. * Gets the current underlying G Buffer.
  58454. * @returns the buffer
  58455. */
  58456. getGBuffer(): MultiRenderTarget;
  58457. /**
  58458. * Gets the number of samples used to render the buffer (anti aliasing).
  58459. */
  58460. /**
  58461. * Sets the number of samples used to render the buffer (anti aliasing).
  58462. */
  58463. samples: number;
  58464. /**
  58465. * Disposes the renderer and frees up associated resources.
  58466. */
  58467. dispose(): void;
  58468. protected _createRenderTargets(): void;
  58469. private _copyBonesTransformationMatrices;
  58470. }
  58471. }
  58472. declare module BABYLON {
  58473. interface Scene {
  58474. /** @hidden (Backing field) */
  58475. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58476. /**
  58477. * Gets or Sets the current geometry buffer associated to the scene.
  58478. */
  58479. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58480. /**
  58481. * Enables a GeometryBufferRender and associates it with the scene
  58482. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58483. * @returns the GeometryBufferRenderer
  58484. */
  58485. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58486. /**
  58487. * Disables the GeometryBufferRender associated with the scene
  58488. */
  58489. disableGeometryBufferRenderer(): void;
  58490. }
  58491. /**
  58492. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58493. * in several rendering techniques.
  58494. */
  58495. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58496. /**
  58497. * The component name helpful to identify the component in the list of scene components.
  58498. */
  58499. readonly name: string;
  58500. /**
  58501. * The scene the component belongs to.
  58502. */
  58503. scene: Scene;
  58504. /**
  58505. * Creates a new instance of the component for the given scene
  58506. * @param scene Defines the scene to register the component in
  58507. */
  58508. constructor(scene: Scene);
  58509. /**
  58510. * Registers the component in a given scene
  58511. */
  58512. register(): void;
  58513. /**
  58514. * Rebuilds the elements related to this component in case of
  58515. * context lost for instance.
  58516. */
  58517. rebuild(): void;
  58518. /**
  58519. * Disposes the component and the associated ressources
  58520. */
  58521. dispose(): void;
  58522. private _gatherRenderTargets;
  58523. }
  58524. }
  58525. declare module BABYLON {
  58526. /** @hidden */
  58527. export var motionBlurPixelShader: {
  58528. name: string;
  58529. shader: string;
  58530. };
  58531. }
  58532. declare module BABYLON {
  58533. /**
  58534. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58535. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58536. * As an example, all you have to do is to create the post-process:
  58537. * var mb = new BABYLON.MotionBlurPostProcess(
  58538. * 'mb', // The name of the effect.
  58539. * scene, // The scene containing the objects to blur according to their velocity.
  58540. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58541. * camera // The camera to apply the render pass to.
  58542. * );
  58543. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58544. */
  58545. export class MotionBlurPostProcess extends PostProcess {
  58546. /**
  58547. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58548. */
  58549. motionStrength: number;
  58550. /**
  58551. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58552. */
  58553. /**
  58554. * Sets the number of iterations to be used for motion blur quality
  58555. */
  58556. motionBlurSamples: number;
  58557. private _motionBlurSamples;
  58558. private _geometryBufferRenderer;
  58559. /**
  58560. * Creates a new instance MotionBlurPostProcess
  58561. * @param name The name of the effect.
  58562. * @param scene The scene containing the objects to blur according to their velocity.
  58563. * @param options The required width/height ratio to downsize to before computing the render pass.
  58564. * @param camera The camera to apply the render pass to.
  58565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58566. * @param engine The engine which the post process will be applied. (default: current engine)
  58567. * @param reusable If the post process can be reused on the same frame. (default: false)
  58568. * @param textureType Type of textures used when performing the post process. (default: 0)
  58569. * @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)
  58570. */
  58571. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58572. /**
  58573. * Excludes the given skinned mesh from computing bones velocities.
  58574. * 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.
  58575. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58576. */
  58577. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58578. /**
  58579. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58580. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58581. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58582. */
  58583. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58584. /**
  58585. * Disposes the post process.
  58586. * @param camera The camera to dispose the post process on.
  58587. */
  58588. dispose(camera?: Camera): void;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /** @hidden */
  58593. export var refractionPixelShader: {
  58594. name: string;
  58595. shader: string;
  58596. };
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * Post process which applies a refractin texture
  58601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58602. */
  58603. export class RefractionPostProcess extends PostProcess {
  58604. /** the base color of the refraction (used to taint the rendering) */
  58605. color: Color3;
  58606. /** simulated refraction depth */
  58607. depth: number;
  58608. /** the coefficient of the base color (0 to remove base color tainting) */
  58609. colorLevel: number;
  58610. private _refTexture;
  58611. private _ownRefractionTexture;
  58612. /**
  58613. * Gets or sets the refraction texture
  58614. * Please note that you are responsible for disposing the texture if you set it manually
  58615. */
  58616. refractionTexture: Texture;
  58617. /**
  58618. * Initializes the RefractionPostProcess
  58619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58620. * @param name The name of the effect.
  58621. * @param refractionTextureUrl Url of the refraction texture to use
  58622. * @param color the base color of the refraction (used to taint the rendering)
  58623. * @param depth simulated refraction depth
  58624. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58625. * @param camera The camera to apply the render pass to.
  58626. * @param options The required width/height ratio to downsize to before computing the render pass.
  58627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58628. * @param engine The engine which the post process will be applied. (default: current engine)
  58629. * @param reusable If the post process can be reused on the same frame. (default: false)
  58630. */
  58631. constructor(name: string, refractionTextureUrl: string,
  58632. /** the base color of the refraction (used to taint the rendering) */
  58633. color: Color3,
  58634. /** simulated refraction depth */
  58635. depth: number,
  58636. /** the coefficient of the base color (0 to remove base color tainting) */
  58637. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58638. /**
  58639. * Disposes of the post process
  58640. * @param camera Camera to dispose post process on
  58641. */
  58642. dispose(camera: Camera): void;
  58643. }
  58644. }
  58645. declare module BABYLON {
  58646. /** @hidden */
  58647. export var sharpenPixelShader: {
  58648. name: string;
  58649. shader: string;
  58650. };
  58651. }
  58652. declare module BABYLON {
  58653. /**
  58654. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58655. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58656. */
  58657. export class SharpenPostProcess extends PostProcess {
  58658. /**
  58659. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58660. */
  58661. colorAmount: number;
  58662. /**
  58663. * How much sharpness should be applied (default: 0.3)
  58664. */
  58665. edgeAmount: number;
  58666. /**
  58667. * Creates a new instance ConvolutionPostProcess
  58668. * @param name The name of the effect.
  58669. * @param options The required width/height ratio to downsize to before computing the render pass.
  58670. * @param camera The camera to apply the render pass to.
  58671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58672. * @param engine The engine which the post process will be applied. (default: current engine)
  58673. * @param reusable If the post process can be reused on the same frame. (default: false)
  58674. * @param textureType Type of textures used when performing the post process. (default: 0)
  58675. * @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)
  58676. */
  58677. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58678. }
  58679. }
  58680. declare module BABYLON {
  58681. /**
  58682. * PostProcessRenderPipeline
  58683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58684. */
  58685. export class PostProcessRenderPipeline {
  58686. private engine;
  58687. private _renderEffects;
  58688. private _renderEffectsForIsolatedPass;
  58689. /**
  58690. * List of inspectable custom properties (used by the Inspector)
  58691. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58692. */
  58693. inspectableCustomProperties: IInspectable[];
  58694. /**
  58695. * @hidden
  58696. */
  58697. protected _cameras: Camera[];
  58698. /** @hidden */
  58699. _name: string;
  58700. /**
  58701. * Gets pipeline name
  58702. */
  58703. readonly name: string;
  58704. /**
  58705. * Initializes a PostProcessRenderPipeline
  58706. * @param engine engine to add the pipeline to
  58707. * @param name name of the pipeline
  58708. */
  58709. constructor(engine: Engine, name: string);
  58710. /**
  58711. * Gets the class name
  58712. * @returns "PostProcessRenderPipeline"
  58713. */
  58714. getClassName(): string;
  58715. /**
  58716. * If all the render effects in the pipeline are supported
  58717. */
  58718. readonly isSupported: boolean;
  58719. /**
  58720. * Adds an effect to the pipeline
  58721. * @param renderEffect the effect to add
  58722. */
  58723. addEffect(renderEffect: PostProcessRenderEffect): void;
  58724. /** @hidden */
  58725. _rebuild(): void;
  58726. /** @hidden */
  58727. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58728. /** @hidden */
  58729. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58730. /** @hidden */
  58731. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58732. /** @hidden */
  58733. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58734. /** @hidden */
  58735. _attachCameras(cameras: Camera, unique: boolean): void;
  58736. /** @hidden */
  58737. _attachCameras(cameras: Camera[], unique: boolean): void;
  58738. /** @hidden */
  58739. _detachCameras(cameras: Camera): void;
  58740. /** @hidden */
  58741. _detachCameras(cameras: Nullable<Camera[]>): void;
  58742. /** @hidden */
  58743. _update(): void;
  58744. /** @hidden */
  58745. _reset(): void;
  58746. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58747. /**
  58748. * Disposes of the pipeline
  58749. */
  58750. dispose(): void;
  58751. }
  58752. }
  58753. declare module BABYLON {
  58754. /**
  58755. * PostProcessRenderPipelineManager class
  58756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58757. */
  58758. export class PostProcessRenderPipelineManager {
  58759. private _renderPipelines;
  58760. /**
  58761. * Initializes a PostProcessRenderPipelineManager
  58762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58763. */
  58764. constructor();
  58765. /**
  58766. * Gets the list of supported render pipelines
  58767. */
  58768. readonly supportedPipelines: PostProcessRenderPipeline[];
  58769. /**
  58770. * Adds a pipeline to the manager
  58771. * @param renderPipeline The pipeline to add
  58772. */
  58773. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58774. /**
  58775. * Attaches a camera to the pipeline
  58776. * @param renderPipelineName The name of the pipeline to attach to
  58777. * @param cameras the camera to attach
  58778. * @param unique if the camera can be attached multiple times to the pipeline
  58779. */
  58780. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58781. /**
  58782. * Detaches a camera from the pipeline
  58783. * @param renderPipelineName The name of the pipeline to detach from
  58784. * @param cameras the camera to detach
  58785. */
  58786. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58787. /**
  58788. * Enables an effect by name on a pipeline
  58789. * @param renderPipelineName the name of the pipeline to enable the effect in
  58790. * @param renderEffectName the name of the effect to enable
  58791. * @param cameras the cameras that the effect should be enabled on
  58792. */
  58793. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58794. /**
  58795. * Disables an effect by name on a pipeline
  58796. * @param renderPipelineName the name of the pipeline to disable the effect in
  58797. * @param renderEffectName the name of the effect to disable
  58798. * @param cameras the cameras that the effect should be disabled on
  58799. */
  58800. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58801. /**
  58802. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58803. */
  58804. update(): void;
  58805. /** @hidden */
  58806. _rebuild(): void;
  58807. /**
  58808. * Disposes of the manager and pipelines
  58809. */
  58810. dispose(): void;
  58811. }
  58812. }
  58813. declare module BABYLON {
  58814. interface Scene {
  58815. /** @hidden (Backing field) */
  58816. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58817. /**
  58818. * Gets the postprocess render pipeline manager
  58819. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58820. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58821. */
  58822. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58823. }
  58824. /**
  58825. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58826. */
  58827. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58828. /**
  58829. * The component name helpfull to identify the component in the list of scene components.
  58830. */
  58831. readonly name: string;
  58832. /**
  58833. * The scene the component belongs to.
  58834. */
  58835. scene: Scene;
  58836. /**
  58837. * Creates a new instance of the component for the given scene
  58838. * @param scene Defines the scene to register the component in
  58839. */
  58840. constructor(scene: Scene);
  58841. /**
  58842. * Registers the component in a given scene
  58843. */
  58844. register(): void;
  58845. /**
  58846. * Rebuilds the elements related to this component in case of
  58847. * context lost for instance.
  58848. */
  58849. rebuild(): void;
  58850. /**
  58851. * Disposes the component and the associated ressources
  58852. */
  58853. dispose(): void;
  58854. private _gatherRenderTargets;
  58855. }
  58856. }
  58857. declare module BABYLON {
  58858. /**
  58859. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58860. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58861. */
  58862. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58863. private _scene;
  58864. private _camerasToBeAttached;
  58865. /**
  58866. * ID of the sharpen post process,
  58867. */
  58868. private readonly SharpenPostProcessId;
  58869. /**
  58870. * @ignore
  58871. * ID of the image processing post process;
  58872. */
  58873. readonly ImageProcessingPostProcessId: string;
  58874. /**
  58875. * @ignore
  58876. * ID of the Fast Approximate Anti-Aliasing post process;
  58877. */
  58878. readonly FxaaPostProcessId: string;
  58879. /**
  58880. * ID of the chromatic aberration post process,
  58881. */
  58882. private readonly ChromaticAberrationPostProcessId;
  58883. /**
  58884. * ID of the grain post process
  58885. */
  58886. private readonly GrainPostProcessId;
  58887. /**
  58888. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58889. */
  58890. sharpen: SharpenPostProcess;
  58891. private _sharpenEffect;
  58892. private bloom;
  58893. /**
  58894. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58895. */
  58896. depthOfField: DepthOfFieldEffect;
  58897. /**
  58898. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58899. */
  58900. fxaa: FxaaPostProcess;
  58901. /**
  58902. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58903. */
  58904. imageProcessing: ImageProcessingPostProcess;
  58905. /**
  58906. * Chromatic aberration post process which will shift rgb colors in the image
  58907. */
  58908. chromaticAberration: ChromaticAberrationPostProcess;
  58909. private _chromaticAberrationEffect;
  58910. /**
  58911. * Grain post process which add noise to the image
  58912. */
  58913. grain: GrainPostProcess;
  58914. private _grainEffect;
  58915. /**
  58916. * Glow post process which adds a glow to emissive areas of the image
  58917. */
  58918. private _glowLayer;
  58919. /**
  58920. * Animations which can be used to tweak settings over a period of time
  58921. */
  58922. animations: Animation[];
  58923. private _imageProcessingConfigurationObserver;
  58924. private _sharpenEnabled;
  58925. private _bloomEnabled;
  58926. private _depthOfFieldEnabled;
  58927. private _depthOfFieldBlurLevel;
  58928. private _fxaaEnabled;
  58929. private _imageProcessingEnabled;
  58930. private _defaultPipelineTextureType;
  58931. private _bloomScale;
  58932. private _chromaticAberrationEnabled;
  58933. private _grainEnabled;
  58934. private _buildAllowed;
  58935. /**
  58936. * Gets active scene
  58937. */
  58938. readonly scene: Scene;
  58939. /**
  58940. * Enable or disable the sharpen process from the pipeline
  58941. */
  58942. sharpenEnabled: boolean;
  58943. private _resizeObserver;
  58944. private _hardwareScaleLevel;
  58945. private _bloomKernel;
  58946. /**
  58947. * Specifies the size of the bloom blur kernel, relative to the final output size
  58948. */
  58949. bloomKernel: number;
  58950. /**
  58951. * Specifies the weight of the bloom in the final rendering
  58952. */
  58953. private _bloomWeight;
  58954. /**
  58955. * Specifies the luma threshold for the area that will be blurred by the bloom
  58956. */
  58957. private _bloomThreshold;
  58958. private _hdr;
  58959. /**
  58960. * The strength of the bloom.
  58961. */
  58962. bloomWeight: number;
  58963. /**
  58964. * The strength of the bloom.
  58965. */
  58966. bloomThreshold: number;
  58967. /**
  58968. * The scale of the bloom, lower value will provide better performance.
  58969. */
  58970. bloomScale: number;
  58971. /**
  58972. * Enable or disable the bloom from the pipeline
  58973. */
  58974. bloomEnabled: boolean;
  58975. private _rebuildBloom;
  58976. /**
  58977. * If the depth of field is enabled.
  58978. */
  58979. depthOfFieldEnabled: boolean;
  58980. /**
  58981. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58982. */
  58983. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58984. /**
  58985. * If the anti aliasing is enabled.
  58986. */
  58987. fxaaEnabled: boolean;
  58988. private _samples;
  58989. /**
  58990. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58991. */
  58992. samples: number;
  58993. /**
  58994. * If image processing is enabled.
  58995. */
  58996. imageProcessingEnabled: boolean;
  58997. /**
  58998. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58999. */
  59000. glowLayerEnabled: boolean;
  59001. /**
  59002. * Gets the glow layer (or null if not defined)
  59003. */
  59004. readonly glowLayer: Nullable<GlowLayer>;
  59005. /**
  59006. * Enable or disable the chromaticAberration process from the pipeline
  59007. */
  59008. chromaticAberrationEnabled: boolean;
  59009. /**
  59010. * Enable or disable the grain process from the pipeline
  59011. */
  59012. grainEnabled: boolean;
  59013. /**
  59014. * @constructor
  59015. * @param name - The rendering pipeline name (default: "")
  59016. * @param hdr - If high dynamic range textures should be used (default: true)
  59017. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59018. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59019. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59020. */
  59021. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59022. /**
  59023. * Get the class name
  59024. * @returns "DefaultRenderingPipeline"
  59025. */
  59026. getClassName(): string;
  59027. /**
  59028. * Force the compilation of the entire pipeline.
  59029. */
  59030. prepare(): void;
  59031. private _hasCleared;
  59032. private _prevPostProcess;
  59033. private _prevPrevPostProcess;
  59034. private _setAutoClearAndTextureSharing;
  59035. private _depthOfFieldSceneObserver;
  59036. private _buildPipeline;
  59037. private _disposePostProcesses;
  59038. /**
  59039. * Adds a camera to the pipeline
  59040. * @param camera the camera to be added
  59041. */
  59042. addCamera(camera: Camera): void;
  59043. /**
  59044. * Removes a camera from the pipeline
  59045. * @param camera the camera to remove
  59046. */
  59047. removeCamera(camera: Camera): void;
  59048. /**
  59049. * Dispose of the pipeline and stop all post processes
  59050. */
  59051. dispose(): void;
  59052. /**
  59053. * Serialize the rendering pipeline (Used when exporting)
  59054. * @returns the serialized object
  59055. */
  59056. serialize(): any;
  59057. /**
  59058. * Parse the serialized pipeline
  59059. * @param source Source pipeline.
  59060. * @param scene The scene to load the pipeline to.
  59061. * @param rootUrl The URL of the serialized pipeline.
  59062. * @returns An instantiated pipeline from the serialized object.
  59063. */
  59064. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59065. }
  59066. }
  59067. declare module BABYLON {
  59068. /** @hidden */
  59069. export var lensHighlightsPixelShader: {
  59070. name: string;
  59071. shader: string;
  59072. };
  59073. }
  59074. declare module BABYLON {
  59075. /** @hidden */
  59076. export var depthOfFieldPixelShader: {
  59077. name: string;
  59078. shader: string;
  59079. };
  59080. }
  59081. declare module BABYLON {
  59082. /**
  59083. * BABYLON.JS Chromatic Aberration GLSL Shader
  59084. * Author: Olivier Guyot
  59085. * Separates very slightly R, G and B colors on the edges of the screen
  59086. * Inspired by Francois Tarlier & Martins Upitis
  59087. */
  59088. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59089. /**
  59090. * @ignore
  59091. * The chromatic aberration PostProcess id in the pipeline
  59092. */
  59093. LensChromaticAberrationEffect: string;
  59094. /**
  59095. * @ignore
  59096. * The highlights enhancing PostProcess id in the pipeline
  59097. */
  59098. HighlightsEnhancingEffect: string;
  59099. /**
  59100. * @ignore
  59101. * The depth-of-field PostProcess id in the pipeline
  59102. */
  59103. LensDepthOfFieldEffect: string;
  59104. private _scene;
  59105. private _depthTexture;
  59106. private _grainTexture;
  59107. private _chromaticAberrationPostProcess;
  59108. private _highlightsPostProcess;
  59109. private _depthOfFieldPostProcess;
  59110. private _edgeBlur;
  59111. private _grainAmount;
  59112. private _chromaticAberration;
  59113. private _distortion;
  59114. private _highlightsGain;
  59115. private _highlightsThreshold;
  59116. private _dofDistance;
  59117. private _dofAperture;
  59118. private _dofDarken;
  59119. private _dofPentagon;
  59120. private _blurNoise;
  59121. /**
  59122. * @constructor
  59123. *
  59124. * Effect parameters are as follow:
  59125. * {
  59126. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59127. * edge_blur: number; // from 0 to x (1 for realism)
  59128. * distortion: number; // from 0 to x (1 for realism)
  59129. * grain_amount: number; // from 0 to 1
  59130. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59131. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59132. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59133. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59134. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59135. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59136. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59137. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59138. * }
  59139. * Note: if an effect parameter is unset, effect is disabled
  59140. *
  59141. * @param name The rendering pipeline name
  59142. * @param parameters - An object containing all parameters (see above)
  59143. * @param scene The scene linked to this pipeline
  59144. * @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)
  59145. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59146. */
  59147. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59148. /**
  59149. * Get the class name
  59150. * @returns "LensRenderingPipeline"
  59151. */
  59152. getClassName(): string;
  59153. /**
  59154. * Gets associated scene
  59155. */
  59156. readonly scene: Scene;
  59157. /**
  59158. * Gets or sets the edge blur
  59159. */
  59160. edgeBlur: number;
  59161. /**
  59162. * Gets or sets the grain amount
  59163. */
  59164. grainAmount: number;
  59165. /**
  59166. * Gets or sets the chromatic aberration amount
  59167. */
  59168. chromaticAberration: number;
  59169. /**
  59170. * Gets or sets the depth of field aperture
  59171. */
  59172. dofAperture: number;
  59173. /**
  59174. * Gets or sets the edge distortion
  59175. */
  59176. edgeDistortion: number;
  59177. /**
  59178. * Gets or sets the depth of field distortion
  59179. */
  59180. dofDistortion: number;
  59181. /**
  59182. * Gets or sets the darken out of focus amount
  59183. */
  59184. darkenOutOfFocus: number;
  59185. /**
  59186. * Gets or sets a boolean indicating if blur noise is enabled
  59187. */
  59188. blurNoise: boolean;
  59189. /**
  59190. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59191. */
  59192. pentagonBokeh: boolean;
  59193. /**
  59194. * Gets or sets the highlight grain amount
  59195. */
  59196. highlightsGain: number;
  59197. /**
  59198. * Gets or sets the highlight threshold
  59199. */
  59200. highlightsThreshold: number;
  59201. /**
  59202. * Sets the amount of blur at the edges
  59203. * @param amount blur amount
  59204. */
  59205. setEdgeBlur(amount: number): void;
  59206. /**
  59207. * Sets edge blur to 0
  59208. */
  59209. disableEdgeBlur(): void;
  59210. /**
  59211. * Sets the amout of grain
  59212. * @param amount Amount of grain
  59213. */
  59214. setGrainAmount(amount: number): void;
  59215. /**
  59216. * Set grain amount to 0
  59217. */
  59218. disableGrain(): void;
  59219. /**
  59220. * Sets the chromatic aberration amount
  59221. * @param amount amount of chromatic aberration
  59222. */
  59223. setChromaticAberration(amount: number): void;
  59224. /**
  59225. * Sets chromatic aberration amount to 0
  59226. */
  59227. disableChromaticAberration(): void;
  59228. /**
  59229. * Sets the EdgeDistortion amount
  59230. * @param amount amount of EdgeDistortion
  59231. */
  59232. setEdgeDistortion(amount: number): void;
  59233. /**
  59234. * Sets edge distortion to 0
  59235. */
  59236. disableEdgeDistortion(): void;
  59237. /**
  59238. * Sets the FocusDistance amount
  59239. * @param amount amount of FocusDistance
  59240. */
  59241. setFocusDistance(amount: number): void;
  59242. /**
  59243. * Disables depth of field
  59244. */
  59245. disableDepthOfField(): void;
  59246. /**
  59247. * Sets the Aperture amount
  59248. * @param amount amount of Aperture
  59249. */
  59250. setAperture(amount: number): void;
  59251. /**
  59252. * Sets the DarkenOutOfFocus amount
  59253. * @param amount amount of DarkenOutOfFocus
  59254. */
  59255. setDarkenOutOfFocus(amount: number): void;
  59256. private _pentagonBokehIsEnabled;
  59257. /**
  59258. * Creates a pentagon bokeh effect
  59259. */
  59260. enablePentagonBokeh(): void;
  59261. /**
  59262. * Disables the pentagon bokeh effect
  59263. */
  59264. disablePentagonBokeh(): void;
  59265. /**
  59266. * Enables noise blur
  59267. */
  59268. enableNoiseBlur(): void;
  59269. /**
  59270. * Disables noise blur
  59271. */
  59272. disableNoiseBlur(): void;
  59273. /**
  59274. * Sets the HighlightsGain amount
  59275. * @param amount amount of HighlightsGain
  59276. */
  59277. setHighlightsGain(amount: number): void;
  59278. /**
  59279. * Sets the HighlightsThreshold amount
  59280. * @param amount amount of HighlightsThreshold
  59281. */
  59282. setHighlightsThreshold(amount: number): void;
  59283. /**
  59284. * Disables highlights
  59285. */
  59286. disableHighlights(): void;
  59287. /**
  59288. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59289. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59290. */
  59291. dispose(disableDepthRender?: boolean): void;
  59292. private _createChromaticAberrationPostProcess;
  59293. private _createHighlightsPostProcess;
  59294. private _createDepthOfFieldPostProcess;
  59295. private _createGrainTexture;
  59296. }
  59297. }
  59298. declare module BABYLON {
  59299. /** @hidden */
  59300. export var ssao2PixelShader: {
  59301. name: string;
  59302. shader: string;
  59303. };
  59304. }
  59305. declare module BABYLON {
  59306. /** @hidden */
  59307. export var ssaoCombinePixelShader: {
  59308. name: string;
  59309. shader: string;
  59310. };
  59311. }
  59312. declare module BABYLON {
  59313. /**
  59314. * Render pipeline to produce ssao effect
  59315. */
  59316. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59317. /**
  59318. * @ignore
  59319. * The PassPostProcess id in the pipeline that contains the original scene color
  59320. */
  59321. SSAOOriginalSceneColorEffect: string;
  59322. /**
  59323. * @ignore
  59324. * The SSAO PostProcess id in the pipeline
  59325. */
  59326. SSAORenderEffect: string;
  59327. /**
  59328. * @ignore
  59329. * The horizontal blur PostProcess id in the pipeline
  59330. */
  59331. SSAOBlurHRenderEffect: string;
  59332. /**
  59333. * @ignore
  59334. * The vertical blur PostProcess id in the pipeline
  59335. */
  59336. SSAOBlurVRenderEffect: string;
  59337. /**
  59338. * @ignore
  59339. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59340. */
  59341. SSAOCombineRenderEffect: string;
  59342. /**
  59343. * The output strength of the SSAO post-process. Default value is 1.0.
  59344. */
  59345. totalStrength: number;
  59346. /**
  59347. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59348. */
  59349. maxZ: number;
  59350. /**
  59351. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59352. */
  59353. minZAspect: number;
  59354. private _samples;
  59355. /**
  59356. * Number of samples used for the SSAO calculations. Default value is 8
  59357. */
  59358. samples: number;
  59359. private _textureSamples;
  59360. /**
  59361. * Number of samples to use for antialiasing
  59362. */
  59363. textureSamples: number;
  59364. /**
  59365. * Ratio object used for SSAO ratio and blur ratio
  59366. */
  59367. private _ratio;
  59368. /**
  59369. * Dynamically generated sphere sampler.
  59370. */
  59371. private _sampleSphere;
  59372. /**
  59373. * Blur filter offsets
  59374. */
  59375. private _samplerOffsets;
  59376. private _expensiveBlur;
  59377. /**
  59378. * If bilateral blur should be used
  59379. */
  59380. expensiveBlur: boolean;
  59381. /**
  59382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59383. */
  59384. radius: number;
  59385. /**
  59386. * The base color of the SSAO post-process
  59387. * The final result is "base + ssao" between [0, 1]
  59388. */
  59389. base: number;
  59390. /**
  59391. * Support test.
  59392. */
  59393. static readonly IsSupported: boolean;
  59394. private _scene;
  59395. private _depthTexture;
  59396. private _normalTexture;
  59397. private _randomTexture;
  59398. private _originalColorPostProcess;
  59399. private _ssaoPostProcess;
  59400. private _blurHPostProcess;
  59401. private _blurVPostProcess;
  59402. private _ssaoCombinePostProcess;
  59403. private _firstUpdate;
  59404. /**
  59405. * Gets active scene
  59406. */
  59407. readonly scene: Scene;
  59408. /**
  59409. * @constructor
  59410. * @param name The rendering pipeline name
  59411. * @param scene The scene linked to this pipeline
  59412. * @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 }
  59413. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59414. */
  59415. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59416. /**
  59417. * Get the class name
  59418. * @returns "SSAO2RenderingPipeline"
  59419. */
  59420. getClassName(): string;
  59421. /**
  59422. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59423. */
  59424. dispose(disableGeometryBufferRenderer?: boolean): void;
  59425. private _createBlurPostProcess;
  59426. /** @hidden */
  59427. _rebuild(): void;
  59428. private _bits;
  59429. private _radicalInverse_VdC;
  59430. private _hammersley;
  59431. private _hemisphereSample_uniform;
  59432. private _generateHemisphere;
  59433. private _createSSAOPostProcess;
  59434. private _createSSAOCombinePostProcess;
  59435. private _createRandomTexture;
  59436. /**
  59437. * Serialize the rendering pipeline (Used when exporting)
  59438. * @returns the serialized object
  59439. */
  59440. serialize(): any;
  59441. /**
  59442. * Parse the serialized pipeline
  59443. * @param source Source pipeline.
  59444. * @param scene The scene to load the pipeline to.
  59445. * @param rootUrl The URL of the serialized pipeline.
  59446. * @returns An instantiated pipeline from the serialized object.
  59447. */
  59448. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59449. }
  59450. }
  59451. declare module BABYLON {
  59452. /** @hidden */
  59453. export var ssaoPixelShader: {
  59454. name: string;
  59455. shader: string;
  59456. };
  59457. }
  59458. declare module BABYLON {
  59459. /**
  59460. * Render pipeline to produce ssao effect
  59461. */
  59462. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59463. /**
  59464. * @ignore
  59465. * The PassPostProcess id in the pipeline that contains the original scene color
  59466. */
  59467. SSAOOriginalSceneColorEffect: string;
  59468. /**
  59469. * @ignore
  59470. * The SSAO PostProcess id in the pipeline
  59471. */
  59472. SSAORenderEffect: string;
  59473. /**
  59474. * @ignore
  59475. * The horizontal blur PostProcess id in the pipeline
  59476. */
  59477. SSAOBlurHRenderEffect: string;
  59478. /**
  59479. * @ignore
  59480. * The vertical blur PostProcess id in the pipeline
  59481. */
  59482. SSAOBlurVRenderEffect: string;
  59483. /**
  59484. * @ignore
  59485. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59486. */
  59487. SSAOCombineRenderEffect: string;
  59488. /**
  59489. * The output strength of the SSAO post-process. Default value is 1.0.
  59490. */
  59491. totalStrength: number;
  59492. /**
  59493. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59494. */
  59495. radius: number;
  59496. /**
  59497. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59498. * Must not be equal to fallOff and superior to fallOff.
  59499. * Default value is 0.0075
  59500. */
  59501. area: number;
  59502. /**
  59503. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59504. * Must not be equal to area and inferior to area.
  59505. * Default value is 0.000001
  59506. */
  59507. fallOff: number;
  59508. /**
  59509. * The base color of the SSAO post-process
  59510. * The final result is "base + ssao" between [0, 1]
  59511. */
  59512. base: number;
  59513. private _scene;
  59514. private _depthTexture;
  59515. private _randomTexture;
  59516. private _originalColorPostProcess;
  59517. private _ssaoPostProcess;
  59518. private _blurHPostProcess;
  59519. private _blurVPostProcess;
  59520. private _ssaoCombinePostProcess;
  59521. private _firstUpdate;
  59522. /**
  59523. * Gets active scene
  59524. */
  59525. readonly scene: Scene;
  59526. /**
  59527. * @constructor
  59528. * @param name - The rendering pipeline name
  59529. * @param scene - The scene linked to this pipeline
  59530. * @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 }
  59531. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59532. */
  59533. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59534. /**
  59535. * Get the class name
  59536. * @returns "SSAORenderingPipeline"
  59537. */
  59538. getClassName(): string;
  59539. /**
  59540. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59541. */
  59542. dispose(disableDepthRender?: boolean): void;
  59543. private _createBlurPostProcess;
  59544. /** @hidden */
  59545. _rebuild(): void;
  59546. private _createSSAOPostProcess;
  59547. private _createSSAOCombinePostProcess;
  59548. private _createRandomTexture;
  59549. }
  59550. }
  59551. declare module BABYLON {
  59552. /** @hidden */
  59553. export var standardPixelShader: {
  59554. name: string;
  59555. shader: string;
  59556. };
  59557. }
  59558. declare module BABYLON {
  59559. /**
  59560. * Standard rendering pipeline
  59561. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59562. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59563. */
  59564. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59565. /**
  59566. * Public members
  59567. */
  59568. /**
  59569. * Post-process which contains the original scene color before the pipeline applies all the effects
  59570. */
  59571. originalPostProcess: Nullable<PostProcess>;
  59572. /**
  59573. * Post-process used to down scale an image x4
  59574. */
  59575. downSampleX4PostProcess: Nullable<PostProcess>;
  59576. /**
  59577. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59578. */
  59579. brightPassPostProcess: Nullable<PostProcess>;
  59580. /**
  59581. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59582. */
  59583. blurHPostProcesses: PostProcess[];
  59584. /**
  59585. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59586. */
  59587. blurVPostProcesses: PostProcess[];
  59588. /**
  59589. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59590. */
  59591. textureAdderPostProcess: Nullable<PostProcess>;
  59592. /**
  59593. * Post-process used to create volumetric lighting effect
  59594. */
  59595. volumetricLightPostProcess: Nullable<PostProcess>;
  59596. /**
  59597. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59598. */
  59599. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59600. /**
  59601. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59602. */
  59603. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59604. /**
  59605. * Post-process used to merge the volumetric light effect and the real scene color
  59606. */
  59607. volumetricLightMergePostProces: Nullable<PostProcess>;
  59608. /**
  59609. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59610. */
  59611. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59612. /**
  59613. * Base post-process used to calculate the average luminance of the final image for HDR
  59614. */
  59615. luminancePostProcess: Nullable<PostProcess>;
  59616. /**
  59617. * Post-processes used to create down sample post-processes in order to get
  59618. * the average luminance of the final image for HDR
  59619. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59620. */
  59621. luminanceDownSamplePostProcesses: PostProcess[];
  59622. /**
  59623. * Post-process used to create a HDR effect (light adaptation)
  59624. */
  59625. hdrPostProcess: Nullable<PostProcess>;
  59626. /**
  59627. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59628. */
  59629. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59630. /**
  59631. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59632. */
  59633. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59634. /**
  59635. * Post-process used to merge the final HDR post-process and the real scene color
  59636. */
  59637. hdrFinalPostProcess: Nullable<PostProcess>;
  59638. /**
  59639. * Post-process used to create a lens flare effect
  59640. */
  59641. lensFlarePostProcess: Nullable<PostProcess>;
  59642. /**
  59643. * Post-process that merges the result of the lens flare post-process and the real scene color
  59644. */
  59645. lensFlareComposePostProcess: Nullable<PostProcess>;
  59646. /**
  59647. * Post-process used to create a motion blur effect
  59648. */
  59649. motionBlurPostProcess: Nullable<PostProcess>;
  59650. /**
  59651. * Post-process used to create a depth of field effect
  59652. */
  59653. depthOfFieldPostProcess: Nullable<PostProcess>;
  59654. /**
  59655. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59656. */
  59657. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59658. /**
  59659. * Represents the brightness threshold in order to configure the illuminated surfaces
  59660. */
  59661. brightThreshold: number;
  59662. /**
  59663. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59664. */
  59665. blurWidth: number;
  59666. /**
  59667. * Sets if the blur for highlighted surfaces must be only horizontal
  59668. */
  59669. horizontalBlur: boolean;
  59670. /**
  59671. * Gets the overall exposure used by the pipeline
  59672. */
  59673. /**
  59674. * Sets the overall exposure used by the pipeline
  59675. */
  59676. exposure: number;
  59677. /**
  59678. * Texture used typically to simulate "dirty" on camera lens
  59679. */
  59680. lensTexture: Nullable<Texture>;
  59681. /**
  59682. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59683. */
  59684. volumetricLightCoefficient: number;
  59685. /**
  59686. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59687. */
  59688. volumetricLightPower: number;
  59689. /**
  59690. * Used the set the blur intensity to smooth the volumetric lights
  59691. */
  59692. volumetricLightBlurScale: number;
  59693. /**
  59694. * Light (spot or directional) used to generate the volumetric lights rays
  59695. * The source light must have a shadow generate so the pipeline can get its
  59696. * depth map
  59697. */
  59698. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59699. /**
  59700. * For eye adaptation, represents the minimum luminance the eye can see
  59701. */
  59702. hdrMinimumLuminance: number;
  59703. /**
  59704. * For eye adaptation, represents the decrease luminance speed
  59705. */
  59706. hdrDecreaseRate: number;
  59707. /**
  59708. * For eye adaptation, represents the increase luminance speed
  59709. */
  59710. hdrIncreaseRate: number;
  59711. /**
  59712. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59713. */
  59714. /**
  59715. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59716. */
  59717. hdrAutoExposure: boolean;
  59718. /**
  59719. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59720. */
  59721. lensColorTexture: Nullable<Texture>;
  59722. /**
  59723. * The overall strengh for the lens flare effect
  59724. */
  59725. lensFlareStrength: number;
  59726. /**
  59727. * Dispersion coefficient for lens flare ghosts
  59728. */
  59729. lensFlareGhostDispersal: number;
  59730. /**
  59731. * Main lens flare halo width
  59732. */
  59733. lensFlareHaloWidth: number;
  59734. /**
  59735. * Based on the lens distortion effect, defines how much the lens flare result
  59736. * is distorted
  59737. */
  59738. lensFlareDistortionStrength: number;
  59739. /**
  59740. * Configures the blur intensity used for for lens flare (halo)
  59741. */
  59742. lensFlareBlurWidth: number;
  59743. /**
  59744. * Lens star texture must be used to simulate rays on the flares and is available
  59745. * in the documentation
  59746. */
  59747. lensStarTexture: Nullable<Texture>;
  59748. /**
  59749. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59750. * flare effect by taking account of the dirt texture
  59751. */
  59752. lensFlareDirtTexture: Nullable<Texture>;
  59753. /**
  59754. * Represents the focal length for the depth of field effect
  59755. */
  59756. depthOfFieldDistance: number;
  59757. /**
  59758. * Represents the blur intensity for the blurred part of the depth of field effect
  59759. */
  59760. depthOfFieldBlurWidth: number;
  59761. /**
  59762. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59763. */
  59764. /**
  59765. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59766. */
  59767. motionStrength: number;
  59768. /**
  59769. * Gets wether or not the motion blur post-process is object based or screen based.
  59770. */
  59771. /**
  59772. * Sets wether or not the motion blur post-process should be object based or screen based
  59773. */
  59774. objectBasedMotionBlur: boolean;
  59775. /**
  59776. * List of animations for the pipeline (IAnimatable implementation)
  59777. */
  59778. animations: Animation[];
  59779. /**
  59780. * Private members
  59781. */
  59782. private _scene;
  59783. private _currentDepthOfFieldSource;
  59784. private _basePostProcess;
  59785. private _fixedExposure;
  59786. private _currentExposure;
  59787. private _hdrAutoExposure;
  59788. private _hdrCurrentLuminance;
  59789. private _motionStrength;
  59790. private _isObjectBasedMotionBlur;
  59791. private _floatTextureType;
  59792. private _camerasToBeAttached;
  59793. private _ratio;
  59794. private _bloomEnabled;
  59795. private _depthOfFieldEnabled;
  59796. private _vlsEnabled;
  59797. private _lensFlareEnabled;
  59798. private _hdrEnabled;
  59799. private _motionBlurEnabled;
  59800. private _fxaaEnabled;
  59801. private _motionBlurSamples;
  59802. private _volumetricLightStepsCount;
  59803. private _samples;
  59804. /**
  59805. * @ignore
  59806. * Specifies if the bloom pipeline is enabled
  59807. */
  59808. BloomEnabled: boolean;
  59809. /**
  59810. * @ignore
  59811. * Specifies if the depth of field pipeline is enabed
  59812. */
  59813. DepthOfFieldEnabled: boolean;
  59814. /**
  59815. * @ignore
  59816. * Specifies if the lens flare pipeline is enabed
  59817. */
  59818. LensFlareEnabled: boolean;
  59819. /**
  59820. * @ignore
  59821. * Specifies if the HDR pipeline is enabled
  59822. */
  59823. HDREnabled: boolean;
  59824. /**
  59825. * @ignore
  59826. * Specifies if the volumetric lights scattering effect is enabled
  59827. */
  59828. VLSEnabled: boolean;
  59829. /**
  59830. * @ignore
  59831. * Specifies if the motion blur effect is enabled
  59832. */
  59833. MotionBlurEnabled: boolean;
  59834. /**
  59835. * Specifies if anti-aliasing is enabled
  59836. */
  59837. fxaaEnabled: boolean;
  59838. /**
  59839. * Specifies the number of steps used to calculate the volumetric lights
  59840. * Typically in interval [50, 200]
  59841. */
  59842. volumetricLightStepsCount: number;
  59843. /**
  59844. * Specifies the number of samples used for the motion blur effect
  59845. * Typically in interval [16, 64]
  59846. */
  59847. motionBlurSamples: number;
  59848. /**
  59849. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59850. */
  59851. samples: number;
  59852. /**
  59853. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59854. * @constructor
  59855. * @param name The rendering pipeline name
  59856. * @param scene The scene linked to this pipeline
  59857. * @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)
  59858. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59859. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59860. */
  59861. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59862. private _buildPipeline;
  59863. private _createDownSampleX4PostProcess;
  59864. private _createBrightPassPostProcess;
  59865. private _createBlurPostProcesses;
  59866. private _createTextureAdderPostProcess;
  59867. private _createVolumetricLightPostProcess;
  59868. private _createLuminancePostProcesses;
  59869. private _createHdrPostProcess;
  59870. private _createLensFlarePostProcess;
  59871. private _createDepthOfFieldPostProcess;
  59872. private _createMotionBlurPostProcess;
  59873. private _getDepthTexture;
  59874. private _disposePostProcesses;
  59875. /**
  59876. * Dispose of the pipeline and stop all post processes
  59877. */
  59878. dispose(): void;
  59879. /**
  59880. * Serialize the rendering pipeline (Used when exporting)
  59881. * @returns the serialized object
  59882. */
  59883. serialize(): any;
  59884. /**
  59885. * Parse the serialized pipeline
  59886. * @param source Source pipeline.
  59887. * @param scene The scene to load the pipeline to.
  59888. * @param rootUrl The URL of the serialized pipeline.
  59889. * @returns An instantiated pipeline from the serialized object.
  59890. */
  59891. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59892. /**
  59893. * Luminance steps
  59894. */
  59895. static LuminanceSteps: number;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /** @hidden */
  59900. export var tonemapPixelShader: {
  59901. name: string;
  59902. shader: string;
  59903. };
  59904. }
  59905. declare module BABYLON {
  59906. /** Defines operator used for tonemapping */
  59907. export enum TonemappingOperator {
  59908. /** Hable */
  59909. Hable = 0,
  59910. /** Reinhard */
  59911. Reinhard = 1,
  59912. /** HejiDawson */
  59913. HejiDawson = 2,
  59914. /** Photographic */
  59915. Photographic = 3
  59916. }
  59917. /**
  59918. * Defines a post process to apply tone mapping
  59919. */
  59920. export class TonemapPostProcess extends PostProcess {
  59921. private _operator;
  59922. /** Defines the required exposure adjustement */
  59923. exposureAdjustment: number;
  59924. /**
  59925. * Creates a new TonemapPostProcess
  59926. * @param name defines the name of the postprocess
  59927. * @param _operator defines the operator to use
  59928. * @param exposureAdjustment defines the required exposure adjustement
  59929. * @param camera defines the camera to use (can be null)
  59930. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59931. * @param engine defines the hosting engine (can be ignore if camera is set)
  59932. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59933. */
  59934. constructor(name: string, _operator: TonemappingOperator,
  59935. /** Defines the required exposure adjustement */
  59936. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59937. }
  59938. }
  59939. declare module BABYLON {
  59940. /** @hidden */
  59941. export var depthVertexShader: {
  59942. name: string;
  59943. shader: string;
  59944. };
  59945. }
  59946. declare module BABYLON {
  59947. /** @hidden */
  59948. export var volumetricLightScatteringPixelShader: {
  59949. name: string;
  59950. shader: string;
  59951. };
  59952. }
  59953. declare module BABYLON {
  59954. /** @hidden */
  59955. export var volumetricLightScatteringPassVertexShader: {
  59956. name: string;
  59957. shader: string;
  59958. };
  59959. }
  59960. declare module BABYLON {
  59961. /** @hidden */
  59962. export var volumetricLightScatteringPassPixelShader: {
  59963. name: string;
  59964. shader: string;
  59965. };
  59966. }
  59967. declare module BABYLON {
  59968. /**
  59969. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59970. */
  59971. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59972. private _volumetricLightScatteringPass;
  59973. private _volumetricLightScatteringRTT;
  59974. private _viewPort;
  59975. private _screenCoordinates;
  59976. private _cachedDefines;
  59977. /**
  59978. * If not undefined, the mesh position is computed from the attached node position
  59979. */
  59980. attachedNode: {
  59981. position: Vector3;
  59982. };
  59983. /**
  59984. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59985. */
  59986. customMeshPosition: Vector3;
  59987. /**
  59988. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59989. */
  59990. useCustomMeshPosition: boolean;
  59991. /**
  59992. * If the post-process should inverse the light scattering direction
  59993. */
  59994. invert: boolean;
  59995. /**
  59996. * The internal mesh used by the post-process
  59997. */
  59998. mesh: Mesh;
  59999. /**
  60000. * @hidden
  60001. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60002. */
  60003. useDiffuseColor: boolean;
  60004. /**
  60005. * Array containing the excluded meshes not rendered in the internal pass
  60006. */
  60007. excludedMeshes: AbstractMesh[];
  60008. /**
  60009. * Controls the overall intensity of the post-process
  60010. */
  60011. exposure: number;
  60012. /**
  60013. * Dissipates each sample's contribution in range [0, 1]
  60014. */
  60015. decay: number;
  60016. /**
  60017. * Controls the overall intensity of each sample
  60018. */
  60019. weight: number;
  60020. /**
  60021. * Controls the density of each sample
  60022. */
  60023. density: number;
  60024. /**
  60025. * @constructor
  60026. * @param name The post-process name
  60027. * @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)
  60028. * @param camera The camera that the post-process will be attached to
  60029. * @param mesh The mesh used to create the light scattering
  60030. * @param samples The post-process quality, default 100
  60031. * @param samplingModeThe post-process filtering mode
  60032. * @param engine The babylon engine
  60033. * @param reusable If the post-process is reusable
  60034. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60035. */
  60036. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60037. /**
  60038. * Returns the string "VolumetricLightScatteringPostProcess"
  60039. * @returns "VolumetricLightScatteringPostProcess"
  60040. */
  60041. getClassName(): string;
  60042. private _isReady;
  60043. /**
  60044. * Sets the new light position for light scattering effect
  60045. * @param position The new custom light position
  60046. */
  60047. setCustomMeshPosition(position: Vector3): void;
  60048. /**
  60049. * Returns the light position for light scattering effect
  60050. * @return Vector3 The custom light position
  60051. */
  60052. getCustomMeshPosition(): Vector3;
  60053. /**
  60054. * Disposes the internal assets and detaches the post-process from the camera
  60055. */
  60056. dispose(camera: Camera): void;
  60057. /**
  60058. * Returns the render target texture used by the post-process
  60059. * @return the render target texture used by the post-process
  60060. */
  60061. getPass(): RenderTargetTexture;
  60062. private _meshExcluded;
  60063. private _createPass;
  60064. private _updateMeshScreenCoordinates;
  60065. /**
  60066. * Creates a default mesh for the Volumeric Light Scattering post-process
  60067. * @param name The mesh name
  60068. * @param scene The scene where to create the mesh
  60069. * @return the default mesh
  60070. */
  60071. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60072. }
  60073. }
  60074. declare module BABYLON {
  60075. interface Scene {
  60076. /** @hidden (Backing field) */
  60077. _boundingBoxRenderer: BoundingBoxRenderer;
  60078. /** @hidden (Backing field) */
  60079. _forceShowBoundingBoxes: boolean;
  60080. /**
  60081. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60082. */
  60083. forceShowBoundingBoxes: boolean;
  60084. /**
  60085. * Gets the bounding box renderer associated with the scene
  60086. * @returns a BoundingBoxRenderer
  60087. */
  60088. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60089. }
  60090. interface AbstractMesh {
  60091. /** @hidden (Backing field) */
  60092. _showBoundingBox: boolean;
  60093. /**
  60094. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60095. */
  60096. showBoundingBox: boolean;
  60097. }
  60098. /**
  60099. * Component responsible of rendering the bounding box of the meshes in a scene.
  60100. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60101. */
  60102. export class BoundingBoxRenderer implements ISceneComponent {
  60103. /**
  60104. * The component name helpfull to identify the component in the list of scene components.
  60105. */
  60106. readonly name: string;
  60107. /**
  60108. * The scene the component belongs to.
  60109. */
  60110. scene: Scene;
  60111. /**
  60112. * Color of the bounding box lines placed in front of an object
  60113. */
  60114. frontColor: Color3;
  60115. /**
  60116. * Color of the bounding box lines placed behind an object
  60117. */
  60118. backColor: Color3;
  60119. /**
  60120. * Defines if the renderer should show the back lines or not
  60121. */
  60122. showBackLines: boolean;
  60123. /**
  60124. * @hidden
  60125. */
  60126. renderList: SmartArray<BoundingBox>;
  60127. private _colorShader;
  60128. private _vertexBuffers;
  60129. private _indexBuffer;
  60130. private _fillIndexBuffer;
  60131. private _fillIndexData;
  60132. /**
  60133. * Instantiates a new bounding box renderer in a scene.
  60134. * @param scene the scene the renderer renders in
  60135. */
  60136. constructor(scene: Scene);
  60137. /**
  60138. * Registers the component in a given scene
  60139. */
  60140. register(): void;
  60141. private _evaluateSubMesh;
  60142. private _activeMesh;
  60143. private _prepareRessources;
  60144. private _createIndexBuffer;
  60145. /**
  60146. * Rebuilds the elements related to this component in case of
  60147. * context lost for instance.
  60148. */
  60149. rebuild(): void;
  60150. /**
  60151. * @hidden
  60152. */
  60153. reset(): void;
  60154. /**
  60155. * Render the bounding boxes of a specific rendering group
  60156. * @param renderingGroupId defines the rendering group to render
  60157. */
  60158. render(renderingGroupId: number): void;
  60159. /**
  60160. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60161. * @param mesh Define the mesh to render the occlusion bounding box for
  60162. */
  60163. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60164. /**
  60165. * Dispose and release the resources attached to this renderer.
  60166. */
  60167. dispose(): void;
  60168. }
  60169. }
  60170. declare module BABYLON {
  60171. /** @hidden */
  60172. export var depthPixelShader: {
  60173. name: string;
  60174. shader: string;
  60175. };
  60176. }
  60177. declare module BABYLON {
  60178. /**
  60179. * This represents a depth renderer in Babylon.
  60180. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60181. */
  60182. export class DepthRenderer {
  60183. private _scene;
  60184. private _depthMap;
  60185. private _effect;
  60186. private readonly _storeNonLinearDepth;
  60187. private readonly _clearColor;
  60188. /** Get if the depth renderer is using packed depth or not */
  60189. readonly isPacked: boolean;
  60190. private _cachedDefines;
  60191. private _camera;
  60192. /**
  60193. * Specifiess that the depth renderer will only be used within
  60194. * the camera it is created for.
  60195. * This can help forcing its rendering during the camera processing.
  60196. */
  60197. useOnlyInActiveCamera: boolean;
  60198. /** @hidden */
  60199. static _SceneComponentInitialization: (scene: Scene) => void;
  60200. /**
  60201. * Instantiates a depth renderer
  60202. * @param scene The scene the renderer belongs to
  60203. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60204. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60205. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60206. */
  60207. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60208. /**
  60209. * Creates the depth rendering effect and checks if the effect is ready.
  60210. * @param subMesh The submesh to be used to render the depth map of
  60211. * @param useInstances If multiple world instances should be used
  60212. * @returns if the depth renderer is ready to render the depth map
  60213. */
  60214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60215. /**
  60216. * Gets the texture which the depth map will be written to.
  60217. * @returns The depth map texture
  60218. */
  60219. getDepthMap(): RenderTargetTexture;
  60220. /**
  60221. * Disposes of the depth renderer.
  60222. */
  60223. dispose(): void;
  60224. }
  60225. }
  60226. declare module BABYLON {
  60227. interface Scene {
  60228. /** @hidden (Backing field) */
  60229. _depthRenderer: {
  60230. [id: string]: DepthRenderer;
  60231. };
  60232. /**
  60233. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60234. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60235. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60236. * @returns the created depth renderer
  60237. */
  60238. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60239. /**
  60240. * Disables a depth renderer for a given camera
  60241. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60242. */
  60243. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60244. }
  60245. /**
  60246. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60247. * in several rendering techniques.
  60248. */
  60249. export class DepthRendererSceneComponent implements ISceneComponent {
  60250. /**
  60251. * The component name helpfull to identify the component in the list of scene components.
  60252. */
  60253. readonly name: string;
  60254. /**
  60255. * The scene the component belongs to.
  60256. */
  60257. scene: Scene;
  60258. /**
  60259. * Creates a new instance of the component for the given scene
  60260. * @param scene Defines the scene to register the component in
  60261. */
  60262. constructor(scene: Scene);
  60263. /**
  60264. * Registers the component in a given scene
  60265. */
  60266. register(): void;
  60267. /**
  60268. * Rebuilds the elements related to this component in case of
  60269. * context lost for instance.
  60270. */
  60271. rebuild(): void;
  60272. /**
  60273. * Disposes the component and the associated ressources
  60274. */
  60275. dispose(): void;
  60276. private _gatherRenderTargets;
  60277. private _gatherActiveCameraRenderTargets;
  60278. }
  60279. }
  60280. declare module BABYLON {
  60281. /** @hidden */
  60282. export var outlinePixelShader: {
  60283. name: string;
  60284. shader: string;
  60285. };
  60286. }
  60287. declare module BABYLON {
  60288. /** @hidden */
  60289. export var outlineVertexShader: {
  60290. name: string;
  60291. shader: string;
  60292. };
  60293. }
  60294. declare module BABYLON {
  60295. interface Scene {
  60296. /** @hidden */
  60297. _outlineRenderer: OutlineRenderer;
  60298. /**
  60299. * Gets the outline renderer associated with the scene
  60300. * @returns a OutlineRenderer
  60301. */
  60302. getOutlineRenderer(): OutlineRenderer;
  60303. }
  60304. interface AbstractMesh {
  60305. /** @hidden (Backing field) */
  60306. _renderOutline: boolean;
  60307. /**
  60308. * Gets or sets a boolean indicating if the outline must be rendered as well
  60309. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60310. */
  60311. renderOutline: boolean;
  60312. /** @hidden (Backing field) */
  60313. _renderOverlay: boolean;
  60314. /**
  60315. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60316. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60317. */
  60318. renderOverlay: boolean;
  60319. }
  60320. /**
  60321. * This class is responsible to draw bothe outline/overlay of meshes.
  60322. * It should not be used directly but through the available method on mesh.
  60323. */
  60324. export class OutlineRenderer implements ISceneComponent {
  60325. /**
  60326. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60327. */
  60328. private static _StencilReference;
  60329. /**
  60330. * The name of the component. Each component must have a unique name.
  60331. */
  60332. name: string;
  60333. /**
  60334. * The scene the component belongs to.
  60335. */
  60336. scene: Scene;
  60337. /**
  60338. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60339. */
  60340. zOffset: number;
  60341. private _engine;
  60342. private _effect;
  60343. private _cachedDefines;
  60344. private _savedDepthWrite;
  60345. /**
  60346. * Instantiates a new outline renderer. (There could be only one per scene).
  60347. * @param scene Defines the scene it belongs to
  60348. */
  60349. constructor(scene: Scene);
  60350. /**
  60351. * Register the component to one instance of a scene.
  60352. */
  60353. register(): void;
  60354. /**
  60355. * Rebuilds the elements related to this component in case of
  60356. * context lost for instance.
  60357. */
  60358. rebuild(): void;
  60359. /**
  60360. * Disposes the component and the associated ressources.
  60361. */
  60362. dispose(): void;
  60363. /**
  60364. * Renders the outline in the canvas.
  60365. * @param subMesh Defines the sumesh to render
  60366. * @param batch Defines the batch of meshes in case of instances
  60367. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60368. */
  60369. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60370. /**
  60371. * Returns whether or not the outline renderer is ready for a given submesh.
  60372. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60373. * @param subMesh Defines the submesh to check readyness for
  60374. * @param useInstances Defines wheter wee are trying to render instances or not
  60375. * @returns true if ready otherwise false
  60376. */
  60377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60378. private _beforeRenderingMesh;
  60379. private _afterRenderingMesh;
  60380. }
  60381. }
  60382. declare module BABYLON {
  60383. /**
  60384. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60385. * @see http://doc.babylonjs.com/babylon101/sprites
  60386. */
  60387. export class SpritePackedManager extends SpriteManager {
  60388. /** defines the packed manager's name */
  60389. name: string;
  60390. /**
  60391. * Creates a new sprite manager from a packed sprite sheet
  60392. * @param name defines the manager's name
  60393. * @param imgUrl defines the sprite sheet url
  60394. * @param capacity defines the maximum allowed number of sprites
  60395. * @param scene defines the hosting scene
  60396. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60397. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60398. * @param samplingMode defines the smapling mode to use with spritesheet
  60399. * @param fromPacked set to true; do not alter
  60400. */
  60401. constructor(
  60402. /** defines the packed manager's name */
  60403. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60404. }
  60405. }
  60406. declare module BABYLON {
  60407. /**
  60408. * Defines the list of states available for a task inside a AssetsManager
  60409. */
  60410. export enum AssetTaskState {
  60411. /**
  60412. * Initialization
  60413. */
  60414. INIT = 0,
  60415. /**
  60416. * Running
  60417. */
  60418. RUNNING = 1,
  60419. /**
  60420. * Done
  60421. */
  60422. DONE = 2,
  60423. /**
  60424. * Error
  60425. */
  60426. ERROR = 3
  60427. }
  60428. /**
  60429. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60430. */
  60431. export abstract class AbstractAssetTask {
  60432. /**
  60433. * Task name
  60434. */ name: string;
  60435. /**
  60436. * Callback called when the task is successful
  60437. */
  60438. onSuccess: (task: any) => void;
  60439. /**
  60440. * Callback called when the task is not successful
  60441. */
  60442. onError: (task: any, message?: string, exception?: any) => void;
  60443. /**
  60444. * Creates a new AssetsManager
  60445. * @param name defines the name of the task
  60446. */
  60447. constructor(
  60448. /**
  60449. * Task name
  60450. */ name: string);
  60451. private _isCompleted;
  60452. private _taskState;
  60453. private _errorObject;
  60454. /**
  60455. * Get if the task is completed
  60456. */
  60457. readonly isCompleted: boolean;
  60458. /**
  60459. * Gets the current state of the task
  60460. */
  60461. readonly taskState: AssetTaskState;
  60462. /**
  60463. * Gets the current error object (if task is in error)
  60464. */
  60465. readonly errorObject: {
  60466. message?: string;
  60467. exception?: any;
  60468. };
  60469. /**
  60470. * Internal only
  60471. * @hidden
  60472. */
  60473. _setErrorObject(message?: string, exception?: any): void;
  60474. /**
  60475. * Execute the current task
  60476. * @param scene defines the scene where you want your assets to be loaded
  60477. * @param onSuccess is a callback called when the task is successfully executed
  60478. * @param onError is a callback called if an error occurs
  60479. */
  60480. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60481. /**
  60482. * Execute the current task
  60483. * @param scene defines the scene where you want your assets to be loaded
  60484. * @param onSuccess is a callback called when the task is successfully executed
  60485. * @param onError is a callback called if an error occurs
  60486. */
  60487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60488. /**
  60489. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60490. * This can be used with failed tasks that have the reason for failure fixed.
  60491. */
  60492. reset(): void;
  60493. private onErrorCallback;
  60494. private onDoneCallback;
  60495. }
  60496. /**
  60497. * Define the interface used by progress events raised during assets loading
  60498. */
  60499. export interface IAssetsProgressEvent {
  60500. /**
  60501. * Defines the number of remaining tasks to process
  60502. */
  60503. remainingCount: number;
  60504. /**
  60505. * Defines the total number of tasks
  60506. */
  60507. totalCount: number;
  60508. /**
  60509. * Defines the task that was just processed
  60510. */
  60511. task: AbstractAssetTask;
  60512. }
  60513. /**
  60514. * Class used to share progress information about assets loading
  60515. */
  60516. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60517. /**
  60518. * Defines the number of remaining tasks to process
  60519. */
  60520. remainingCount: number;
  60521. /**
  60522. * Defines the total number of tasks
  60523. */
  60524. totalCount: number;
  60525. /**
  60526. * Defines the task that was just processed
  60527. */
  60528. task: AbstractAssetTask;
  60529. /**
  60530. * Creates a AssetsProgressEvent
  60531. * @param remainingCount defines the number of remaining tasks to process
  60532. * @param totalCount defines the total number of tasks
  60533. * @param task defines the task that was just processed
  60534. */
  60535. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60536. }
  60537. /**
  60538. * Define a task used by AssetsManager to load meshes
  60539. */
  60540. export class MeshAssetTask extends AbstractAssetTask {
  60541. /**
  60542. * Defines the name of the task
  60543. */
  60544. name: string;
  60545. /**
  60546. * Defines the list of mesh's names you want to load
  60547. */
  60548. meshesNames: any;
  60549. /**
  60550. * Defines the root url to use as a base to load your meshes and associated resources
  60551. */
  60552. rootUrl: string;
  60553. /**
  60554. * Defines the filename of the scene to load from
  60555. */
  60556. sceneFilename: string;
  60557. /**
  60558. * Gets the list of loaded meshes
  60559. */
  60560. loadedMeshes: Array<AbstractMesh>;
  60561. /**
  60562. * Gets the list of loaded particle systems
  60563. */
  60564. loadedParticleSystems: Array<IParticleSystem>;
  60565. /**
  60566. * Gets the list of loaded skeletons
  60567. */
  60568. loadedSkeletons: Array<Skeleton>;
  60569. /**
  60570. * Gets the list of loaded animation groups
  60571. */
  60572. loadedAnimationGroups: Array<AnimationGroup>;
  60573. /**
  60574. * Callback called when the task is successful
  60575. */
  60576. onSuccess: (task: MeshAssetTask) => void;
  60577. /**
  60578. * Callback called when the task is successful
  60579. */
  60580. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60581. /**
  60582. * Creates a new MeshAssetTask
  60583. * @param name defines the name of the task
  60584. * @param meshesNames defines the list of mesh's names you want to load
  60585. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60586. * @param sceneFilename defines the filename of the scene to load from
  60587. */
  60588. constructor(
  60589. /**
  60590. * Defines the name of the task
  60591. */
  60592. name: string,
  60593. /**
  60594. * Defines the list of mesh's names you want to load
  60595. */
  60596. meshesNames: any,
  60597. /**
  60598. * Defines the root url to use as a base to load your meshes and associated resources
  60599. */
  60600. rootUrl: string,
  60601. /**
  60602. * Defines the filename of the scene to load from
  60603. */
  60604. sceneFilename: string);
  60605. /**
  60606. * Execute the current task
  60607. * @param scene defines the scene where you want your assets to be loaded
  60608. * @param onSuccess is a callback called when the task is successfully executed
  60609. * @param onError is a callback called if an error occurs
  60610. */
  60611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60612. }
  60613. /**
  60614. * Define a task used by AssetsManager to load text content
  60615. */
  60616. export class TextFileAssetTask extends AbstractAssetTask {
  60617. /**
  60618. * Defines the name of the task
  60619. */
  60620. name: string;
  60621. /**
  60622. * Defines the location of the file to load
  60623. */
  60624. url: string;
  60625. /**
  60626. * Gets the loaded text string
  60627. */
  60628. text: string;
  60629. /**
  60630. * Callback called when the task is successful
  60631. */
  60632. onSuccess: (task: TextFileAssetTask) => void;
  60633. /**
  60634. * Callback called when the task is successful
  60635. */
  60636. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60637. /**
  60638. * Creates a new TextFileAssetTask object
  60639. * @param name defines the name of the task
  60640. * @param url defines the location of the file to load
  60641. */
  60642. constructor(
  60643. /**
  60644. * Defines the name of the task
  60645. */
  60646. name: string,
  60647. /**
  60648. * Defines the location of the file to load
  60649. */
  60650. url: string);
  60651. /**
  60652. * Execute the current task
  60653. * @param scene defines the scene where you want your assets to be loaded
  60654. * @param onSuccess is a callback called when the task is successfully executed
  60655. * @param onError is a callback called if an error occurs
  60656. */
  60657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60658. }
  60659. /**
  60660. * Define a task used by AssetsManager to load binary data
  60661. */
  60662. export class BinaryFileAssetTask extends AbstractAssetTask {
  60663. /**
  60664. * Defines the name of the task
  60665. */
  60666. name: string;
  60667. /**
  60668. * Defines the location of the file to load
  60669. */
  60670. url: string;
  60671. /**
  60672. * Gets the lodaded data (as an array buffer)
  60673. */
  60674. data: ArrayBuffer;
  60675. /**
  60676. * Callback called when the task is successful
  60677. */
  60678. onSuccess: (task: BinaryFileAssetTask) => void;
  60679. /**
  60680. * Callback called when the task is successful
  60681. */
  60682. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60683. /**
  60684. * Creates a new BinaryFileAssetTask object
  60685. * @param name defines the name of the new task
  60686. * @param url defines the location of the file to load
  60687. */
  60688. constructor(
  60689. /**
  60690. * Defines the name of the task
  60691. */
  60692. name: string,
  60693. /**
  60694. * Defines the location of the file to load
  60695. */
  60696. url: string);
  60697. /**
  60698. * Execute the current task
  60699. * @param scene defines the scene where you want your assets to be loaded
  60700. * @param onSuccess is a callback called when the task is successfully executed
  60701. * @param onError is a callback called if an error occurs
  60702. */
  60703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60704. }
  60705. /**
  60706. * Define a task used by AssetsManager to load images
  60707. */
  60708. export class ImageAssetTask extends AbstractAssetTask {
  60709. /**
  60710. * Defines the name of the task
  60711. */
  60712. name: string;
  60713. /**
  60714. * Defines the location of the image to load
  60715. */
  60716. url: string;
  60717. /**
  60718. * Gets the loaded images
  60719. */
  60720. image: HTMLImageElement;
  60721. /**
  60722. * Callback called when the task is successful
  60723. */
  60724. onSuccess: (task: ImageAssetTask) => void;
  60725. /**
  60726. * Callback called when the task is successful
  60727. */
  60728. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60729. /**
  60730. * Creates a new ImageAssetTask
  60731. * @param name defines the name of the task
  60732. * @param url defines the location of the image to load
  60733. */
  60734. constructor(
  60735. /**
  60736. * Defines the name of the task
  60737. */
  60738. name: string,
  60739. /**
  60740. * Defines the location of the image to load
  60741. */
  60742. url: string);
  60743. /**
  60744. * Execute the current task
  60745. * @param scene defines the scene where you want your assets to be loaded
  60746. * @param onSuccess is a callback called when the task is successfully executed
  60747. * @param onError is a callback called if an error occurs
  60748. */
  60749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60750. }
  60751. /**
  60752. * Defines the interface used by texture loading tasks
  60753. */
  60754. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60755. /**
  60756. * Gets the loaded texture
  60757. */
  60758. texture: TEX;
  60759. }
  60760. /**
  60761. * Define a task used by AssetsManager to load 2D textures
  60762. */
  60763. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60764. /**
  60765. * Defines the name of the task
  60766. */
  60767. name: string;
  60768. /**
  60769. * Defines the location of the file to load
  60770. */
  60771. url: string;
  60772. /**
  60773. * Defines if mipmap should not be generated (default is false)
  60774. */
  60775. noMipmap?: boolean | undefined;
  60776. /**
  60777. * Defines if texture must be inverted on Y axis (default is false)
  60778. */
  60779. invertY?: boolean | undefined;
  60780. /**
  60781. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60782. */
  60783. samplingMode: number;
  60784. /**
  60785. * Gets the loaded texture
  60786. */
  60787. texture: Texture;
  60788. /**
  60789. * Callback called when the task is successful
  60790. */
  60791. onSuccess: (task: TextureAssetTask) => void;
  60792. /**
  60793. * Callback called when the task is successful
  60794. */
  60795. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60796. /**
  60797. * Creates a new TextureAssetTask object
  60798. * @param name defines the name of the task
  60799. * @param url defines the location of the file to load
  60800. * @param noMipmap defines if mipmap should not be generated (default is false)
  60801. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60802. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60803. */
  60804. constructor(
  60805. /**
  60806. * Defines the name of the task
  60807. */
  60808. name: string,
  60809. /**
  60810. * Defines the location of the file to load
  60811. */
  60812. url: string,
  60813. /**
  60814. * Defines if mipmap should not be generated (default is false)
  60815. */
  60816. noMipmap?: boolean | undefined,
  60817. /**
  60818. * Defines if texture must be inverted on Y axis (default is false)
  60819. */
  60820. invertY?: boolean | undefined,
  60821. /**
  60822. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60823. */
  60824. samplingMode?: number);
  60825. /**
  60826. * Execute the current task
  60827. * @param scene defines the scene where you want your assets to be loaded
  60828. * @param onSuccess is a callback called when the task is successfully executed
  60829. * @param onError is a callback called if an error occurs
  60830. */
  60831. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60832. }
  60833. /**
  60834. * Define a task used by AssetsManager to load cube textures
  60835. */
  60836. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60837. /**
  60838. * Defines the name of the task
  60839. */
  60840. name: string;
  60841. /**
  60842. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60843. */
  60844. url: string;
  60845. /**
  60846. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60847. */
  60848. extensions?: string[] | undefined;
  60849. /**
  60850. * Defines if mipmaps should not be generated (default is false)
  60851. */
  60852. noMipmap?: boolean | undefined;
  60853. /**
  60854. * Defines the explicit list of files (undefined by default)
  60855. */
  60856. files?: string[] | undefined;
  60857. /**
  60858. * Gets the loaded texture
  60859. */
  60860. texture: CubeTexture;
  60861. /**
  60862. * Callback called when the task is successful
  60863. */
  60864. onSuccess: (task: CubeTextureAssetTask) => void;
  60865. /**
  60866. * Callback called when the task is successful
  60867. */
  60868. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60869. /**
  60870. * Creates a new CubeTextureAssetTask
  60871. * @param name defines the name of the task
  60872. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60873. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60874. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60875. * @param files defines the explicit list of files (undefined by default)
  60876. */
  60877. constructor(
  60878. /**
  60879. * Defines the name of the task
  60880. */
  60881. name: string,
  60882. /**
  60883. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60884. */
  60885. url: string,
  60886. /**
  60887. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60888. */
  60889. extensions?: string[] | undefined,
  60890. /**
  60891. * Defines if mipmaps should not be generated (default is false)
  60892. */
  60893. noMipmap?: boolean | undefined,
  60894. /**
  60895. * Defines the explicit list of files (undefined by default)
  60896. */
  60897. files?: string[] | undefined);
  60898. /**
  60899. * Execute the current task
  60900. * @param scene defines the scene where you want your assets to be loaded
  60901. * @param onSuccess is a callback called when the task is successfully executed
  60902. * @param onError is a callback called if an error occurs
  60903. */
  60904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60905. }
  60906. /**
  60907. * Define a task used by AssetsManager to load HDR cube textures
  60908. */
  60909. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60910. /**
  60911. * Defines the name of the task
  60912. */
  60913. name: string;
  60914. /**
  60915. * Defines the location of the file to load
  60916. */
  60917. url: string;
  60918. /**
  60919. * Defines the desired size (the more it increases the longer the generation will be)
  60920. */
  60921. size: number;
  60922. /**
  60923. * Defines if mipmaps should not be generated (default is false)
  60924. */
  60925. noMipmap: boolean;
  60926. /**
  60927. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60928. */
  60929. generateHarmonics: boolean;
  60930. /**
  60931. * 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)
  60932. */
  60933. gammaSpace: boolean;
  60934. /**
  60935. * Internal Use Only
  60936. */
  60937. reserved: boolean;
  60938. /**
  60939. * Gets the loaded texture
  60940. */
  60941. texture: HDRCubeTexture;
  60942. /**
  60943. * Callback called when the task is successful
  60944. */
  60945. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60946. /**
  60947. * Callback called when the task is successful
  60948. */
  60949. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60950. /**
  60951. * Creates a new HDRCubeTextureAssetTask object
  60952. * @param name defines the name of the task
  60953. * @param url defines the location of the file to load
  60954. * @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.
  60955. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60956. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60957. * @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)
  60958. * @param reserved Internal use only
  60959. */
  60960. constructor(
  60961. /**
  60962. * Defines the name of the task
  60963. */
  60964. name: string,
  60965. /**
  60966. * Defines the location of the file to load
  60967. */
  60968. url: string,
  60969. /**
  60970. * Defines the desired size (the more it increases the longer the generation will be)
  60971. */
  60972. size: number,
  60973. /**
  60974. * Defines if mipmaps should not be generated (default is false)
  60975. */
  60976. noMipmap?: boolean,
  60977. /**
  60978. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60979. */
  60980. generateHarmonics?: boolean,
  60981. /**
  60982. * 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)
  60983. */
  60984. gammaSpace?: boolean,
  60985. /**
  60986. * Internal Use Only
  60987. */
  60988. reserved?: boolean);
  60989. /**
  60990. * Execute the current task
  60991. * @param scene defines the scene where you want your assets to be loaded
  60992. * @param onSuccess is a callback called when the task is successfully executed
  60993. * @param onError is a callback called if an error occurs
  60994. */
  60995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60996. }
  60997. /**
  60998. * Define a task used by AssetsManager to load Equirectangular cube textures
  60999. */
  61000. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61001. /**
  61002. * Defines the name of the task
  61003. */
  61004. name: string;
  61005. /**
  61006. * Defines the location of the file to load
  61007. */
  61008. url: string;
  61009. /**
  61010. * Defines the desired size (the more it increases the longer the generation will be)
  61011. */
  61012. size: number;
  61013. /**
  61014. * Defines if mipmaps should not be generated (default is false)
  61015. */
  61016. noMipmap: boolean;
  61017. /**
  61018. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61019. * but the standard material would require them in Gamma space) (default is true)
  61020. */
  61021. gammaSpace: boolean;
  61022. /**
  61023. * Gets the loaded texture
  61024. */
  61025. texture: EquiRectangularCubeTexture;
  61026. /**
  61027. * Callback called when the task is successful
  61028. */
  61029. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61030. /**
  61031. * Callback called when the task is successful
  61032. */
  61033. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61034. /**
  61035. * Creates a new EquiRectangularCubeTextureAssetTask object
  61036. * @param name defines the name of the task
  61037. * @param url defines the location of the file to load
  61038. * @param size defines the desired size (the more it increases the longer the generation will be)
  61039. * If the size is omitted this implies you are using a preprocessed cubemap.
  61040. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61041. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61042. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61043. * (default is true)
  61044. */
  61045. constructor(
  61046. /**
  61047. * Defines the name of the task
  61048. */
  61049. name: string,
  61050. /**
  61051. * Defines the location of the file to load
  61052. */
  61053. url: string,
  61054. /**
  61055. * Defines the desired size (the more it increases the longer the generation will be)
  61056. */
  61057. size: number,
  61058. /**
  61059. * Defines if mipmaps should not be generated (default is false)
  61060. */
  61061. noMipmap?: boolean,
  61062. /**
  61063. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61064. * but the standard material would require them in Gamma space) (default is true)
  61065. */
  61066. gammaSpace?: boolean);
  61067. /**
  61068. * Execute the current task
  61069. * @param scene defines the scene where you want your assets to be loaded
  61070. * @param onSuccess is a callback called when the task is successfully executed
  61071. * @param onError is a callback called if an error occurs
  61072. */
  61073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61074. }
  61075. /**
  61076. * This class can be used to easily import assets into a scene
  61077. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61078. */
  61079. export class AssetsManager {
  61080. private _scene;
  61081. private _isLoading;
  61082. protected _tasks: AbstractAssetTask[];
  61083. protected _waitingTasksCount: number;
  61084. protected _totalTasksCount: number;
  61085. /**
  61086. * Callback called when all tasks are processed
  61087. */
  61088. onFinish: (tasks: AbstractAssetTask[]) => void;
  61089. /**
  61090. * Callback called when a task is successful
  61091. */
  61092. onTaskSuccess: (task: AbstractAssetTask) => void;
  61093. /**
  61094. * Callback called when a task had an error
  61095. */
  61096. onTaskError: (task: AbstractAssetTask) => void;
  61097. /**
  61098. * Callback called when a task is done (whatever the result is)
  61099. */
  61100. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61101. /**
  61102. * Observable called when all tasks are processed
  61103. */
  61104. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61105. /**
  61106. * Observable called when a task had an error
  61107. */
  61108. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61109. /**
  61110. * Observable called when all tasks were executed
  61111. */
  61112. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61113. /**
  61114. * Observable called when a task is done (whatever the result is)
  61115. */
  61116. onProgressObservable: Observable<IAssetsProgressEvent>;
  61117. /**
  61118. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61120. */
  61121. useDefaultLoadingScreen: boolean;
  61122. /**
  61123. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61124. * when all assets have been downloaded.
  61125. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61126. */
  61127. autoHideLoadingUI: boolean;
  61128. /**
  61129. * Creates a new AssetsManager
  61130. * @param scene defines the scene to work on
  61131. */
  61132. constructor(scene: Scene);
  61133. /**
  61134. * Add a MeshAssetTask to the list of active tasks
  61135. * @param taskName defines the name of the new task
  61136. * @param meshesNames defines the name of meshes to load
  61137. * @param rootUrl defines the root url to use to locate files
  61138. * @param sceneFilename defines the filename of the scene file
  61139. * @returns a new MeshAssetTask object
  61140. */
  61141. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61142. /**
  61143. * Add a TextFileAssetTask to the list of active tasks
  61144. * @param taskName defines the name of the new task
  61145. * @param url defines the url of the file to load
  61146. * @returns a new TextFileAssetTask object
  61147. */
  61148. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61149. /**
  61150. * Add a BinaryFileAssetTask to the list of active tasks
  61151. * @param taskName defines the name of the new task
  61152. * @param url defines the url of the file to load
  61153. * @returns a new BinaryFileAssetTask object
  61154. */
  61155. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61156. /**
  61157. * Add a ImageAssetTask to the list of active tasks
  61158. * @param taskName defines the name of the new task
  61159. * @param url defines the url of the file to load
  61160. * @returns a new ImageAssetTask object
  61161. */
  61162. addImageTask(taskName: string, url: string): ImageAssetTask;
  61163. /**
  61164. * Add a TextureAssetTask to the list of active tasks
  61165. * @param taskName defines the name of the new task
  61166. * @param url defines the url of the file to load
  61167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61168. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61169. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61170. * @returns a new TextureAssetTask object
  61171. */
  61172. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61173. /**
  61174. * Add a CubeTextureAssetTask to the list of active tasks
  61175. * @param taskName defines the name of the new task
  61176. * @param url defines the url of the file to load
  61177. * @param extensions defines the extension to use to load the cube map (can be null)
  61178. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61179. * @param files defines the list of files to load (can be null)
  61180. * @returns a new CubeTextureAssetTask object
  61181. */
  61182. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61183. /**
  61184. *
  61185. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61186. * @param taskName defines the name of the new task
  61187. * @param url defines the url of the file to load
  61188. * @param size defines the size you want for the cubemap (can be null)
  61189. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61190. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61191. * @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)
  61192. * @param reserved Internal use only
  61193. * @returns a new HDRCubeTextureAssetTask object
  61194. */
  61195. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61196. /**
  61197. *
  61198. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61199. * @param taskName defines the name of the new task
  61200. * @param url defines the url of the file to load
  61201. * @param size defines the size you want for the cubemap (can be null)
  61202. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61203. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61204. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61205. * @returns a new EquiRectangularCubeTextureAssetTask object
  61206. */
  61207. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61208. /**
  61209. * Remove a task from the assets manager.
  61210. * @param task the task to remove
  61211. */
  61212. removeTask(task: AbstractAssetTask): void;
  61213. private _decreaseWaitingTasksCount;
  61214. private _runTask;
  61215. /**
  61216. * Reset the AssetsManager and remove all tasks
  61217. * @return the current instance of the AssetsManager
  61218. */
  61219. reset(): AssetsManager;
  61220. /**
  61221. * Start the loading process
  61222. * @return the current instance of the AssetsManager
  61223. */
  61224. load(): AssetsManager;
  61225. /**
  61226. * Start the loading process as an async operation
  61227. * @return a promise returning the list of failed tasks
  61228. */
  61229. loadAsync(): Promise<void>;
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * Wrapper class for promise with external resolve and reject.
  61235. */
  61236. export class Deferred<T> {
  61237. /**
  61238. * The promise associated with this deferred object.
  61239. */
  61240. readonly promise: Promise<T>;
  61241. private _resolve;
  61242. private _reject;
  61243. /**
  61244. * The resolve method of the promise associated with this deferred object.
  61245. */
  61246. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61247. /**
  61248. * The reject method of the promise associated with this deferred object.
  61249. */
  61250. readonly reject: (reason?: any) => void;
  61251. /**
  61252. * Constructor for this deferred object.
  61253. */
  61254. constructor();
  61255. }
  61256. }
  61257. declare module BABYLON {
  61258. /**
  61259. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61260. */
  61261. export class MeshExploder {
  61262. private _centerMesh;
  61263. private _meshes;
  61264. private _meshesOrigins;
  61265. private _toCenterVectors;
  61266. private _scaledDirection;
  61267. private _newPosition;
  61268. private _centerPosition;
  61269. /**
  61270. * Explodes meshes from a center mesh.
  61271. * @param meshes The meshes to explode.
  61272. * @param centerMesh The mesh to be center of explosion.
  61273. */
  61274. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61275. private _setCenterMesh;
  61276. /**
  61277. * Get class name
  61278. * @returns "MeshExploder"
  61279. */
  61280. getClassName(): string;
  61281. /**
  61282. * "Exploded meshes"
  61283. * @returns Array of meshes with the centerMesh at index 0.
  61284. */
  61285. getMeshes(): Array<Mesh>;
  61286. /**
  61287. * Explodes meshes giving a specific direction
  61288. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61289. */
  61290. explode(direction?: number): void;
  61291. }
  61292. }
  61293. declare module BABYLON {
  61294. /**
  61295. * Class used to help managing file picking and drag'n'drop
  61296. */
  61297. export class FilesInput {
  61298. /**
  61299. * List of files ready to be loaded
  61300. */
  61301. static readonly FilesToLoad: {
  61302. [key: string]: File;
  61303. };
  61304. /**
  61305. * Callback called when a file is processed
  61306. */
  61307. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61308. private _engine;
  61309. private _currentScene;
  61310. private _sceneLoadedCallback;
  61311. private _progressCallback;
  61312. private _additionalRenderLoopLogicCallback;
  61313. private _textureLoadingCallback;
  61314. private _startingProcessingFilesCallback;
  61315. private _onReloadCallback;
  61316. private _errorCallback;
  61317. private _elementToMonitor;
  61318. private _sceneFileToLoad;
  61319. private _filesToLoad;
  61320. /**
  61321. * Creates a new FilesInput
  61322. * @param engine defines the rendering engine
  61323. * @param scene defines the hosting scene
  61324. * @param sceneLoadedCallback callback called when scene is loaded
  61325. * @param progressCallback callback called to track progress
  61326. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61327. * @param textureLoadingCallback callback called when a texture is loading
  61328. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61329. * @param onReloadCallback callback called when a reload is requested
  61330. * @param errorCallback callback call if an error occurs
  61331. */
  61332. 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);
  61333. private _dragEnterHandler;
  61334. private _dragOverHandler;
  61335. private _dropHandler;
  61336. /**
  61337. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61338. * @param elementToMonitor defines the DOM element to track
  61339. */
  61340. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61341. /**
  61342. * Release all associated resources
  61343. */
  61344. dispose(): void;
  61345. private renderFunction;
  61346. private drag;
  61347. private drop;
  61348. private _traverseFolder;
  61349. private _processFiles;
  61350. /**
  61351. * Load files from a drop event
  61352. * @param event defines the drop event to use as source
  61353. */
  61354. loadFiles(event: any): void;
  61355. private _processReload;
  61356. /**
  61357. * Reload the current scene from the loaded files
  61358. */
  61359. reload(): void;
  61360. }
  61361. }
  61362. declare module BABYLON {
  61363. /**
  61364. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61366. */
  61367. export class SceneOptimization {
  61368. /**
  61369. * Defines the priority of this optimization (0 by default which means first in the list)
  61370. */
  61371. priority: number;
  61372. /**
  61373. * Gets a string describing the action executed by the current optimization
  61374. * @returns description string
  61375. */
  61376. getDescription(): string;
  61377. /**
  61378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61379. * @param scene defines the current scene where to apply this optimization
  61380. * @param optimizer defines the current optimizer
  61381. * @returns true if everything that can be done was applied
  61382. */
  61383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61384. /**
  61385. * Creates the SceneOptimization object
  61386. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61387. * @param desc defines the description associated with the optimization
  61388. */
  61389. constructor(
  61390. /**
  61391. * Defines the priority of this optimization (0 by default which means first in the list)
  61392. */
  61393. priority?: number);
  61394. }
  61395. /**
  61396. * Defines an optimization used to reduce the size of render target textures
  61397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61398. */
  61399. export class TextureOptimization extends SceneOptimization {
  61400. /**
  61401. * Defines the priority of this optimization (0 by default which means first in the list)
  61402. */
  61403. priority: number;
  61404. /**
  61405. * 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
  61406. */
  61407. maximumSize: number;
  61408. /**
  61409. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61410. */
  61411. step: number;
  61412. /**
  61413. * Gets a string describing the action executed by the current optimization
  61414. * @returns description string
  61415. */
  61416. getDescription(): string;
  61417. /**
  61418. * Creates the TextureOptimization object
  61419. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61420. * @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
  61421. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61422. */
  61423. constructor(
  61424. /**
  61425. * Defines the priority of this optimization (0 by default which means first in the list)
  61426. */
  61427. priority?: number,
  61428. /**
  61429. * 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
  61430. */
  61431. maximumSize?: number,
  61432. /**
  61433. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61434. */
  61435. step?: number);
  61436. /**
  61437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61438. * @param scene defines the current scene where to apply this optimization
  61439. * @param optimizer defines the current optimizer
  61440. * @returns true if everything that can be done was applied
  61441. */
  61442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61443. }
  61444. /**
  61445. * Defines an optimization used to increase or decrease the rendering resolution
  61446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61447. */
  61448. export class HardwareScalingOptimization extends SceneOptimization {
  61449. /**
  61450. * Defines the priority of this optimization (0 by default which means first in the list)
  61451. */
  61452. priority: number;
  61453. /**
  61454. * Defines the maximum scale to use (2 by default)
  61455. */
  61456. maximumScale: number;
  61457. /**
  61458. * Defines the step to use between two passes (0.5 by default)
  61459. */
  61460. step: number;
  61461. private _currentScale;
  61462. private _directionOffset;
  61463. /**
  61464. * Gets a string describing the action executed by the current optimization
  61465. * @return description string
  61466. */
  61467. getDescription(): string;
  61468. /**
  61469. * Creates the HardwareScalingOptimization object
  61470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61471. * @param maximumScale defines the maximum scale to use (2 by default)
  61472. * @param step defines the step to use between two passes (0.5 by default)
  61473. */
  61474. constructor(
  61475. /**
  61476. * Defines the priority of this optimization (0 by default which means first in the list)
  61477. */
  61478. priority?: number,
  61479. /**
  61480. * Defines the maximum scale to use (2 by default)
  61481. */
  61482. maximumScale?: number,
  61483. /**
  61484. * Defines the step to use between two passes (0.5 by default)
  61485. */
  61486. step?: number);
  61487. /**
  61488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61489. * @param scene defines the current scene where to apply this optimization
  61490. * @param optimizer defines the current optimizer
  61491. * @returns true if everything that can be done was applied
  61492. */
  61493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61494. }
  61495. /**
  61496. * Defines an optimization used to remove shadows
  61497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61498. */
  61499. export class ShadowsOptimization extends SceneOptimization {
  61500. /**
  61501. * Gets a string describing the action executed by the current optimization
  61502. * @return description string
  61503. */
  61504. getDescription(): string;
  61505. /**
  61506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61507. * @param scene defines the current scene where to apply this optimization
  61508. * @param optimizer defines the current optimizer
  61509. * @returns true if everything that can be done was applied
  61510. */
  61511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61512. }
  61513. /**
  61514. * Defines an optimization used to turn post-processes off
  61515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61516. */
  61517. export class PostProcessesOptimization extends SceneOptimization {
  61518. /**
  61519. * Gets a string describing the action executed by the current optimization
  61520. * @return description string
  61521. */
  61522. getDescription(): string;
  61523. /**
  61524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61525. * @param scene defines the current scene where to apply this optimization
  61526. * @param optimizer defines the current optimizer
  61527. * @returns true if everything that can be done was applied
  61528. */
  61529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61530. }
  61531. /**
  61532. * Defines an optimization used to turn lens flares off
  61533. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61534. */
  61535. export class LensFlaresOptimization extends SceneOptimization {
  61536. /**
  61537. * Gets a string describing the action executed by the current optimization
  61538. * @return description string
  61539. */
  61540. getDescription(): string;
  61541. /**
  61542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61543. * @param scene defines the current scene where to apply this optimization
  61544. * @param optimizer defines the current optimizer
  61545. * @returns true if everything that can be done was applied
  61546. */
  61547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61548. }
  61549. /**
  61550. * Defines an optimization based on user defined callback.
  61551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61552. */
  61553. export class CustomOptimization extends SceneOptimization {
  61554. /**
  61555. * Callback called to apply the custom optimization.
  61556. */
  61557. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61558. /**
  61559. * Callback called to get custom description
  61560. */
  61561. onGetDescription: () => string;
  61562. /**
  61563. * Gets a string describing the action executed by the current optimization
  61564. * @returns description string
  61565. */
  61566. getDescription(): string;
  61567. /**
  61568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61569. * @param scene defines the current scene where to apply this optimization
  61570. * @param optimizer defines the current optimizer
  61571. * @returns true if everything that can be done was applied
  61572. */
  61573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61574. }
  61575. /**
  61576. * Defines an optimization used to turn particles off
  61577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61578. */
  61579. export class ParticlesOptimization extends SceneOptimization {
  61580. /**
  61581. * Gets a string describing the action executed by the current optimization
  61582. * @return description string
  61583. */
  61584. getDescription(): string;
  61585. /**
  61586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61587. * @param scene defines the current scene where to apply this optimization
  61588. * @param optimizer defines the current optimizer
  61589. * @returns true if everything that can be done was applied
  61590. */
  61591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61592. }
  61593. /**
  61594. * Defines an optimization used to turn render targets off
  61595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61596. */
  61597. export class RenderTargetsOptimization extends SceneOptimization {
  61598. /**
  61599. * Gets a string describing the action executed by the current optimization
  61600. * @return description string
  61601. */
  61602. getDescription(): string;
  61603. /**
  61604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61605. * @param scene defines the current scene where to apply this optimization
  61606. * @param optimizer defines the current optimizer
  61607. * @returns true if everything that can be done was applied
  61608. */
  61609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61610. }
  61611. /**
  61612. * Defines an optimization used to merge meshes with compatible materials
  61613. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61614. */
  61615. export class MergeMeshesOptimization extends SceneOptimization {
  61616. private static _UpdateSelectionTree;
  61617. /**
  61618. * Gets or sets a boolean which defines if optimization octree has to be updated
  61619. */
  61620. /**
  61621. * Gets or sets a boolean which defines if optimization octree has to be updated
  61622. */
  61623. static UpdateSelectionTree: boolean;
  61624. /**
  61625. * Gets a string describing the action executed by the current optimization
  61626. * @return description string
  61627. */
  61628. getDescription(): string;
  61629. private _canBeMerged;
  61630. /**
  61631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61632. * @param scene defines the current scene where to apply this optimization
  61633. * @param optimizer defines the current optimizer
  61634. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61635. * @returns true if everything that can be done was applied
  61636. */
  61637. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61638. }
  61639. /**
  61640. * Defines a list of options used by SceneOptimizer
  61641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61642. */
  61643. export class SceneOptimizerOptions {
  61644. /**
  61645. * Defines the target frame rate to reach (60 by default)
  61646. */
  61647. targetFrameRate: number;
  61648. /**
  61649. * Defines the interval between two checkes (2000ms by default)
  61650. */
  61651. trackerDuration: number;
  61652. /**
  61653. * Gets the list of optimizations to apply
  61654. */
  61655. optimizations: SceneOptimization[];
  61656. /**
  61657. * Creates a new list of options used by SceneOptimizer
  61658. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61659. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61660. */
  61661. constructor(
  61662. /**
  61663. * Defines the target frame rate to reach (60 by default)
  61664. */
  61665. targetFrameRate?: number,
  61666. /**
  61667. * Defines the interval between two checkes (2000ms by default)
  61668. */
  61669. trackerDuration?: number);
  61670. /**
  61671. * Add a new optimization
  61672. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61673. * @returns the current SceneOptimizerOptions
  61674. */
  61675. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61676. /**
  61677. * Add a new custom optimization
  61678. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61679. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61680. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61681. * @returns the current SceneOptimizerOptions
  61682. */
  61683. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61684. /**
  61685. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61686. * @param targetFrameRate defines the target frame rate (60 by default)
  61687. * @returns a SceneOptimizerOptions object
  61688. */
  61689. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61690. /**
  61691. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61692. * @param targetFrameRate defines the target frame rate (60 by default)
  61693. * @returns a SceneOptimizerOptions object
  61694. */
  61695. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61696. /**
  61697. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61698. * @param targetFrameRate defines the target frame rate (60 by default)
  61699. * @returns a SceneOptimizerOptions object
  61700. */
  61701. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61702. }
  61703. /**
  61704. * Class used to run optimizations in order to reach a target frame rate
  61705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61706. */
  61707. export class SceneOptimizer implements IDisposable {
  61708. private _isRunning;
  61709. private _options;
  61710. private _scene;
  61711. private _currentPriorityLevel;
  61712. private _targetFrameRate;
  61713. private _trackerDuration;
  61714. private _currentFrameRate;
  61715. private _sceneDisposeObserver;
  61716. private _improvementMode;
  61717. /**
  61718. * Defines an observable called when the optimizer reaches the target frame rate
  61719. */
  61720. onSuccessObservable: Observable<SceneOptimizer>;
  61721. /**
  61722. * Defines an observable called when the optimizer enables an optimization
  61723. */
  61724. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61725. /**
  61726. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61727. */
  61728. onFailureObservable: Observable<SceneOptimizer>;
  61729. /**
  61730. * Gets a boolean indicating if the optimizer is in improvement mode
  61731. */
  61732. readonly isInImprovementMode: boolean;
  61733. /**
  61734. * Gets the current priority level (0 at start)
  61735. */
  61736. readonly currentPriorityLevel: number;
  61737. /**
  61738. * Gets the current frame rate checked by the SceneOptimizer
  61739. */
  61740. readonly currentFrameRate: number;
  61741. /**
  61742. * Gets or sets the current target frame rate (60 by default)
  61743. */
  61744. /**
  61745. * Gets or sets the current target frame rate (60 by default)
  61746. */
  61747. targetFrameRate: number;
  61748. /**
  61749. * Gets or sets the current interval between two checks (every 2000ms by default)
  61750. */
  61751. /**
  61752. * Gets or sets the current interval between two checks (every 2000ms by default)
  61753. */
  61754. trackerDuration: number;
  61755. /**
  61756. * Gets the list of active optimizations
  61757. */
  61758. readonly optimizations: SceneOptimization[];
  61759. /**
  61760. * Creates a new SceneOptimizer
  61761. * @param scene defines the scene to work on
  61762. * @param options defines the options to use with the SceneOptimizer
  61763. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61764. * @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)
  61765. */
  61766. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61767. /**
  61768. * Stops the current optimizer
  61769. */
  61770. stop(): void;
  61771. /**
  61772. * Reset the optimizer to initial step (current priority level = 0)
  61773. */
  61774. reset(): void;
  61775. /**
  61776. * Start the optimizer. By default it will try to reach a specific framerate
  61777. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61778. */
  61779. start(): void;
  61780. private _checkCurrentState;
  61781. /**
  61782. * Release all resources
  61783. */
  61784. dispose(): void;
  61785. /**
  61786. * Helper function to create a SceneOptimizer with one single line of code
  61787. * @param scene defines the scene to work on
  61788. * @param options defines the options to use with the SceneOptimizer
  61789. * @param onSuccess defines a callback to call on success
  61790. * @param onFailure defines a callback to call on failure
  61791. * @returns the new SceneOptimizer object
  61792. */
  61793. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61794. }
  61795. }
  61796. declare module BABYLON {
  61797. /**
  61798. * Class used to serialize a scene into a string
  61799. */
  61800. export class SceneSerializer {
  61801. /**
  61802. * Clear cache used by a previous serialization
  61803. */
  61804. static ClearCache(): void;
  61805. /**
  61806. * Serialize a scene into a JSON compatible object
  61807. * @param scene defines the scene to serialize
  61808. * @returns a JSON compatible object
  61809. */
  61810. static Serialize(scene: Scene): any;
  61811. /**
  61812. * Serialize a mesh into a JSON compatible object
  61813. * @param toSerialize defines the mesh to serialize
  61814. * @param withParents defines if parents must be serialized as well
  61815. * @param withChildren defines if children must be serialized as well
  61816. * @returns a JSON compatible object
  61817. */
  61818. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61819. }
  61820. }
  61821. declare module BABYLON {
  61822. /**
  61823. * Class used to host texture specific utilities
  61824. */
  61825. export class TextureTools {
  61826. /**
  61827. * Uses the GPU to create a copy texture rescaled at a given size
  61828. * @param texture Texture to copy from
  61829. * @param width defines the desired width
  61830. * @param height defines the desired height
  61831. * @param useBilinearMode defines if bilinear mode has to be used
  61832. * @return the generated texture
  61833. */
  61834. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61835. }
  61836. }
  61837. declare module BABYLON {
  61838. /**
  61839. * This represents the different options available for the video capture.
  61840. */
  61841. export interface VideoRecorderOptions {
  61842. /** Defines the mime type of the video. */
  61843. mimeType: string;
  61844. /** Defines the FPS the video should be recorded at. */
  61845. fps: number;
  61846. /** Defines the chunk size for the recording data. */
  61847. recordChunckSize: number;
  61848. /** The audio tracks to attach to the recording. */
  61849. audioTracks?: MediaStreamTrack[];
  61850. }
  61851. /**
  61852. * This can help with recording videos from BabylonJS.
  61853. * This is based on the available WebRTC functionalities of the browser.
  61854. *
  61855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61856. */
  61857. export class VideoRecorder {
  61858. private static readonly _defaultOptions;
  61859. /**
  61860. * Returns whether or not the VideoRecorder is available in your browser.
  61861. * @param engine Defines the Babylon Engine.
  61862. * @returns true if supported otherwise false.
  61863. */
  61864. static IsSupported(engine: Engine): boolean;
  61865. private readonly _options;
  61866. private _canvas;
  61867. private _mediaRecorder;
  61868. private _recordedChunks;
  61869. private _fileName;
  61870. private _resolve;
  61871. private _reject;
  61872. /**
  61873. * True when a recording is already in progress.
  61874. */
  61875. readonly isRecording: boolean;
  61876. /**
  61877. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61878. * @param engine Defines the BabylonJS Engine you wish to record.
  61879. * @param options Defines options that can be used to customize the capture.
  61880. */
  61881. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61882. /**
  61883. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61884. */
  61885. stopRecording(): void;
  61886. /**
  61887. * Starts recording the canvas for a max duration specified in parameters.
  61888. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61889. * If null no automatic download will start and you can rely on the promise to get the data back.
  61890. * @param maxDuration Defines the maximum recording time in seconds.
  61891. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61892. * @return A promise callback at the end of the recording with the video data in Blob.
  61893. */
  61894. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61895. /**
  61896. * Releases internal resources used during the recording.
  61897. */
  61898. dispose(): void;
  61899. private _handleDataAvailable;
  61900. private _handleError;
  61901. private _handleStop;
  61902. }
  61903. }
  61904. declare module BABYLON {
  61905. /**
  61906. * Class containing a set of static utilities functions for screenshots
  61907. */
  61908. export class ScreenshotTools {
  61909. /**
  61910. * Captures a screenshot of the current rendering
  61911. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61912. * @param engine defines the rendering engine
  61913. * @param camera defines the source camera
  61914. * @param size This parameter can be set to a single number or to an object with the
  61915. * following (optional) properties: precision, width, height. If a single number is passed,
  61916. * it will be used for both width and height. If an object is passed, the screenshot size
  61917. * will be derived from the parameters. The precision property is a multiplier allowing
  61918. * rendering at a higher or lower resolution
  61919. * @param successCallback defines the callback receives a single parameter which contains the
  61920. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61921. * src parameter of an <img> to display it
  61922. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61923. * Check your browser for supported MIME types
  61924. */
  61925. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61926. /**
  61927. * Captures a screenshot of the current rendering
  61928. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61929. * @param engine defines the rendering engine
  61930. * @param camera defines the source camera
  61931. * @param size This parameter can be set to a single number or to an object with the
  61932. * following (optional) properties: precision, width, height. If a single number is passed,
  61933. * it will be used for both width and height. If an object is passed, the screenshot size
  61934. * will be derived from the parameters. The precision property is a multiplier allowing
  61935. * rendering at a higher or lower resolution
  61936. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61937. * Check your browser for supported MIME types
  61938. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61939. * to the src parameter of an <img> to display it
  61940. */
  61941. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61942. /**
  61943. * Generates an image screenshot from the specified camera.
  61944. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61945. * @param engine The engine to use for rendering
  61946. * @param camera The camera to use for rendering
  61947. * @param size This parameter can be set to a single number or to an object with the
  61948. * following (optional) properties: precision, width, height. If a single number is passed,
  61949. * it will be used for both width and height. If an object is passed, the screenshot size
  61950. * will be derived from the parameters. The precision property is a multiplier allowing
  61951. * rendering at a higher or lower resolution
  61952. * @param successCallback The callback receives a single parameter which contains the
  61953. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61954. * src parameter of an <img> to display it
  61955. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61956. * Check your browser for supported MIME types
  61957. * @param samples Texture samples (default: 1)
  61958. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61959. * @param fileName A name for for the downloaded file.
  61960. */
  61961. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61962. /**
  61963. * Generates an image screenshot from the specified camera.
  61964. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61965. * @param engine The engine to use for rendering
  61966. * @param camera The camera to use for rendering
  61967. * @param size This parameter can be set to a single number or to an object with the
  61968. * following (optional) properties: precision, width, height. If a single number is passed,
  61969. * it will be used for both width and height. If an object is passed, the screenshot size
  61970. * will be derived from the parameters. The precision property is a multiplier allowing
  61971. * rendering at a higher or lower resolution
  61972. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61973. * Check your browser for supported MIME types
  61974. * @param samples Texture samples (default: 1)
  61975. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61976. * @param fileName A name for for the downloaded file.
  61977. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61978. * to the src parameter of an <img> to display it
  61979. */
  61980. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61981. /**
  61982. * Gets height and width for screenshot size
  61983. * @private
  61984. */
  61985. private static _getScreenshotSize;
  61986. }
  61987. }
  61988. declare module BABYLON {
  61989. /**
  61990. * A cursor which tracks a point on a path
  61991. */
  61992. export class PathCursor {
  61993. private path;
  61994. /**
  61995. * Stores path cursor callbacks for when an onchange event is triggered
  61996. */
  61997. private _onchange;
  61998. /**
  61999. * The value of the path cursor
  62000. */
  62001. value: number;
  62002. /**
  62003. * The animation array of the path cursor
  62004. */
  62005. animations: Animation[];
  62006. /**
  62007. * Initializes the path cursor
  62008. * @param path The path to track
  62009. */
  62010. constructor(path: Path2);
  62011. /**
  62012. * Gets the cursor point on the path
  62013. * @returns A point on the path cursor at the cursor location
  62014. */
  62015. getPoint(): Vector3;
  62016. /**
  62017. * Moves the cursor ahead by the step amount
  62018. * @param step The amount to move the cursor forward
  62019. * @returns This path cursor
  62020. */
  62021. moveAhead(step?: number): PathCursor;
  62022. /**
  62023. * Moves the cursor behind by the step amount
  62024. * @param step The amount to move the cursor back
  62025. * @returns This path cursor
  62026. */
  62027. moveBack(step?: number): PathCursor;
  62028. /**
  62029. * Moves the cursor by the step amount
  62030. * If the step amount is greater than one, an exception is thrown
  62031. * @param step The amount to move the cursor
  62032. * @returns This path cursor
  62033. */
  62034. move(step: number): PathCursor;
  62035. /**
  62036. * Ensures that the value is limited between zero and one
  62037. * @returns This path cursor
  62038. */
  62039. private ensureLimits;
  62040. /**
  62041. * Runs onchange callbacks on change (used by the animation engine)
  62042. * @returns This path cursor
  62043. */
  62044. private raiseOnChange;
  62045. /**
  62046. * Executes a function on change
  62047. * @param f A path cursor onchange callback
  62048. * @returns This path cursor
  62049. */
  62050. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62051. }
  62052. }
  62053. declare module BABYLON {
  62054. /** @hidden */
  62055. export var blurPixelShader: {
  62056. name: string;
  62057. shader: string;
  62058. };
  62059. }
  62060. declare module BABYLON {
  62061. /** @hidden */
  62062. export var pointCloudVertexDeclaration: {
  62063. name: string;
  62064. shader: string;
  62065. };
  62066. }
  62067. // Mixins
  62068. interface Window {
  62069. mozIndexedDB: IDBFactory;
  62070. webkitIndexedDB: IDBFactory;
  62071. msIndexedDB: IDBFactory;
  62072. webkitURL: typeof URL;
  62073. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62074. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62075. WebGLRenderingContext: WebGLRenderingContext;
  62076. MSGesture: MSGesture;
  62077. CANNON: any;
  62078. AudioContext: AudioContext;
  62079. webkitAudioContext: AudioContext;
  62080. PointerEvent: any;
  62081. Math: Math;
  62082. Uint8Array: Uint8ArrayConstructor;
  62083. Float32Array: Float32ArrayConstructor;
  62084. mozURL: typeof URL;
  62085. msURL: typeof URL;
  62086. VRFrameData: any; // WebVR, from specs 1.1
  62087. DracoDecoderModule: any;
  62088. setImmediate(handler: (...args: any[]) => void): number;
  62089. }
  62090. interface HTMLCanvasElement {
  62091. requestPointerLock(): void;
  62092. msRequestPointerLock?(): void;
  62093. mozRequestPointerLock?(): void;
  62094. webkitRequestPointerLock?(): void;
  62095. /** Track wether a record is in progress */
  62096. isRecording: boolean;
  62097. /** Capture Stream method defined by some browsers */
  62098. captureStream(fps?: number): MediaStream;
  62099. }
  62100. interface CanvasRenderingContext2D {
  62101. msImageSmoothingEnabled: boolean;
  62102. }
  62103. interface MouseEvent {
  62104. mozMovementX: number;
  62105. mozMovementY: number;
  62106. webkitMovementX: number;
  62107. webkitMovementY: number;
  62108. msMovementX: number;
  62109. msMovementY: number;
  62110. }
  62111. interface Navigator {
  62112. mozGetVRDevices: (any: any) => any;
  62113. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62114. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62115. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62116. webkitGetGamepads(): Gamepad[];
  62117. msGetGamepads(): Gamepad[];
  62118. webkitGamepads(): Gamepad[];
  62119. }
  62120. interface HTMLVideoElement {
  62121. mozSrcObject: any;
  62122. }
  62123. interface Math {
  62124. fround(x: number): number;
  62125. imul(a: number, b: number): number;
  62126. }
  62127. interface WebGLRenderingContext {
  62128. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62129. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62130. vertexAttribDivisor(index: number, divisor: number): void;
  62131. createVertexArray(): any;
  62132. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62133. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62134. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62135. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62136. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62137. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62138. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62139. // Queries
  62140. createQuery(): WebGLQuery;
  62141. deleteQuery(query: WebGLQuery): void;
  62142. beginQuery(target: number, query: WebGLQuery): void;
  62143. endQuery(target: number): void;
  62144. getQueryParameter(query: WebGLQuery, pname: number): any;
  62145. getQuery(target: number, pname: number): any;
  62146. MAX_SAMPLES: number;
  62147. RGBA8: number;
  62148. READ_FRAMEBUFFER: number;
  62149. DRAW_FRAMEBUFFER: number;
  62150. UNIFORM_BUFFER: number;
  62151. HALF_FLOAT_OES: number;
  62152. RGBA16F: number;
  62153. RGBA32F: number;
  62154. R32F: number;
  62155. RG32F: number;
  62156. RGB32F: number;
  62157. R16F: number;
  62158. RG16F: number;
  62159. RGB16F: number;
  62160. RED: number;
  62161. RG: number;
  62162. R8: number;
  62163. RG8: number;
  62164. UNSIGNED_INT_24_8: number;
  62165. DEPTH24_STENCIL8: number;
  62166. /* Multiple Render Targets */
  62167. drawBuffers(buffers: number[]): void;
  62168. readBuffer(src: number): void;
  62169. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62170. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62171. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62172. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62173. // Occlusion Query
  62174. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62175. ANY_SAMPLES_PASSED: number;
  62176. QUERY_RESULT_AVAILABLE: number;
  62177. QUERY_RESULT: number;
  62178. }
  62179. interface WebGLProgram {
  62180. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62181. }
  62182. interface EXT_disjoint_timer_query {
  62183. QUERY_COUNTER_BITS_EXT: number;
  62184. TIME_ELAPSED_EXT: number;
  62185. TIMESTAMP_EXT: number;
  62186. GPU_DISJOINT_EXT: number;
  62187. QUERY_RESULT_EXT: number;
  62188. QUERY_RESULT_AVAILABLE_EXT: number;
  62189. queryCounterEXT(query: WebGLQuery, target: number): void;
  62190. createQueryEXT(): WebGLQuery;
  62191. beginQueryEXT(target: number, query: WebGLQuery): void;
  62192. endQueryEXT(target: number): void;
  62193. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62194. deleteQueryEXT(query: WebGLQuery): void;
  62195. }
  62196. interface WebGLUniformLocation {
  62197. _currentState: any;
  62198. }
  62199. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62200. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62201. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62202. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62203. interface WebGLRenderingContext {
  62204. readonly RASTERIZER_DISCARD: number;
  62205. readonly DEPTH_COMPONENT24: number;
  62206. readonly TEXTURE_3D: number;
  62207. readonly TEXTURE_2D_ARRAY: number;
  62208. readonly TEXTURE_COMPARE_FUNC: number;
  62209. readonly TEXTURE_COMPARE_MODE: number;
  62210. readonly COMPARE_REF_TO_TEXTURE: number;
  62211. readonly TEXTURE_WRAP_R: number;
  62212. readonly HALF_FLOAT: number;
  62213. readonly RGB8: number;
  62214. readonly RED_INTEGER: number;
  62215. readonly RG_INTEGER: number;
  62216. readonly RGB_INTEGER: number;
  62217. readonly RGBA_INTEGER: number;
  62218. readonly R8_SNORM: number;
  62219. readonly RG8_SNORM: number;
  62220. readonly RGB8_SNORM: number;
  62221. readonly RGBA8_SNORM: number;
  62222. readonly R8I: number;
  62223. readonly RG8I: number;
  62224. readonly RGB8I: number;
  62225. readonly RGBA8I: number;
  62226. readonly R8UI: number;
  62227. readonly RG8UI: number;
  62228. readonly RGB8UI: number;
  62229. readonly RGBA8UI: number;
  62230. readonly R16I: number;
  62231. readonly RG16I: number;
  62232. readonly RGB16I: number;
  62233. readonly RGBA16I: number;
  62234. readonly R16UI: number;
  62235. readonly RG16UI: number;
  62236. readonly RGB16UI: number;
  62237. readonly RGBA16UI: number;
  62238. readonly R32I: number;
  62239. readonly RG32I: number;
  62240. readonly RGB32I: number;
  62241. readonly RGBA32I: number;
  62242. readonly R32UI: number;
  62243. readonly RG32UI: number;
  62244. readonly RGB32UI: number;
  62245. readonly RGBA32UI: number;
  62246. readonly RGB10_A2UI: number;
  62247. readonly R11F_G11F_B10F: number;
  62248. readonly RGB9_E5: number;
  62249. readonly RGB10_A2: number;
  62250. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62251. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62252. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62253. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62254. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62255. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62256. 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;
  62257. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62258. readonly TRANSFORM_FEEDBACK: number;
  62259. readonly INTERLEAVED_ATTRIBS: number;
  62260. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62261. createTransformFeedback(): WebGLTransformFeedback;
  62262. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62263. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62264. beginTransformFeedback(primitiveMode: number): void;
  62265. endTransformFeedback(): void;
  62266. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62267. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62268. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62269. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62270. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62271. }
  62272. interface ImageBitmap {
  62273. readonly width: number;
  62274. readonly height: number;
  62275. close(): void;
  62276. }
  62277. interface WebGLQuery extends WebGLObject {
  62278. }
  62279. declare var WebGLQuery: {
  62280. prototype: WebGLQuery;
  62281. new(): WebGLQuery;
  62282. };
  62283. interface WebGLSampler extends WebGLObject {
  62284. }
  62285. declare var WebGLSampler: {
  62286. prototype: WebGLSampler;
  62287. new(): WebGLSampler;
  62288. };
  62289. interface WebGLSync extends WebGLObject {
  62290. }
  62291. declare var WebGLSync: {
  62292. prototype: WebGLSync;
  62293. new(): WebGLSync;
  62294. };
  62295. interface WebGLTransformFeedback extends WebGLObject {
  62296. }
  62297. declare var WebGLTransformFeedback: {
  62298. prototype: WebGLTransformFeedback;
  62299. new(): WebGLTransformFeedback;
  62300. };
  62301. interface WebGLVertexArrayObject extends WebGLObject {
  62302. }
  62303. declare var WebGLVertexArrayObject: {
  62304. prototype: WebGLVertexArrayObject;
  62305. new(): WebGLVertexArrayObject;
  62306. };
  62307. // Type definitions for WebVR API
  62308. // Project: https://w3c.github.io/webvr/
  62309. // Definitions by: six a <https://github.com/lostfictions>
  62310. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62311. interface VRDisplay extends EventTarget {
  62312. /**
  62313. * Dictionary of capabilities describing the VRDisplay.
  62314. */
  62315. readonly capabilities: VRDisplayCapabilities;
  62316. /**
  62317. * z-depth defining the far plane of the eye view frustum
  62318. * enables mapping of values in the render target depth
  62319. * attachment to scene coordinates. Initially set to 10000.0.
  62320. */
  62321. depthFar: number;
  62322. /**
  62323. * z-depth defining the near plane of the eye view frustum
  62324. * enables mapping of values in the render target depth
  62325. * attachment to scene coordinates. Initially set to 0.01.
  62326. */
  62327. depthNear: number;
  62328. /**
  62329. * An identifier for this distinct VRDisplay. Used as an
  62330. * association point in the Gamepad API.
  62331. */
  62332. readonly displayId: number;
  62333. /**
  62334. * A display name, a user-readable name identifying it.
  62335. */
  62336. readonly displayName: string;
  62337. readonly isConnected: boolean;
  62338. readonly isPresenting: boolean;
  62339. /**
  62340. * If this VRDisplay supports room-scale experiences, the optional
  62341. * stage attribute contains details on the room-scale parameters.
  62342. */
  62343. readonly stageParameters: VRStageParameters | null;
  62344. /**
  62345. * Passing the value returned by `requestAnimationFrame` to
  62346. * `cancelAnimationFrame` will unregister the callback.
  62347. * @param handle Define the hanle of the request to cancel
  62348. */
  62349. cancelAnimationFrame(handle: number): void;
  62350. /**
  62351. * Stops presenting to the VRDisplay.
  62352. * @returns a promise to know when it stopped
  62353. */
  62354. exitPresent(): Promise<void>;
  62355. /**
  62356. * Return the current VREyeParameters for the given eye.
  62357. * @param whichEye Define the eye we want the parameter for
  62358. * @returns the eye parameters
  62359. */
  62360. getEyeParameters(whichEye: string): VREyeParameters;
  62361. /**
  62362. * Populates the passed VRFrameData with the information required to render
  62363. * the current frame.
  62364. * @param frameData Define the data structure to populate
  62365. * @returns true if ok otherwise false
  62366. */
  62367. getFrameData(frameData: VRFrameData): boolean;
  62368. /**
  62369. * Get the layers currently being presented.
  62370. * @returns the list of VR layers
  62371. */
  62372. getLayers(): VRLayer[];
  62373. /**
  62374. * Return a VRPose containing the future predicted pose of the VRDisplay
  62375. * when the current frame will be presented. The value returned will not
  62376. * change until JavaScript has returned control to the browser.
  62377. *
  62378. * The VRPose will contain the position, orientation, velocity,
  62379. * and acceleration of each of these properties.
  62380. * @returns the pose object
  62381. */
  62382. getPose(): VRPose;
  62383. /**
  62384. * Return the current instantaneous pose of the VRDisplay, with no
  62385. * prediction applied.
  62386. * @returns the current instantaneous pose
  62387. */
  62388. getImmediatePose(): VRPose;
  62389. /**
  62390. * The callback passed to `requestAnimationFrame` will be called
  62391. * any time a new frame should be rendered. When the VRDisplay is
  62392. * presenting the callback will be called at the native refresh
  62393. * rate of the HMD. When not presenting this function acts
  62394. * identically to how window.requestAnimationFrame acts. Content should
  62395. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62396. * asynchronously from other displays and at differing refresh rates.
  62397. * @param callback Define the eaction to run next frame
  62398. * @returns the request handle it
  62399. */
  62400. requestAnimationFrame(callback: FrameRequestCallback): number;
  62401. /**
  62402. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62403. * Repeat calls while already presenting will update the VRLayers being displayed.
  62404. * @param layers Define the list of layer to present
  62405. * @returns a promise to know when the request has been fulfilled
  62406. */
  62407. requestPresent(layers: VRLayer[]): Promise<void>;
  62408. /**
  62409. * Reset the pose for this display, treating its current position and
  62410. * orientation as the "origin/zero" values. VRPose.position,
  62411. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62412. * updated when calling resetPose(). This should be called in only
  62413. * sitting-space experiences.
  62414. */
  62415. resetPose(): void;
  62416. /**
  62417. * The VRLayer provided to the VRDisplay will be captured and presented
  62418. * in the HMD. Calling this function has the same effect on the source
  62419. * canvas as any other operation that uses its source image, and canvases
  62420. * created without preserveDrawingBuffer set to true will be cleared.
  62421. * @param pose Define the pose to submit
  62422. */
  62423. submitFrame(pose?: VRPose): void;
  62424. }
  62425. declare var VRDisplay: {
  62426. prototype: VRDisplay;
  62427. new(): VRDisplay;
  62428. };
  62429. interface VRLayer {
  62430. leftBounds?: number[] | Float32Array | null;
  62431. rightBounds?: number[] | Float32Array | null;
  62432. source?: HTMLCanvasElement | null;
  62433. }
  62434. interface VRDisplayCapabilities {
  62435. readonly canPresent: boolean;
  62436. readonly hasExternalDisplay: boolean;
  62437. readonly hasOrientation: boolean;
  62438. readonly hasPosition: boolean;
  62439. readonly maxLayers: number;
  62440. }
  62441. interface VREyeParameters {
  62442. /** @deprecated */
  62443. readonly fieldOfView: VRFieldOfView;
  62444. readonly offset: Float32Array;
  62445. readonly renderHeight: number;
  62446. readonly renderWidth: number;
  62447. }
  62448. interface VRFieldOfView {
  62449. readonly downDegrees: number;
  62450. readonly leftDegrees: number;
  62451. readonly rightDegrees: number;
  62452. readonly upDegrees: number;
  62453. }
  62454. interface VRFrameData {
  62455. readonly leftProjectionMatrix: Float32Array;
  62456. readonly leftViewMatrix: Float32Array;
  62457. readonly pose: VRPose;
  62458. readonly rightProjectionMatrix: Float32Array;
  62459. readonly rightViewMatrix: Float32Array;
  62460. readonly timestamp: number;
  62461. }
  62462. interface VRPose {
  62463. readonly angularAcceleration: Float32Array | null;
  62464. readonly angularVelocity: Float32Array | null;
  62465. readonly linearAcceleration: Float32Array | null;
  62466. readonly linearVelocity: Float32Array | null;
  62467. readonly orientation: Float32Array | null;
  62468. readonly position: Float32Array | null;
  62469. readonly timestamp: number;
  62470. }
  62471. interface VRStageParameters {
  62472. sittingToStandingTransform?: Float32Array;
  62473. sizeX?: number;
  62474. sizeY?: number;
  62475. }
  62476. interface Navigator {
  62477. getVRDisplays(): Promise<VRDisplay[]>;
  62478. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62479. }
  62480. interface Window {
  62481. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62482. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62483. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62484. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62485. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62486. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62487. }
  62488. interface Gamepad {
  62489. readonly displayId: number;
  62490. }
  62491. type XRSessionMode =
  62492. | "inline"
  62493. | "immersive-vr"
  62494. | "immersive-ar";
  62495. type XRReferenceSpaceType =
  62496. | "viewer"
  62497. | "local"
  62498. | "local-floor"
  62499. | "bounded-floor"
  62500. | "unbounded";
  62501. type XREnvironmentBlendMode =
  62502. | "opaque"
  62503. | "additive"
  62504. | "alpha-blend";
  62505. type XRVisibilityState =
  62506. | "visible"
  62507. | "visible-blurred"
  62508. | "hidden";
  62509. type XRHandedness =
  62510. | "none"
  62511. | "left"
  62512. | "right";
  62513. type XRTargetRayMode =
  62514. | "gaze"
  62515. | "tracked-pointer"
  62516. | "screen";
  62517. type XREye =
  62518. | "none"
  62519. | "left"
  62520. | "right";
  62521. interface XRSpace extends EventTarget {
  62522. }
  62523. interface XRRenderState {
  62524. depthNear?: number;
  62525. depthFar?: number;
  62526. inlineVerticalFieldOfView?: number;
  62527. baseLayer?: XRWebGLLayer;
  62528. }
  62529. interface XRInputSource {
  62530. handedness: XRHandedness;
  62531. targetRayMode: XRTargetRayMode;
  62532. targetRaySpace: XRSpace;
  62533. gripSpace: XRSpace | undefined;
  62534. gamepad: Gamepad | undefined;
  62535. profiles: Array<string>;
  62536. }
  62537. interface XRSession {
  62538. addEventListener: Function;
  62539. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62540. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62541. requestAnimationFrame: Function;
  62542. end(): Promise<void>;
  62543. renderState: XRRenderState;
  62544. inputSources: Array<XRInputSource>;
  62545. }
  62546. interface XRReferenceSpace extends XRSpace {
  62547. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62548. onreset: any;
  62549. }
  62550. interface XRFrame {
  62551. session: XRSession;
  62552. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62553. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62554. }
  62555. interface XRViewerPose extends XRPose {
  62556. views: Array<XRView>;
  62557. }
  62558. interface XRPose {
  62559. transform: XRRigidTransform;
  62560. emulatedPosition: boolean;
  62561. }
  62562. declare var XRWebGLLayer: {
  62563. prototype: XRWebGLLayer;
  62564. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62565. };
  62566. interface XRWebGLLayer {
  62567. framebuffer: WebGLFramebuffer;
  62568. framebufferWidth: number;
  62569. framebufferHeight: number;
  62570. getViewport: Function;
  62571. }
  62572. interface XRRigidTransform {
  62573. position: DOMPointReadOnly;
  62574. orientation: DOMPointReadOnly;
  62575. matrix: Float32Array;
  62576. inverse: XRRigidTransform;
  62577. }
  62578. interface XRView {
  62579. eye: XREye;
  62580. projectionMatrix: Float32Array;
  62581. transform: XRRigidTransform;
  62582. }
  62583. interface XRInputSourceChangeEvent {
  62584. session: XRSession;
  62585. removed: Array<XRInputSource>;
  62586. added: Array<XRInputSource>;
  62587. }
  62588. declare module BABYLON.GUI {
  62589. /**
  62590. * Class used to specific a value and its associated unit
  62591. */
  62592. export class ValueAndUnit {
  62593. /** defines the unit to store */
  62594. unit: number;
  62595. /** defines a boolean indicating if the value can be negative */
  62596. negativeValueAllowed: boolean;
  62597. private _value;
  62598. private _originalUnit;
  62599. /**
  62600. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62601. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62602. */
  62603. ignoreAdaptiveScaling: boolean;
  62604. /**
  62605. * Creates a new ValueAndUnit
  62606. * @param value defines the value to store
  62607. * @param unit defines the unit to store
  62608. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62609. */
  62610. constructor(value: number,
  62611. /** defines the unit to store */
  62612. unit?: number,
  62613. /** defines a boolean indicating if the value can be negative */
  62614. negativeValueAllowed?: boolean);
  62615. /** Gets a boolean indicating if the value is a percentage */
  62616. readonly isPercentage: boolean;
  62617. /** Gets a boolean indicating if the value is store as pixel */
  62618. readonly isPixel: boolean;
  62619. /** Gets direct internal value */
  62620. readonly internalValue: number;
  62621. /**
  62622. * Gets value as pixel
  62623. * @param host defines the root host
  62624. * @param refValue defines the reference value for percentages
  62625. * @returns the value as pixel
  62626. */
  62627. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62628. /**
  62629. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62630. * @param value defines the value to store
  62631. * @param unit defines the unit to store
  62632. * @returns the current ValueAndUnit
  62633. */
  62634. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62635. /**
  62636. * Gets the value accordingly to its unit
  62637. * @param host defines the root host
  62638. * @returns the value
  62639. */
  62640. getValue(host: AdvancedDynamicTexture): number;
  62641. /**
  62642. * Gets a string representation of the value
  62643. * @param host defines the root host
  62644. * @param decimals defines an optional number of decimals to display
  62645. * @returns a string
  62646. */
  62647. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62648. /**
  62649. * Store a value parsed from a string
  62650. * @param source defines the source string
  62651. * @returns true if the value was successfully parsed
  62652. */
  62653. fromString(source: string | number): boolean;
  62654. private static _Regex;
  62655. private static _UNITMODE_PERCENTAGE;
  62656. private static _UNITMODE_PIXEL;
  62657. /** UNITMODE_PERCENTAGE */
  62658. static readonly UNITMODE_PERCENTAGE: number;
  62659. /** UNITMODE_PIXEL */
  62660. static readonly UNITMODE_PIXEL: number;
  62661. }
  62662. }
  62663. declare module BABYLON.GUI {
  62664. /**
  62665. * Define a style used by control to automatically setup properties based on a template.
  62666. * Only support font related properties so far
  62667. */
  62668. export class Style implements BABYLON.IDisposable {
  62669. private _fontFamily;
  62670. private _fontStyle;
  62671. private _fontWeight;
  62672. /** @hidden */
  62673. _host: AdvancedDynamicTexture;
  62674. /** @hidden */
  62675. _fontSize: ValueAndUnit;
  62676. /**
  62677. * BABYLON.Observable raised when the style values are changed
  62678. */
  62679. onChangedObservable: BABYLON.Observable<Style>;
  62680. /**
  62681. * Creates a new style object
  62682. * @param host defines the AdvancedDynamicTexture which hosts this style
  62683. */
  62684. constructor(host: AdvancedDynamicTexture);
  62685. /**
  62686. * Gets or sets the font size
  62687. */
  62688. fontSize: string | number;
  62689. /**
  62690. * Gets or sets the font family
  62691. */
  62692. fontFamily: string;
  62693. /**
  62694. * Gets or sets the font style
  62695. */
  62696. fontStyle: string;
  62697. /** Gets or sets font weight */
  62698. fontWeight: string;
  62699. /** Dispose all associated resources */
  62700. dispose(): void;
  62701. }
  62702. }
  62703. declare module BABYLON.GUI {
  62704. /**
  62705. * Class used to transport BABYLON.Vector2 information for pointer events
  62706. */
  62707. export class Vector2WithInfo extends BABYLON.Vector2 {
  62708. /** defines the current mouse button index */
  62709. buttonIndex: number;
  62710. /**
  62711. * Creates a new Vector2WithInfo
  62712. * @param source defines the vector2 data to transport
  62713. * @param buttonIndex defines the current mouse button index
  62714. */
  62715. constructor(source: BABYLON.Vector2,
  62716. /** defines the current mouse button index */
  62717. buttonIndex?: number);
  62718. }
  62719. /** Class used to provide 2D matrix features */
  62720. export class Matrix2D {
  62721. /** Gets the internal array of 6 floats used to store matrix data */
  62722. m: Float32Array;
  62723. /**
  62724. * Creates a new matrix
  62725. * @param m00 defines value for (0, 0)
  62726. * @param m01 defines value for (0, 1)
  62727. * @param m10 defines value for (1, 0)
  62728. * @param m11 defines value for (1, 1)
  62729. * @param m20 defines value for (2, 0)
  62730. * @param m21 defines value for (2, 1)
  62731. */
  62732. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62733. /**
  62734. * Fills the matrix from direct values
  62735. * @param m00 defines value for (0, 0)
  62736. * @param m01 defines value for (0, 1)
  62737. * @param m10 defines value for (1, 0)
  62738. * @param m11 defines value for (1, 1)
  62739. * @param m20 defines value for (2, 0)
  62740. * @param m21 defines value for (2, 1)
  62741. * @returns the current modified matrix
  62742. */
  62743. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62744. /**
  62745. * Gets matrix determinant
  62746. * @returns the determinant
  62747. */
  62748. determinant(): number;
  62749. /**
  62750. * Inverses the matrix and stores it in a target matrix
  62751. * @param result defines the target matrix
  62752. * @returns the current matrix
  62753. */
  62754. invertToRef(result: Matrix2D): Matrix2D;
  62755. /**
  62756. * Multiplies the current matrix with another one
  62757. * @param other defines the second operand
  62758. * @param result defines the target matrix
  62759. * @returns the current matrix
  62760. */
  62761. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62762. /**
  62763. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62764. * @param x defines the x coordinate to transform
  62765. * @param y defines the x coordinate to transform
  62766. * @param result defines the target vector2
  62767. * @returns the current matrix
  62768. */
  62769. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62770. /**
  62771. * Creates an identity matrix
  62772. * @returns a new matrix
  62773. */
  62774. static Identity(): Matrix2D;
  62775. /**
  62776. * Creates a translation matrix and stores it in a target matrix
  62777. * @param x defines the x coordinate of the translation
  62778. * @param y defines the y coordinate of the translation
  62779. * @param result defines the target matrix
  62780. */
  62781. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62782. /**
  62783. * Creates a scaling matrix and stores it in a target matrix
  62784. * @param x defines the x coordinate of the scaling
  62785. * @param y defines the y coordinate of the scaling
  62786. * @param result defines the target matrix
  62787. */
  62788. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62789. /**
  62790. * Creates a rotation matrix and stores it in a target matrix
  62791. * @param angle defines the rotation angle
  62792. * @param result defines the target matrix
  62793. */
  62794. static RotationToRef(angle: number, result: Matrix2D): void;
  62795. private static _TempPreTranslationMatrix;
  62796. private static _TempPostTranslationMatrix;
  62797. private static _TempRotationMatrix;
  62798. private static _TempScalingMatrix;
  62799. private static _TempCompose0;
  62800. private static _TempCompose1;
  62801. private static _TempCompose2;
  62802. /**
  62803. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62804. * @param tx defines the x coordinate of the translation
  62805. * @param ty defines the y coordinate of the translation
  62806. * @param angle defines the rotation angle
  62807. * @param scaleX defines the x coordinate of the scaling
  62808. * @param scaleY defines the y coordinate of the scaling
  62809. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62810. * @param result defines the target matrix
  62811. */
  62812. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62813. }
  62814. }
  62815. declare module BABYLON.GUI {
  62816. /**
  62817. * Class used to store 2D control sizes
  62818. */
  62819. export class Measure {
  62820. /** defines left coordinate */
  62821. left: number;
  62822. /** defines top coordinate */
  62823. top: number;
  62824. /** defines width dimension */
  62825. width: number;
  62826. /** defines height dimension */
  62827. height: number;
  62828. /**
  62829. * Creates a new measure
  62830. * @param left defines left coordinate
  62831. * @param top defines top coordinate
  62832. * @param width defines width dimension
  62833. * @param height defines height dimension
  62834. */
  62835. constructor(
  62836. /** defines left coordinate */
  62837. left: number,
  62838. /** defines top coordinate */
  62839. top: number,
  62840. /** defines width dimension */
  62841. width: number,
  62842. /** defines height dimension */
  62843. height: number);
  62844. /**
  62845. * Copy from another measure
  62846. * @param other defines the other measure to copy from
  62847. */
  62848. copyFrom(other: Measure): void;
  62849. /**
  62850. * Copy from a group of 4 floats
  62851. * @param left defines left coordinate
  62852. * @param top defines top coordinate
  62853. * @param width defines width dimension
  62854. * @param height defines height dimension
  62855. */
  62856. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62857. /**
  62858. * Computes the axis aligned bounding box measure for two given measures
  62859. * @param a Input measure
  62860. * @param b Input measure
  62861. * @param result the resulting bounding measure
  62862. */
  62863. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62864. /**
  62865. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62866. * @param transform the matrix to transform the measure before computing the AABB
  62867. * @param result the resulting AABB
  62868. */
  62869. transformToRef(transform: Matrix2D, result: Measure): void;
  62870. /**
  62871. * Check equality between this measure and another one
  62872. * @param other defines the other measures
  62873. * @returns true if both measures are equals
  62874. */
  62875. isEqualsTo(other: Measure): boolean;
  62876. /**
  62877. * Creates an empty measure
  62878. * @returns a new measure
  62879. */
  62880. static Empty(): Measure;
  62881. }
  62882. }
  62883. declare module BABYLON.GUI {
  62884. /**
  62885. * Interface used to define a control that can receive focus
  62886. */
  62887. export interface IFocusableControl {
  62888. /**
  62889. * Function called when the control receives the focus
  62890. */
  62891. onFocus(): void;
  62892. /**
  62893. * Function called when the control loses the focus
  62894. */
  62895. onBlur(): void;
  62896. /**
  62897. * Function called to let the control handle keyboard events
  62898. * @param evt defines the current keyboard event
  62899. */
  62900. processKeyboard(evt: KeyboardEvent): void;
  62901. /**
  62902. * Function called to get the list of controls that should not steal the focus from this control
  62903. * @returns an array of controls
  62904. */
  62905. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62906. }
  62907. /**
  62908. * Class used to create texture to support 2D GUI elements
  62909. * @see http://doc.babylonjs.com/how_to/gui
  62910. */
  62911. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62912. private _isDirty;
  62913. private _renderObserver;
  62914. private _resizeObserver;
  62915. private _preKeyboardObserver;
  62916. private _pointerMoveObserver;
  62917. private _pointerObserver;
  62918. private _canvasPointerOutObserver;
  62919. private _background;
  62920. /** @hidden */
  62921. _rootContainer: Container;
  62922. /** @hidden */
  62923. _lastPickedControl: Control;
  62924. /** @hidden */
  62925. _lastControlOver: {
  62926. [pointerId: number]: Control;
  62927. };
  62928. /** @hidden */
  62929. _lastControlDown: {
  62930. [pointerId: number]: Control;
  62931. };
  62932. /** @hidden */
  62933. _capturingControl: {
  62934. [pointerId: number]: Control;
  62935. };
  62936. /** @hidden */
  62937. _shouldBlockPointer: boolean;
  62938. /** @hidden */
  62939. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62940. /** @hidden */
  62941. _linkedControls: Control[];
  62942. private _isFullscreen;
  62943. private _fullscreenViewport;
  62944. private _idealWidth;
  62945. private _idealHeight;
  62946. private _useSmallestIdeal;
  62947. private _renderAtIdealSize;
  62948. private _focusedControl;
  62949. private _blockNextFocusCheck;
  62950. private _renderScale;
  62951. private _rootCanvas;
  62952. private _cursorChanged;
  62953. /**
  62954. * Define type to string to ensure compatibility across browsers
  62955. * Safari doesn't support DataTransfer constructor
  62956. */
  62957. private _clipboardData;
  62958. /**
  62959. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62960. */
  62961. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62962. /**
  62963. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62964. */
  62965. onControlPickedObservable: BABYLON.Observable<Control>;
  62966. /**
  62967. * BABYLON.Observable event triggered before layout is evaluated
  62968. */
  62969. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62970. /**
  62971. * BABYLON.Observable event triggered after the layout was evaluated
  62972. */
  62973. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62974. /**
  62975. * BABYLON.Observable event triggered before the texture is rendered
  62976. */
  62977. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62978. /**
  62979. * BABYLON.Observable event triggered after the texture was rendered
  62980. */
  62981. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62982. /**
  62983. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62984. */
  62985. premulAlpha: boolean;
  62986. /**
  62987. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62988. * Useful when you want more antialiasing
  62989. */
  62990. renderScale: number;
  62991. /** Gets or sets the background color */
  62992. background: string;
  62993. /**
  62994. * Gets or sets the ideal width used to design controls.
  62995. * The GUI will then rescale everything accordingly
  62996. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62997. */
  62998. idealWidth: number;
  62999. /**
  63000. * Gets or sets the ideal height used to design controls.
  63001. * The GUI will then rescale everything accordingly
  63002. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63003. */
  63004. idealHeight: number;
  63005. /**
  63006. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63007. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63008. */
  63009. useSmallestIdeal: boolean;
  63010. /**
  63011. * Gets or sets a boolean indicating if adaptive scaling must be used
  63012. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63013. */
  63014. renderAtIdealSize: boolean;
  63015. /**
  63016. * Gets the underlying layer used to render the texture when in fullscreen mode
  63017. */
  63018. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63019. /**
  63020. * Gets the root container control
  63021. */
  63022. readonly rootContainer: Container;
  63023. /**
  63024. * Returns an array containing the root container.
  63025. * This is mostly used to let the Inspector introspects the ADT
  63026. * @returns an array containing the rootContainer
  63027. */
  63028. getChildren(): Array<Container>;
  63029. /**
  63030. * Will return all controls that are inside this texture
  63031. * @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
  63032. * @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
  63033. * @return all child controls
  63034. */
  63035. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63036. /**
  63037. * Gets or sets the current focused control
  63038. */
  63039. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63040. /**
  63041. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63042. */
  63043. isForeground: boolean;
  63044. /**
  63045. * Gets or set information about clipboardData
  63046. */
  63047. clipboardData: string;
  63048. /**
  63049. * Creates a new AdvancedDynamicTexture
  63050. * @param name defines the name of the texture
  63051. * @param width defines the width of the texture
  63052. * @param height defines the height of the texture
  63053. * @param scene defines the hosting scene
  63054. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63055. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63056. */
  63057. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63058. /**
  63059. * Get the current class name of the texture useful for serialization or dynamic coding.
  63060. * @returns "AdvancedDynamicTexture"
  63061. */
  63062. getClassName(): string;
  63063. /**
  63064. * Function used to execute a function on all controls
  63065. * @param func defines the function to execute
  63066. * @param container defines the container where controls belong. If null the root container will be used
  63067. */
  63068. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63069. private _useInvalidateRectOptimization;
  63070. /**
  63071. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63072. */
  63073. useInvalidateRectOptimization: boolean;
  63074. private _invalidatedRectangle;
  63075. /**
  63076. * Invalidates a rectangle area on the gui texture
  63077. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63078. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63079. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63080. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63081. */
  63082. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63083. /**
  63084. * Marks the texture as dirty forcing a complete update
  63085. */
  63086. markAsDirty(): void;
  63087. /**
  63088. * Helper function used to create a new style
  63089. * @returns a new style
  63090. * @see http://doc.babylonjs.com/how_to/gui#styles
  63091. */
  63092. createStyle(): Style;
  63093. /**
  63094. * Adds a new control to the root container
  63095. * @param control defines the control to add
  63096. * @returns the current texture
  63097. */
  63098. addControl(control: Control): AdvancedDynamicTexture;
  63099. /**
  63100. * Removes a control from the root container
  63101. * @param control defines the control to remove
  63102. * @returns the current texture
  63103. */
  63104. removeControl(control: Control): AdvancedDynamicTexture;
  63105. /**
  63106. * Release all resources
  63107. */
  63108. dispose(): void;
  63109. private _onResize;
  63110. /** @hidden */
  63111. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63112. /**
  63113. * Get screen coordinates for a vector3
  63114. * @param position defines the position to project
  63115. * @param worldMatrix defines the world matrix to use
  63116. * @returns the projected position
  63117. */
  63118. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63119. private _checkUpdate;
  63120. private _clearMeasure;
  63121. private _render;
  63122. /** @hidden */
  63123. _changeCursor(cursor: string): void;
  63124. /** @hidden */
  63125. _registerLastControlDown(control: Control, pointerId: number): void;
  63126. private _doPicking;
  63127. /** @hidden */
  63128. _cleanControlAfterRemovalFromList(list: {
  63129. [pointerId: number]: Control;
  63130. }, control: Control): void;
  63131. /** @hidden */
  63132. _cleanControlAfterRemoval(control: Control): void;
  63133. /** Attach to all scene events required to support pointer events */
  63134. attach(): void;
  63135. /** @hidden */
  63136. private onClipboardCopy;
  63137. /** @hidden */
  63138. private onClipboardCut;
  63139. /** @hidden */
  63140. private onClipboardPaste;
  63141. /**
  63142. * Register the clipboard Events onto the canvas
  63143. */
  63144. registerClipboardEvents(): void;
  63145. /**
  63146. * Unregister the clipboard Events from the canvas
  63147. */
  63148. unRegisterClipboardEvents(): void;
  63149. /**
  63150. * Connect the texture to a hosting mesh to enable interactions
  63151. * @param mesh defines the mesh to attach to
  63152. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63153. */
  63154. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63155. /**
  63156. * Move the focus to a specific control
  63157. * @param control defines the control which will receive the focus
  63158. */
  63159. moveFocusToControl(control: IFocusableControl): void;
  63160. private _manageFocus;
  63161. private _attachToOnPointerOut;
  63162. /**
  63163. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63164. * @param mesh defines the mesh which will receive the texture
  63165. * @param width defines the texture width (1024 by default)
  63166. * @param height defines the texture height (1024 by default)
  63167. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63168. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63169. * @returns a new AdvancedDynamicTexture
  63170. */
  63171. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63172. /**
  63173. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63174. * In this mode the texture will rely on a layer for its rendering.
  63175. * This allows it to be treated like any other layer.
  63176. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63177. * LayerMask is set through advancedTexture.layer.layerMask
  63178. * @param name defines name for the texture
  63179. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63180. * @param scene defines the hsoting scene
  63181. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63182. * @returns a new AdvancedDynamicTexture
  63183. */
  63184. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63185. }
  63186. }
  63187. declare module BABYLON.GUI {
  63188. /**
  63189. * Root class used for all 2D controls
  63190. * @see http://doc.babylonjs.com/how_to/gui#controls
  63191. */
  63192. export class Control {
  63193. /** defines the name of the control */
  63194. name?: string | undefined;
  63195. /**
  63196. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63197. */
  63198. static AllowAlphaInheritance: boolean;
  63199. private _alpha;
  63200. private _alphaSet;
  63201. private _zIndex;
  63202. /** @hidden */
  63203. _host: AdvancedDynamicTexture;
  63204. /** Gets or sets the control parent */
  63205. parent: BABYLON.Nullable<Container>;
  63206. /** @hidden */
  63207. _currentMeasure: Measure;
  63208. private _fontFamily;
  63209. private _fontStyle;
  63210. private _fontWeight;
  63211. private _fontSize;
  63212. private _font;
  63213. /** @hidden */
  63214. _width: ValueAndUnit;
  63215. /** @hidden */
  63216. _height: ValueAndUnit;
  63217. /** @hidden */
  63218. protected _fontOffset: {
  63219. ascent: number;
  63220. height: number;
  63221. descent: number;
  63222. };
  63223. private _color;
  63224. private _style;
  63225. private _styleObserver;
  63226. /** @hidden */
  63227. protected _horizontalAlignment: number;
  63228. /** @hidden */
  63229. protected _verticalAlignment: number;
  63230. /** @hidden */
  63231. protected _isDirty: boolean;
  63232. /** @hidden */
  63233. protected _wasDirty: boolean;
  63234. /** @hidden */
  63235. _tempParentMeasure: Measure;
  63236. /** @hidden */
  63237. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63238. /** @hidden */
  63239. protected _cachedParentMeasure: Measure;
  63240. private _paddingLeft;
  63241. private _paddingRight;
  63242. private _paddingTop;
  63243. private _paddingBottom;
  63244. /** @hidden */
  63245. _left: ValueAndUnit;
  63246. /** @hidden */
  63247. _top: ValueAndUnit;
  63248. private _scaleX;
  63249. private _scaleY;
  63250. private _rotation;
  63251. private _transformCenterX;
  63252. private _transformCenterY;
  63253. /** @hidden */
  63254. _transformMatrix: Matrix2D;
  63255. /** @hidden */
  63256. protected _invertTransformMatrix: Matrix2D;
  63257. /** @hidden */
  63258. protected _transformedPosition: BABYLON.Vector2;
  63259. private _isMatrixDirty;
  63260. private _cachedOffsetX;
  63261. private _cachedOffsetY;
  63262. private _isVisible;
  63263. private _isHighlighted;
  63264. /** @hidden */
  63265. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63266. private _fontSet;
  63267. private _dummyVector2;
  63268. private _downCount;
  63269. private _enterCount;
  63270. private _doNotRender;
  63271. private _downPointerIds;
  63272. protected _isEnabled: boolean;
  63273. protected _disabledColor: string;
  63274. /** @hidden */
  63275. protected _rebuildLayout: boolean;
  63276. /** @hidden */
  63277. _isClipped: boolean;
  63278. /** @hidden */
  63279. _tag: any;
  63280. /**
  63281. * 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
  63282. */
  63283. uniqueId: number;
  63284. /**
  63285. * Gets or sets an object used to store user defined information for the node
  63286. */
  63287. metadata: any;
  63288. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63289. isHitTestVisible: boolean;
  63290. /** Gets or sets a boolean indicating if the control can block pointer events */
  63291. isPointerBlocker: boolean;
  63292. /** Gets or sets a boolean indicating if the control can be focusable */
  63293. isFocusInvisible: boolean;
  63294. /**
  63295. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63296. * 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
  63297. */
  63298. clipChildren: boolean;
  63299. /**
  63300. * Gets or sets a boolean indicating that control content must be clipped
  63301. * 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
  63302. */
  63303. clipContent: boolean;
  63304. /**
  63305. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63306. */
  63307. useBitmapCache: boolean;
  63308. private _cacheData;
  63309. private _shadowOffsetX;
  63310. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63311. shadowOffsetX: number;
  63312. private _shadowOffsetY;
  63313. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63314. shadowOffsetY: number;
  63315. private _shadowBlur;
  63316. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63317. shadowBlur: number;
  63318. private _shadowColor;
  63319. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63320. shadowColor: string;
  63321. /** Gets or sets the cursor to use when the control is hovered */
  63322. hoverCursor: string;
  63323. /** @hidden */
  63324. protected _linkOffsetX: ValueAndUnit;
  63325. /** @hidden */
  63326. protected _linkOffsetY: ValueAndUnit;
  63327. /** Gets the control type name */
  63328. readonly typeName: string;
  63329. /**
  63330. * Get the current class name of the control.
  63331. * @returns current class name
  63332. */
  63333. getClassName(): string;
  63334. /**
  63335. * An event triggered when the pointer move over the control.
  63336. */
  63337. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63338. /**
  63339. * An event triggered when the pointer move out of the control.
  63340. */
  63341. onPointerOutObservable: BABYLON.Observable<Control>;
  63342. /**
  63343. * An event triggered when the pointer taps the control
  63344. */
  63345. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63346. /**
  63347. * An event triggered when pointer up
  63348. */
  63349. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63350. /**
  63351. * An event triggered when a control is clicked on
  63352. */
  63353. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63354. /**
  63355. * An event triggered when pointer enters the control
  63356. */
  63357. onPointerEnterObservable: BABYLON.Observable<Control>;
  63358. /**
  63359. * An event triggered when the control is marked as dirty
  63360. */
  63361. onDirtyObservable: BABYLON.Observable<Control>;
  63362. /**
  63363. * An event triggered before drawing the control
  63364. */
  63365. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63366. /**
  63367. * An event triggered after the control was drawn
  63368. */
  63369. onAfterDrawObservable: BABYLON.Observable<Control>;
  63370. /**
  63371. * Get the hosting AdvancedDynamicTexture
  63372. */
  63373. readonly host: AdvancedDynamicTexture;
  63374. /** Gets or set information about font offsets (used to render and align text) */
  63375. fontOffset: {
  63376. ascent: number;
  63377. height: number;
  63378. descent: number;
  63379. };
  63380. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63381. alpha: number;
  63382. /**
  63383. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63384. */
  63385. isHighlighted: boolean;
  63386. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63387. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63388. */
  63389. scaleX: number;
  63390. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63391. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63392. */
  63393. scaleY: number;
  63394. /** Gets or sets the rotation angle (0 by default)
  63395. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63396. */
  63397. rotation: number;
  63398. /** Gets or sets the transformation center on Y axis (0 by default)
  63399. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63400. */
  63401. transformCenterY: number;
  63402. /** Gets or sets the transformation center on X axis (0 by default)
  63403. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63404. */
  63405. transformCenterX: number;
  63406. /**
  63407. * Gets or sets the horizontal alignment
  63408. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63409. */
  63410. horizontalAlignment: number;
  63411. /**
  63412. * Gets or sets the vertical alignment
  63413. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63414. */
  63415. verticalAlignment: number;
  63416. /**
  63417. * Gets or sets control width
  63418. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63419. */
  63420. width: string | number;
  63421. /**
  63422. * Gets or sets the control width in pixel
  63423. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63424. */
  63425. widthInPixels: number;
  63426. /**
  63427. * Gets or sets control height
  63428. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63429. */
  63430. height: string | number;
  63431. /**
  63432. * Gets or sets control height in pixel
  63433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63434. */
  63435. heightInPixels: number;
  63436. /** Gets or set font family */
  63437. fontFamily: string;
  63438. /** Gets or sets font style */
  63439. fontStyle: string;
  63440. /** Gets or sets font weight */
  63441. fontWeight: string;
  63442. /**
  63443. * Gets or sets style
  63444. * @see http://doc.babylonjs.com/how_to/gui#styles
  63445. */
  63446. style: BABYLON.Nullable<Style>;
  63447. /** @hidden */
  63448. readonly _isFontSizeInPercentage: boolean;
  63449. /** Gets or sets font size in pixels */
  63450. fontSizeInPixels: number;
  63451. /** Gets or sets font size */
  63452. fontSize: string | number;
  63453. /** Gets or sets foreground color */
  63454. color: string;
  63455. /** Gets or sets z index which is used to reorder controls on the z axis */
  63456. zIndex: number;
  63457. /** Gets or sets a boolean indicating if the control can be rendered */
  63458. notRenderable: boolean;
  63459. /** Gets or sets a boolean indicating if the control is visible */
  63460. isVisible: boolean;
  63461. /** Gets a boolean indicating that the control needs to update its rendering */
  63462. readonly isDirty: boolean;
  63463. /**
  63464. * Gets the current linked mesh (or null if none)
  63465. */
  63466. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63467. /**
  63468. * Gets or sets a value indicating the padding to use on the left of the control
  63469. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63470. */
  63471. paddingLeft: string | number;
  63472. /**
  63473. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63474. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63475. */
  63476. paddingLeftInPixels: number;
  63477. /**
  63478. * Gets or sets a value indicating the padding to use on the right of the control
  63479. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63480. */
  63481. paddingRight: string | number;
  63482. /**
  63483. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63484. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63485. */
  63486. paddingRightInPixels: number;
  63487. /**
  63488. * Gets or sets a value indicating the padding to use on the top of the control
  63489. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63490. */
  63491. paddingTop: string | number;
  63492. /**
  63493. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63494. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63495. */
  63496. paddingTopInPixels: number;
  63497. /**
  63498. * Gets or sets a value indicating the padding to use on the bottom of the control
  63499. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63500. */
  63501. paddingBottom: string | number;
  63502. /**
  63503. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63504. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63505. */
  63506. paddingBottomInPixels: number;
  63507. /**
  63508. * Gets or sets a value indicating the left coordinate of the control
  63509. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63510. */
  63511. left: string | number;
  63512. /**
  63513. * Gets or sets a value indicating the left coordinate in pixels of the control
  63514. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63515. */
  63516. leftInPixels: number;
  63517. /**
  63518. * Gets or sets a value indicating the top coordinate of the control
  63519. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63520. */
  63521. top: string | number;
  63522. /**
  63523. * Gets or sets a value indicating the top coordinate in pixels of the control
  63524. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63525. */
  63526. topInPixels: number;
  63527. /**
  63528. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63529. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63530. */
  63531. linkOffsetX: string | number;
  63532. /**
  63533. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63534. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63535. */
  63536. linkOffsetXInPixels: number;
  63537. /**
  63538. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63539. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63540. */
  63541. linkOffsetY: string | number;
  63542. /**
  63543. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63544. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63545. */
  63546. linkOffsetYInPixels: number;
  63547. /** Gets the center coordinate on X axis */
  63548. readonly centerX: number;
  63549. /** Gets the center coordinate on Y axis */
  63550. readonly centerY: number;
  63551. /** Gets or sets if control is Enabled*/
  63552. isEnabled: boolean;
  63553. /** Gets or sets background color of control if it's disabled*/
  63554. disabledColor: string;
  63555. /**
  63556. * Creates a new control
  63557. * @param name defines the name of the control
  63558. */
  63559. constructor(
  63560. /** defines the name of the control */
  63561. name?: string | undefined);
  63562. /** @hidden */
  63563. protected _getTypeName(): string;
  63564. /**
  63565. * Gets the first ascendant in the hierarchy of the given type
  63566. * @param className defines the required type
  63567. * @returns the ascendant or null if not found
  63568. */
  63569. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63570. /** @hidden */
  63571. _resetFontCache(): void;
  63572. /**
  63573. * Determines if a container is an ascendant of the current control
  63574. * @param container defines the container to look for
  63575. * @returns true if the container is one of the ascendant of the control
  63576. */
  63577. isAscendant(container: Control): boolean;
  63578. /**
  63579. * Gets coordinates in local control space
  63580. * @param globalCoordinates defines the coordinates to transform
  63581. * @returns the new coordinates in local space
  63582. */
  63583. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63584. /**
  63585. * Gets coordinates in local control space
  63586. * @param globalCoordinates defines the coordinates to transform
  63587. * @param result defines the target vector2 where to store the result
  63588. * @returns the current control
  63589. */
  63590. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63591. /**
  63592. * Gets coordinates in parent local control space
  63593. * @param globalCoordinates defines the coordinates to transform
  63594. * @returns the new coordinates in parent local space
  63595. */
  63596. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63597. /**
  63598. * Move the current control to a vector3 position projected onto the screen.
  63599. * @param position defines the target position
  63600. * @param scene defines the hosting scene
  63601. */
  63602. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63603. /** @hidden */
  63604. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63605. /**
  63606. * Will return all controls that have this control as ascendant
  63607. * @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
  63608. * @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
  63609. * @return all child controls
  63610. */
  63611. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63612. /**
  63613. * Link current control with a target mesh
  63614. * @param mesh defines the mesh to link with
  63615. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63616. */
  63617. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63618. /** @hidden */
  63619. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63620. /** @hidden */
  63621. _offsetLeft(offset: number): void;
  63622. /** @hidden */
  63623. _offsetTop(offset: number): void;
  63624. /** @hidden */
  63625. _markMatrixAsDirty(): void;
  63626. /** @hidden */
  63627. _flagDescendantsAsMatrixDirty(): void;
  63628. /** @hidden */
  63629. _intersectsRect(rect: Measure): boolean;
  63630. /** @hidden */
  63631. protected invalidateRect(): void;
  63632. /** @hidden */
  63633. _markAsDirty(force?: boolean): void;
  63634. /** @hidden */
  63635. _markAllAsDirty(): void;
  63636. /** @hidden */
  63637. _link(host: AdvancedDynamicTexture): void;
  63638. /** @hidden */
  63639. protected _transform(context?: CanvasRenderingContext2D): void;
  63640. /** @hidden */
  63641. _renderHighlight(context: CanvasRenderingContext2D): void;
  63642. /** @hidden */
  63643. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63644. /** @hidden */
  63645. protected _applyStates(context: CanvasRenderingContext2D): void;
  63646. /** @hidden */
  63647. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63648. /** @hidden */
  63649. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63650. protected _evaluateClippingState(parentMeasure: Measure): void;
  63651. /** @hidden */
  63652. _measure(): void;
  63653. /** @hidden */
  63654. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63655. /** @hidden */
  63656. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63657. /** @hidden */
  63658. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63659. /** @hidden */
  63660. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63661. private static _ClipMeasure;
  63662. private _tmpMeasureA;
  63663. private _clip;
  63664. /** @hidden */
  63665. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63666. /** @hidden */
  63667. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63668. /**
  63669. * Tests if a given coordinates belong to the current control
  63670. * @param x defines x coordinate to test
  63671. * @param y defines y coordinate to test
  63672. * @returns true if the coordinates are inside the control
  63673. */
  63674. contains(x: number, y: number): boolean;
  63675. /** @hidden */
  63676. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63677. /** @hidden */
  63678. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63679. /** @hidden */
  63680. _onPointerEnter(target: Control): boolean;
  63681. /** @hidden */
  63682. _onPointerOut(target: Control, force?: boolean): void;
  63683. /** @hidden */
  63684. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63685. /** @hidden */
  63686. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63687. /** @hidden */
  63688. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63689. /** @hidden */
  63690. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63691. private _prepareFont;
  63692. /** Releases associated resources */
  63693. dispose(): void;
  63694. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63695. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63696. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63697. private static _VERTICAL_ALIGNMENT_TOP;
  63698. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63699. private static _VERTICAL_ALIGNMENT_CENTER;
  63700. /** HORIZONTAL_ALIGNMENT_LEFT */
  63701. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63702. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63703. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63704. /** HORIZONTAL_ALIGNMENT_CENTER */
  63705. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63706. /** VERTICAL_ALIGNMENT_TOP */
  63707. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63708. /** VERTICAL_ALIGNMENT_BOTTOM */
  63709. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63710. /** VERTICAL_ALIGNMENT_CENTER */
  63711. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63712. private static _FontHeightSizes;
  63713. /** @hidden */
  63714. static _GetFontOffset(font: string): {
  63715. ascent: number;
  63716. height: number;
  63717. descent: number;
  63718. };
  63719. /**
  63720. * Creates a stack panel that can be used to render headers
  63721. * @param control defines the control to associate with the header
  63722. * @param text defines the text of the header
  63723. * @param size defines the size of the header
  63724. * @param options defines options used to configure the header
  63725. * @returns a new StackPanel
  63726. * @ignore
  63727. * @hidden
  63728. */
  63729. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63730. isHorizontal: boolean;
  63731. controlFirst: boolean;
  63732. }) => any;
  63733. /** @hidden */
  63734. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63735. }
  63736. }
  63737. declare module BABYLON.GUI {
  63738. /**
  63739. * Root class for 2D containers
  63740. * @see http://doc.babylonjs.com/how_to/gui#containers
  63741. */
  63742. export class Container extends Control {
  63743. name?: string | undefined;
  63744. /** @hidden */
  63745. protected _children: Control[];
  63746. /** @hidden */
  63747. protected _measureForChildren: Measure;
  63748. /** @hidden */
  63749. protected _background: string;
  63750. /** @hidden */
  63751. protected _adaptWidthToChildren: boolean;
  63752. /** @hidden */
  63753. protected _adaptHeightToChildren: boolean;
  63754. /**
  63755. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63756. */
  63757. logLayoutCycleErrors: boolean;
  63758. /**
  63759. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63760. */
  63761. maxLayoutCycle: number;
  63762. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63763. adaptHeightToChildren: boolean;
  63764. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63765. adaptWidthToChildren: boolean;
  63766. /** Gets or sets background color */
  63767. background: string;
  63768. /** Gets the list of children */
  63769. readonly children: Control[];
  63770. /**
  63771. * Creates a new Container
  63772. * @param name defines the name of the container
  63773. */
  63774. constructor(name?: string | undefined);
  63775. protected _getTypeName(): string;
  63776. _flagDescendantsAsMatrixDirty(): void;
  63777. /**
  63778. * Gets a child using its name
  63779. * @param name defines the child name to look for
  63780. * @returns the child control if found
  63781. */
  63782. getChildByName(name: string): BABYLON.Nullable<Control>;
  63783. /**
  63784. * Gets a child using its type and its name
  63785. * @param name defines the child name to look for
  63786. * @param type defines the child type to look for
  63787. * @returns the child control if found
  63788. */
  63789. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63790. /**
  63791. * Search for a specific control in children
  63792. * @param control defines the control to look for
  63793. * @returns true if the control is in child list
  63794. */
  63795. containsControl(control: Control): boolean;
  63796. /**
  63797. * Adds a new control to the current container
  63798. * @param control defines the control to add
  63799. * @returns the current container
  63800. */
  63801. addControl(control: BABYLON.Nullable<Control>): Container;
  63802. /**
  63803. * Removes all controls from the current container
  63804. * @returns the current container
  63805. */
  63806. clearControls(): Container;
  63807. /**
  63808. * Removes a control from the current container
  63809. * @param control defines the control to remove
  63810. * @returns the current container
  63811. */
  63812. removeControl(control: Control): Container;
  63813. /** @hidden */
  63814. _reOrderControl(control: Control): void;
  63815. /** @hidden */
  63816. _offsetLeft(offset: number): void;
  63817. /** @hidden */
  63818. _offsetTop(offset: number): void;
  63819. /** @hidden */
  63820. _markAllAsDirty(): void;
  63821. /** @hidden */
  63822. protected _localDraw(context: CanvasRenderingContext2D): void;
  63823. /** @hidden */
  63824. _link(host: AdvancedDynamicTexture): void;
  63825. /** @hidden */
  63826. protected _beforeLayout(): void;
  63827. /** @hidden */
  63828. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63829. /** @hidden */
  63830. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63831. protected _postMeasure(): void;
  63832. /** @hidden */
  63833. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63834. /** @hidden */
  63835. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63836. /** @hidden */
  63837. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63838. /** @hidden */
  63839. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63840. /** Releases associated resources */
  63841. dispose(): void;
  63842. }
  63843. }
  63844. declare module BABYLON.GUI {
  63845. /** Class used to create rectangle container */
  63846. export class Rectangle extends Container {
  63847. name?: string | undefined;
  63848. private _thickness;
  63849. private _cornerRadius;
  63850. /** Gets or sets border thickness */
  63851. thickness: number;
  63852. /** Gets or sets the corner radius angle */
  63853. cornerRadius: number;
  63854. /**
  63855. * Creates a new Rectangle
  63856. * @param name defines the control name
  63857. */
  63858. constructor(name?: string | undefined);
  63859. protected _getTypeName(): string;
  63860. protected _localDraw(context: CanvasRenderingContext2D): void;
  63861. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63862. private _drawRoundedRect;
  63863. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63864. }
  63865. }
  63866. declare module BABYLON.GUI {
  63867. /**
  63868. * Enum that determines the text-wrapping mode to use.
  63869. */
  63870. export enum TextWrapping {
  63871. /**
  63872. * Clip the text when it's larger than Control.width; this is the default mode.
  63873. */
  63874. Clip = 0,
  63875. /**
  63876. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63877. */
  63878. WordWrap = 1,
  63879. /**
  63880. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63881. */
  63882. Ellipsis = 2
  63883. }
  63884. /**
  63885. * Class used to create text block control
  63886. */
  63887. export class TextBlock extends Control {
  63888. /**
  63889. * Defines the name of the control
  63890. */
  63891. name?: string | undefined;
  63892. private _text;
  63893. private _textWrapping;
  63894. private _textHorizontalAlignment;
  63895. private _textVerticalAlignment;
  63896. private _lines;
  63897. private _resizeToFit;
  63898. private _lineSpacing;
  63899. private _outlineWidth;
  63900. private _outlineColor;
  63901. /**
  63902. * An event triggered after the text is changed
  63903. */
  63904. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63905. /**
  63906. * An event triggered after the text was broken up into lines
  63907. */
  63908. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63909. /**
  63910. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63911. */
  63912. readonly lines: any[];
  63913. /**
  63914. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63915. */
  63916. /**
  63917. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63918. */
  63919. resizeToFit: boolean;
  63920. /**
  63921. * Gets or sets a boolean indicating if text must be wrapped
  63922. */
  63923. /**
  63924. * Gets or sets a boolean indicating if text must be wrapped
  63925. */
  63926. textWrapping: TextWrapping | boolean;
  63927. /**
  63928. * Gets or sets text to display
  63929. */
  63930. /**
  63931. * Gets or sets text to display
  63932. */
  63933. text: string;
  63934. /**
  63935. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63936. */
  63937. /**
  63938. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63939. */
  63940. textHorizontalAlignment: number;
  63941. /**
  63942. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63943. */
  63944. /**
  63945. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63946. */
  63947. textVerticalAlignment: number;
  63948. /**
  63949. * Gets or sets line spacing value
  63950. */
  63951. /**
  63952. * Gets or sets line spacing value
  63953. */
  63954. lineSpacing: string | number;
  63955. /**
  63956. * Gets or sets outlineWidth of the text to display
  63957. */
  63958. /**
  63959. * Gets or sets outlineWidth of the text to display
  63960. */
  63961. outlineWidth: number;
  63962. /**
  63963. * Gets or sets outlineColor of the text to display
  63964. */
  63965. /**
  63966. * Gets or sets outlineColor of the text to display
  63967. */
  63968. outlineColor: string;
  63969. /**
  63970. * Creates a new TextBlock object
  63971. * @param name defines the name of the control
  63972. * @param text defines the text to display (emptry string by default)
  63973. */
  63974. constructor(
  63975. /**
  63976. * Defines the name of the control
  63977. */
  63978. name?: string | undefined, text?: string);
  63979. protected _getTypeName(): string;
  63980. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63981. private _drawText;
  63982. /** @hidden */
  63983. _draw(context: CanvasRenderingContext2D): void;
  63984. protected _applyStates(context: CanvasRenderingContext2D): void;
  63985. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63986. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63987. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63988. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63989. protected _renderLines(context: CanvasRenderingContext2D): void;
  63990. /**
  63991. * Given a width constraint applied on the text block, find the expected height
  63992. * @returns expected height
  63993. */
  63994. computeExpectedHeight(): number;
  63995. dispose(): void;
  63996. }
  63997. }
  63998. declare module BABYLON.GUI {
  63999. /**
  64000. * Class used to create 2D images
  64001. */
  64002. export class Image extends Control {
  64003. name?: string | undefined;
  64004. private static _WorkingCanvas;
  64005. private _domImage;
  64006. private _imageWidth;
  64007. private _imageHeight;
  64008. private _loaded;
  64009. private _stretch;
  64010. private _source;
  64011. private _autoScale;
  64012. private _sourceLeft;
  64013. private _sourceTop;
  64014. private _sourceWidth;
  64015. private _sourceHeight;
  64016. private _cellWidth;
  64017. private _cellHeight;
  64018. private _cellId;
  64019. private _populateNinePatchSlicesFromImage;
  64020. private _sliceLeft;
  64021. private _sliceRight;
  64022. private _sliceTop;
  64023. private _sliceBottom;
  64024. private _detectPointerOnOpaqueOnly;
  64025. /**
  64026. * BABYLON.Observable notified when the content is loaded
  64027. */
  64028. onImageLoadedObservable: BABYLON.Observable<Image>;
  64029. /**
  64030. * Gets a boolean indicating that the content is loaded
  64031. */
  64032. readonly isLoaded: boolean;
  64033. /**
  64034. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64035. */
  64036. populateNinePatchSlicesFromImage: boolean;
  64037. /**
  64038. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64039. * Beware using this as this will comsume more memory as the image has to be stored twice
  64040. */
  64041. detectPointerOnOpaqueOnly: boolean;
  64042. /**
  64043. * Gets or sets the left value for slicing (9-patch)
  64044. */
  64045. sliceLeft: number;
  64046. /**
  64047. * Gets or sets the right value for slicing (9-patch)
  64048. */
  64049. sliceRight: number;
  64050. /**
  64051. * Gets or sets the top value for slicing (9-patch)
  64052. */
  64053. sliceTop: number;
  64054. /**
  64055. * Gets or sets the bottom value for slicing (9-patch)
  64056. */
  64057. sliceBottom: number;
  64058. /**
  64059. * Gets or sets the left coordinate in the source image
  64060. */
  64061. sourceLeft: number;
  64062. /**
  64063. * Gets or sets the top coordinate in the source image
  64064. */
  64065. sourceTop: number;
  64066. /**
  64067. * Gets or sets the width to capture in the source image
  64068. */
  64069. sourceWidth: number;
  64070. /**
  64071. * Gets or sets the height to capture in the source image
  64072. */
  64073. sourceHeight: number;
  64074. /**
  64075. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64076. * @see http://doc.babylonjs.com/how_to/gui#image
  64077. */
  64078. autoScale: boolean;
  64079. /** Gets or sets the streching mode used by the image */
  64080. stretch: number;
  64081. /**
  64082. * Gets or sets the internal DOM image used to render the control
  64083. */
  64084. domImage: HTMLImageElement;
  64085. private _onImageLoaded;
  64086. private _extractNinePatchSliceDataFromImage;
  64087. /**
  64088. * Gets or sets image source url
  64089. */
  64090. source: BABYLON.Nullable<string>;
  64091. /**
  64092. * Gets or sets the cell width to use when animation sheet is enabled
  64093. * @see http://doc.babylonjs.com/how_to/gui#image
  64094. */
  64095. cellWidth: number;
  64096. /**
  64097. * Gets or sets the cell height to use when animation sheet is enabled
  64098. * @see http://doc.babylonjs.com/how_to/gui#image
  64099. */
  64100. cellHeight: number;
  64101. /**
  64102. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64103. * @see http://doc.babylonjs.com/how_to/gui#image
  64104. */
  64105. cellId: number;
  64106. /**
  64107. * Creates a new Image
  64108. * @param name defines the control name
  64109. * @param url defines the image url
  64110. */
  64111. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64112. /**
  64113. * Tests if a given coordinates belong to the current control
  64114. * @param x defines x coordinate to test
  64115. * @param y defines y coordinate to test
  64116. * @returns true if the coordinates are inside the control
  64117. */
  64118. contains(x: number, y: number): boolean;
  64119. protected _getTypeName(): string;
  64120. /** Force the control to synchronize with its content */
  64121. synchronizeSizeWithContent(): void;
  64122. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64123. private _prepareWorkingCanvasForOpaqueDetection;
  64124. private _drawImage;
  64125. _draw(context: CanvasRenderingContext2D): void;
  64126. private _renderCornerPatch;
  64127. private _renderNinePatch;
  64128. dispose(): void;
  64129. /** STRETCH_NONE */
  64130. static readonly STRETCH_NONE: number;
  64131. /** STRETCH_FILL */
  64132. static readonly STRETCH_FILL: number;
  64133. /** STRETCH_UNIFORM */
  64134. static readonly STRETCH_UNIFORM: number;
  64135. /** STRETCH_EXTEND */
  64136. static readonly STRETCH_EXTEND: number;
  64137. /** NINE_PATCH */
  64138. static readonly STRETCH_NINE_PATCH: number;
  64139. }
  64140. }
  64141. declare module BABYLON.GUI {
  64142. /**
  64143. * Class used to create 2D buttons
  64144. */
  64145. export class Button extends Rectangle {
  64146. name?: string | undefined;
  64147. /**
  64148. * Function called to generate a pointer enter animation
  64149. */
  64150. pointerEnterAnimation: () => void;
  64151. /**
  64152. * Function called to generate a pointer out animation
  64153. */
  64154. pointerOutAnimation: () => void;
  64155. /**
  64156. * Function called to generate a pointer down animation
  64157. */
  64158. pointerDownAnimation: () => void;
  64159. /**
  64160. * Function called to generate a pointer up animation
  64161. */
  64162. pointerUpAnimation: () => void;
  64163. /**
  64164. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64165. */
  64166. delegatePickingToChildren: boolean;
  64167. private _image;
  64168. /**
  64169. * Returns the image part of the button (if any)
  64170. */
  64171. readonly image: BABYLON.Nullable<Image>;
  64172. private _textBlock;
  64173. /**
  64174. * Returns the image part of the button (if any)
  64175. */
  64176. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64177. /**
  64178. * Creates a new Button
  64179. * @param name defines the name of the button
  64180. */
  64181. constructor(name?: string | undefined);
  64182. protected _getTypeName(): string;
  64183. /** @hidden */
  64184. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64185. /** @hidden */
  64186. _onPointerEnter(target: Control): boolean;
  64187. /** @hidden */
  64188. _onPointerOut(target: Control, force?: boolean): void;
  64189. /** @hidden */
  64190. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64191. /** @hidden */
  64192. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64193. /**
  64194. * Creates a new button made with an image and a text
  64195. * @param name defines the name of the button
  64196. * @param text defines the text of the button
  64197. * @param imageUrl defines the url of the image
  64198. * @returns a new Button
  64199. */
  64200. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64201. /**
  64202. * Creates a new button made with an image
  64203. * @param name defines the name of the button
  64204. * @param imageUrl defines the url of the image
  64205. * @returns a new Button
  64206. */
  64207. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64208. /**
  64209. * Creates a new button made with a text
  64210. * @param name defines the name of the button
  64211. * @param text defines the text of the button
  64212. * @returns a new Button
  64213. */
  64214. static CreateSimpleButton(name: string, text: string): Button;
  64215. /**
  64216. * Creates a new button made with an image and a centered text
  64217. * @param name defines the name of the button
  64218. * @param text defines the text of the button
  64219. * @param imageUrl defines the url of the image
  64220. * @returns a new Button
  64221. */
  64222. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64223. }
  64224. }
  64225. declare module BABYLON.GUI {
  64226. /**
  64227. * Class used to create a 2D stack panel container
  64228. */
  64229. export class StackPanel extends Container {
  64230. name?: string | undefined;
  64231. private _isVertical;
  64232. private _manualWidth;
  64233. private _manualHeight;
  64234. private _doNotTrackManualChanges;
  64235. /**
  64236. * Gets or sets a boolean indicating that layou warnings should be ignored
  64237. */
  64238. ignoreLayoutWarnings: boolean;
  64239. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64240. isVertical: boolean;
  64241. /**
  64242. * Gets or sets panel width.
  64243. * This value should not be set when in horizontal mode as it will be computed automatically
  64244. */
  64245. width: string | number;
  64246. /**
  64247. * Gets or sets panel height.
  64248. * This value should not be set when in vertical mode as it will be computed automatically
  64249. */
  64250. height: string | number;
  64251. /**
  64252. * Creates a new StackPanel
  64253. * @param name defines control name
  64254. */
  64255. constructor(name?: string | undefined);
  64256. protected _getTypeName(): string;
  64257. /** @hidden */
  64258. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64259. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64260. protected _postMeasure(): void;
  64261. }
  64262. }
  64263. declare module BABYLON.GUI {
  64264. /**
  64265. * Class used to represent a 2D checkbox
  64266. */
  64267. export class Checkbox extends Control {
  64268. name?: string | undefined;
  64269. private _isChecked;
  64270. private _background;
  64271. private _checkSizeRatio;
  64272. private _thickness;
  64273. /** Gets or sets border thickness */
  64274. thickness: number;
  64275. /**
  64276. * BABYLON.Observable raised when isChecked property changes
  64277. */
  64278. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64279. /** Gets or sets a value indicating the ratio between overall size and check size */
  64280. checkSizeRatio: number;
  64281. /** Gets or sets background color */
  64282. background: string;
  64283. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64284. isChecked: boolean;
  64285. /**
  64286. * Creates a new CheckBox
  64287. * @param name defines the control name
  64288. */
  64289. constructor(name?: string | undefined);
  64290. protected _getTypeName(): string;
  64291. /** @hidden */
  64292. _draw(context: CanvasRenderingContext2D): void;
  64293. /** @hidden */
  64294. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64295. /**
  64296. * Utility function to easily create a checkbox with a header
  64297. * @param title defines the label to use for the header
  64298. * @param onValueChanged defines the callback to call when value changes
  64299. * @returns a StackPanel containing the checkbox and a textBlock
  64300. */
  64301. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64302. }
  64303. }
  64304. declare module BABYLON.GUI {
  64305. /**
  64306. * Class used to store key control properties
  64307. */
  64308. export class KeyPropertySet {
  64309. /** Width */
  64310. width?: string;
  64311. /** Height */
  64312. height?: string;
  64313. /** Left padding */
  64314. paddingLeft?: string;
  64315. /** Right padding */
  64316. paddingRight?: string;
  64317. /** Top padding */
  64318. paddingTop?: string;
  64319. /** Bottom padding */
  64320. paddingBottom?: string;
  64321. /** Foreground color */
  64322. color?: string;
  64323. /** Background color */
  64324. background?: string;
  64325. }
  64326. /**
  64327. * Class used to create virtual keyboard
  64328. */
  64329. export class VirtualKeyboard extends StackPanel {
  64330. /** BABYLON.Observable raised when a key is pressed */
  64331. onKeyPressObservable: BABYLON.Observable<string>;
  64332. /** Gets or sets default key button width */
  64333. defaultButtonWidth: string;
  64334. /** Gets or sets default key button height */
  64335. defaultButtonHeight: string;
  64336. /** Gets or sets default key button left padding */
  64337. defaultButtonPaddingLeft: string;
  64338. /** Gets or sets default key button right padding */
  64339. defaultButtonPaddingRight: string;
  64340. /** Gets or sets default key button top padding */
  64341. defaultButtonPaddingTop: string;
  64342. /** Gets or sets default key button bottom padding */
  64343. defaultButtonPaddingBottom: string;
  64344. /** Gets or sets default key button foreground color */
  64345. defaultButtonColor: string;
  64346. /** Gets or sets default key button background color */
  64347. defaultButtonBackground: string;
  64348. /** Gets or sets shift button foreground color */
  64349. shiftButtonColor: string;
  64350. /** Gets or sets shift button thickness*/
  64351. selectedShiftThickness: number;
  64352. /** Gets shift key state */
  64353. shiftState: number;
  64354. protected _getTypeName(): string;
  64355. private _createKey;
  64356. /**
  64357. * Adds a new row of keys
  64358. * @param keys defines the list of keys to add
  64359. * @param propertySets defines the associated property sets
  64360. */
  64361. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64362. /**
  64363. * Set the shift key to a specific state
  64364. * @param shiftState defines the new shift state
  64365. */
  64366. applyShiftState(shiftState: number): void;
  64367. private _currentlyConnectedInputText;
  64368. private _connectedInputTexts;
  64369. private _onKeyPressObserver;
  64370. /** Gets the input text control currently attached to the keyboard */
  64371. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64372. /**
  64373. * Connects the keyboard with an input text control
  64374. *
  64375. * @param input defines the target control
  64376. */
  64377. connect(input: InputText): void;
  64378. /**
  64379. * Disconnects the keyboard from connected InputText controls
  64380. *
  64381. * @param input optionally defines a target control, otherwise all are disconnected
  64382. */
  64383. disconnect(input?: InputText): void;
  64384. private _removeConnectedInputObservables;
  64385. /**
  64386. * Release all resources
  64387. */
  64388. dispose(): void;
  64389. /**
  64390. * Creates a new keyboard using a default layout
  64391. *
  64392. * @param name defines control name
  64393. * @returns a new VirtualKeyboard
  64394. */
  64395. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64396. }
  64397. }
  64398. declare module BABYLON.GUI {
  64399. /**
  64400. * Class used to create input text control
  64401. */
  64402. export class InputText extends Control implements IFocusableControl {
  64403. name?: string | undefined;
  64404. private _text;
  64405. private _placeholderText;
  64406. private _background;
  64407. private _focusedBackground;
  64408. private _focusedColor;
  64409. private _placeholderColor;
  64410. private _thickness;
  64411. private _margin;
  64412. private _autoStretchWidth;
  64413. private _maxWidth;
  64414. private _isFocused;
  64415. private _blinkTimeout;
  64416. private _blinkIsEven;
  64417. private _cursorOffset;
  64418. private _scrollLeft;
  64419. private _textWidth;
  64420. private _clickedCoordinate;
  64421. private _deadKey;
  64422. private _addKey;
  64423. private _currentKey;
  64424. private _isTextHighlightOn;
  64425. private _textHighlightColor;
  64426. private _highligherOpacity;
  64427. private _highlightedText;
  64428. private _startHighlightIndex;
  64429. private _endHighlightIndex;
  64430. private _cursorIndex;
  64431. private _onFocusSelectAll;
  64432. private _isPointerDown;
  64433. private _onClipboardObserver;
  64434. private _onPointerDblTapObserver;
  64435. /** @hidden */
  64436. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64437. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64438. promptMessage: string;
  64439. /** Force disable prompt on mobile device */
  64440. disableMobilePrompt: boolean;
  64441. /** BABYLON.Observable raised when the text changes */
  64442. onTextChangedObservable: BABYLON.Observable<InputText>;
  64443. /** BABYLON.Observable raised just before an entered character is to be added */
  64444. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64445. /** BABYLON.Observable raised when the control gets the focus */
  64446. onFocusObservable: BABYLON.Observable<InputText>;
  64447. /** BABYLON.Observable raised when the control loses the focus */
  64448. onBlurObservable: BABYLON.Observable<InputText>;
  64449. /**Observable raised when the text is highlighted */
  64450. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64451. /**Observable raised when copy event is triggered */
  64452. onTextCopyObservable: BABYLON.Observable<InputText>;
  64453. /** BABYLON.Observable raised when cut event is triggered */
  64454. onTextCutObservable: BABYLON.Observable<InputText>;
  64455. /** BABYLON.Observable raised when paste event is triggered */
  64456. onTextPasteObservable: BABYLON.Observable<InputText>;
  64457. /** BABYLON.Observable raised when a key event was processed */
  64458. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64459. /** Gets or sets the maximum width allowed by the control */
  64460. maxWidth: string | number;
  64461. /** Gets the maximum width allowed by the control in pixels */
  64462. readonly maxWidthInPixels: number;
  64463. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64464. highligherOpacity: number;
  64465. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64466. onFocusSelectAll: boolean;
  64467. /** Gets or sets the text hightlight color */
  64468. textHighlightColor: string;
  64469. /** Gets or sets control margin */
  64470. margin: string;
  64471. /** Gets control margin in pixels */
  64472. readonly marginInPixels: number;
  64473. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64474. autoStretchWidth: boolean;
  64475. /** Gets or sets border thickness */
  64476. thickness: number;
  64477. /** Gets or sets the background color when focused */
  64478. focusedBackground: string;
  64479. /** Gets or sets the background color when focused */
  64480. focusedColor: string;
  64481. /** Gets or sets the background color */
  64482. background: string;
  64483. /** Gets or sets the placeholder color */
  64484. placeholderColor: string;
  64485. /** Gets or sets the text displayed when the control is empty */
  64486. placeholderText: string;
  64487. /** Gets or sets the dead key flag */
  64488. deadKey: boolean;
  64489. /** Gets or sets the highlight text */
  64490. highlightedText: string;
  64491. /** Gets or sets if the current key should be added */
  64492. addKey: boolean;
  64493. /** Gets or sets the value of the current key being entered */
  64494. currentKey: string;
  64495. /** Gets or sets the text displayed in the control */
  64496. text: string;
  64497. /** Gets or sets control width */
  64498. width: string | number;
  64499. /**
  64500. * Creates a new InputText
  64501. * @param name defines the control name
  64502. * @param text defines the text of the control
  64503. */
  64504. constructor(name?: string | undefined, text?: string);
  64505. /** @hidden */
  64506. onBlur(): void;
  64507. /** @hidden */
  64508. onFocus(): void;
  64509. protected _getTypeName(): string;
  64510. /**
  64511. * Function called to get the list of controls that should not steal the focus from this control
  64512. * @returns an array of controls
  64513. */
  64514. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64515. /** @hidden */
  64516. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64517. /** @hidden */
  64518. private _updateValueFromCursorIndex;
  64519. /** @hidden */
  64520. private _processDblClick;
  64521. /** @hidden */
  64522. private _selectAllText;
  64523. /**
  64524. * Handles the keyboard event
  64525. * @param evt Defines the KeyboardEvent
  64526. */
  64527. processKeyboard(evt: KeyboardEvent): void;
  64528. /** @hidden */
  64529. private _onCopyText;
  64530. /** @hidden */
  64531. private _onCutText;
  64532. /** @hidden */
  64533. private _onPasteText;
  64534. _draw(context: CanvasRenderingContext2D): void;
  64535. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64536. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64537. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64538. protected _beforeRenderText(text: string): string;
  64539. dispose(): void;
  64540. }
  64541. }
  64542. declare module BABYLON.GUI {
  64543. /**
  64544. * Class used to create a 2D grid container
  64545. */
  64546. export class Grid extends Container {
  64547. name?: string | undefined;
  64548. private _rowDefinitions;
  64549. private _columnDefinitions;
  64550. private _cells;
  64551. private _childControls;
  64552. /**
  64553. * Gets the number of columns
  64554. */
  64555. readonly columnCount: number;
  64556. /**
  64557. * Gets the number of rows
  64558. */
  64559. readonly rowCount: number;
  64560. /** Gets the list of children */
  64561. readonly children: Control[];
  64562. /** Gets the list of cells (e.g. the containers) */
  64563. readonly cells: {
  64564. [key: string]: Container;
  64565. };
  64566. /**
  64567. * Gets the definition of a specific row
  64568. * @param index defines the index of the row
  64569. * @returns the row definition
  64570. */
  64571. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64572. /**
  64573. * Gets the definition of a specific column
  64574. * @param index defines the index of the column
  64575. * @returns the column definition
  64576. */
  64577. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64578. /**
  64579. * Adds a new row to the grid
  64580. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64581. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64582. * @returns the current grid
  64583. */
  64584. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64585. /**
  64586. * Adds a new column to the grid
  64587. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64588. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64589. * @returns the current grid
  64590. */
  64591. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64592. /**
  64593. * Update a row definition
  64594. * @param index defines the index of the row to update
  64595. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64596. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64597. * @returns the current grid
  64598. */
  64599. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64600. /**
  64601. * Update a column definition
  64602. * @param index defines the index of the column to update
  64603. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64604. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64605. * @returns the current grid
  64606. */
  64607. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64608. /**
  64609. * Gets the list of children stored in a specific cell
  64610. * @param row defines the row to check
  64611. * @param column defines the column to check
  64612. * @returns the list of controls
  64613. */
  64614. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64615. /**
  64616. * Gets a string representing the child cell info (row x column)
  64617. * @param child defines the control to get info from
  64618. * @returns a string containing the child cell info (row x column)
  64619. */
  64620. getChildCellInfo(child: Control): string;
  64621. private _removeCell;
  64622. private _offsetCell;
  64623. /**
  64624. * Remove a column definition at specified index
  64625. * @param index defines the index of the column to remove
  64626. * @returns the current grid
  64627. */
  64628. removeColumnDefinition(index: number): Grid;
  64629. /**
  64630. * Remove a row definition at specified index
  64631. * @param index defines the index of the row to remove
  64632. * @returns the current grid
  64633. */
  64634. removeRowDefinition(index: number): Grid;
  64635. /**
  64636. * Adds a new control to the current grid
  64637. * @param control defines the control to add
  64638. * @param row defines the row where to add the control (0 by default)
  64639. * @param column defines the column where to add the control (0 by default)
  64640. * @returns the current grid
  64641. */
  64642. addControl(control: Control, row?: number, column?: number): Grid;
  64643. /**
  64644. * Removes a control from the current container
  64645. * @param control defines the control to remove
  64646. * @returns the current container
  64647. */
  64648. removeControl(control: Control): Container;
  64649. /**
  64650. * Creates a new Grid
  64651. * @param name defines control name
  64652. */
  64653. constructor(name?: string | undefined);
  64654. protected _getTypeName(): string;
  64655. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64656. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64657. _flagDescendantsAsMatrixDirty(): void;
  64658. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64659. /** Releases associated resources */
  64660. dispose(): void;
  64661. }
  64662. }
  64663. declare module BABYLON.GUI {
  64664. /** Class used to create color pickers */
  64665. export class ColorPicker extends Control {
  64666. name?: string | undefined;
  64667. private static _Epsilon;
  64668. private _colorWheelCanvas;
  64669. private _value;
  64670. private _tmpColor;
  64671. private _pointerStartedOnSquare;
  64672. private _pointerStartedOnWheel;
  64673. private _squareLeft;
  64674. private _squareTop;
  64675. private _squareSize;
  64676. private _h;
  64677. private _s;
  64678. private _v;
  64679. private _lastPointerDownID;
  64680. /**
  64681. * BABYLON.Observable raised when the value changes
  64682. */
  64683. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64684. /** Gets or sets the color of the color picker */
  64685. value: BABYLON.Color3;
  64686. /**
  64687. * Gets or sets control width
  64688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64689. */
  64690. width: string | number;
  64691. /**
  64692. * Gets or sets control height
  64693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64694. */
  64695. /** Gets or sets control height */
  64696. height: string | number;
  64697. /** Gets or sets control size */
  64698. size: string | number;
  64699. /**
  64700. * Creates a new ColorPicker
  64701. * @param name defines the control name
  64702. */
  64703. constructor(name?: string | undefined);
  64704. protected _getTypeName(): string;
  64705. /** @hidden */
  64706. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64707. private _updateSquareProps;
  64708. private _drawGradientSquare;
  64709. private _drawCircle;
  64710. private _createColorWheelCanvas;
  64711. /** @hidden */
  64712. _draw(context: CanvasRenderingContext2D): void;
  64713. private _pointerIsDown;
  64714. private _updateValueFromPointer;
  64715. private _isPointOnSquare;
  64716. private _isPointOnWheel;
  64717. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64718. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64719. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64720. /**
  64721. * This function expands the color picker by creating a color picker dialog with manual
  64722. * color value input and the ability to save colors into an array to be used later in
  64723. * subsequent launches of the dialogue.
  64724. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64725. * @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.
  64726. * @returns picked color as a hex string and the saved colors array as hex strings.
  64727. */
  64728. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64729. pickerWidth?: string;
  64730. pickerHeight?: string;
  64731. headerHeight?: string;
  64732. lastColor?: string;
  64733. swatchLimit?: number;
  64734. numSwatchesPerLine?: number;
  64735. savedColors?: Array<string>;
  64736. }): Promise<{
  64737. savedColors?: string[];
  64738. pickedColor: string;
  64739. }>;
  64740. }
  64741. }
  64742. declare module BABYLON.GUI {
  64743. /** Class used to create 2D ellipse containers */
  64744. export class Ellipse extends Container {
  64745. name?: string | undefined;
  64746. private _thickness;
  64747. /** Gets or sets border thickness */
  64748. thickness: number;
  64749. /**
  64750. * Creates a new Ellipse
  64751. * @param name defines the control name
  64752. */
  64753. constructor(name?: string | undefined);
  64754. protected _getTypeName(): string;
  64755. protected _localDraw(context: CanvasRenderingContext2D): void;
  64756. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64757. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64758. }
  64759. }
  64760. declare module BABYLON.GUI {
  64761. /**
  64762. * Class used to create a password control
  64763. */
  64764. export class InputPassword extends InputText {
  64765. protected _beforeRenderText(text: string): string;
  64766. }
  64767. }
  64768. declare module BABYLON.GUI {
  64769. /** Class used to render 2D lines */
  64770. export class Line extends Control {
  64771. name?: string | undefined;
  64772. private _lineWidth;
  64773. private _x1;
  64774. private _y1;
  64775. private _x2;
  64776. private _y2;
  64777. private _dash;
  64778. private _connectedControl;
  64779. private _connectedControlDirtyObserver;
  64780. /** Gets or sets the dash pattern */
  64781. dash: Array<number>;
  64782. /** Gets or sets the control connected with the line end */
  64783. connectedControl: Control;
  64784. /** Gets or sets start coordinates on X axis */
  64785. x1: string | number;
  64786. /** Gets or sets start coordinates on Y axis */
  64787. y1: string | number;
  64788. /** Gets or sets end coordinates on X axis */
  64789. x2: string | number;
  64790. /** Gets or sets end coordinates on Y axis */
  64791. y2: string | number;
  64792. /** Gets or sets line width */
  64793. lineWidth: number;
  64794. /** Gets or sets horizontal alignment */
  64795. horizontalAlignment: number;
  64796. /** Gets or sets vertical alignment */
  64797. verticalAlignment: number;
  64798. private readonly _effectiveX2;
  64799. private readonly _effectiveY2;
  64800. /**
  64801. * Creates a new Line
  64802. * @param name defines the control name
  64803. */
  64804. constructor(name?: string | undefined);
  64805. protected _getTypeName(): string;
  64806. _draw(context: CanvasRenderingContext2D): void;
  64807. _measure(): void;
  64808. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64809. /**
  64810. * Move one end of the line given 3D cartesian coordinates.
  64811. * @param position Targeted world position
  64812. * @param scene BABYLON.Scene
  64813. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64814. */
  64815. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64816. /**
  64817. * Move one end of the line to a position in screen absolute space.
  64818. * @param projectedPosition Position in screen absolute space (X, Y)
  64819. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64820. */
  64821. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64822. }
  64823. }
  64824. declare module BABYLON.GUI {
  64825. /**
  64826. * Class used to store a point for a MultiLine object.
  64827. * The point can be pure 2D coordinates, a mesh or a control
  64828. */
  64829. export class MultiLinePoint {
  64830. private _multiLine;
  64831. private _x;
  64832. private _y;
  64833. private _control;
  64834. private _mesh;
  64835. private _controlObserver;
  64836. private _meshObserver;
  64837. /** @hidden */
  64838. _point: BABYLON.Vector2;
  64839. /**
  64840. * Creates a new MultiLinePoint
  64841. * @param multiLine defines the source MultiLine object
  64842. */
  64843. constructor(multiLine: MultiLine);
  64844. /** Gets or sets x coordinate */
  64845. x: string | number;
  64846. /** Gets or sets y coordinate */
  64847. y: string | number;
  64848. /** Gets or sets the control associated with this point */
  64849. control: BABYLON.Nullable<Control>;
  64850. /** Gets or sets the mesh associated with this point */
  64851. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64852. /** Resets links */
  64853. resetLinks(): void;
  64854. /**
  64855. * Gets a translation vector
  64856. * @returns the translation vector
  64857. */
  64858. translate(): BABYLON.Vector2;
  64859. private _translatePoint;
  64860. /** Release associated resources */
  64861. dispose(): void;
  64862. }
  64863. }
  64864. declare module BABYLON.GUI {
  64865. /**
  64866. * Class used to create multi line control
  64867. */
  64868. export class MultiLine extends Control {
  64869. name?: string | undefined;
  64870. private _lineWidth;
  64871. private _dash;
  64872. private _points;
  64873. private _minX;
  64874. private _minY;
  64875. private _maxX;
  64876. private _maxY;
  64877. /**
  64878. * Creates a new MultiLine
  64879. * @param name defines the control name
  64880. */
  64881. constructor(name?: string | undefined);
  64882. /** Gets or sets dash pattern */
  64883. dash: Array<number>;
  64884. /**
  64885. * Gets point stored at specified index
  64886. * @param index defines the index to look for
  64887. * @returns the requested point if found
  64888. */
  64889. getAt(index: number): MultiLinePoint;
  64890. /** Function called when a point is updated */
  64891. onPointUpdate: () => void;
  64892. /**
  64893. * Adds new points to the point collection
  64894. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64895. * @returns the list of created MultiLinePoint
  64896. */
  64897. add(...items: (AbstractMesh | Control | {
  64898. x: string | number;
  64899. y: string | number;
  64900. })[]): MultiLinePoint[];
  64901. /**
  64902. * Adds a new point to the point collection
  64903. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64904. * @returns the created MultiLinePoint
  64905. */
  64906. push(item?: (AbstractMesh | Control | {
  64907. x: string | number;
  64908. y: string | number;
  64909. })): MultiLinePoint;
  64910. /**
  64911. * Remove a specific value or point from the active point collection
  64912. * @param value defines the value or point to remove
  64913. */
  64914. remove(value: number | MultiLinePoint): void;
  64915. /**
  64916. * Resets this object to initial state (no point)
  64917. */
  64918. reset(): void;
  64919. /**
  64920. * Resets all links
  64921. */
  64922. resetLinks(): void;
  64923. /** Gets or sets line width */
  64924. lineWidth: number;
  64925. horizontalAlignment: number;
  64926. verticalAlignment: number;
  64927. protected _getTypeName(): string;
  64928. _draw(context: CanvasRenderingContext2D): void;
  64929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64930. _measure(): void;
  64931. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64932. dispose(): void;
  64933. }
  64934. }
  64935. declare module BABYLON.GUI {
  64936. /**
  64937. * Class used to create radio button controls
  64938. */
  64939. export class RadioButton extends Control {
  64940. name?: string | undefined;
  64941. private _isChecked;
  64942. private _background;
  64943. private _checkSizeRatio;
  64944. private _thickness;
  64945. /** Gets or sets border thickness */
  64946. thickness: number;
  64947. /** Gets or sets group name */
  64948. group: string;
  64949. /** BABYLON.Observable raised when isChecked is changed */
  64950. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64951. /** Gets or sets a value indicating the ratio between overall size and check size */
  64952. checkSizeRatio: number;
  64953. /** Gets or sets background color */
  64954. background: string;
  64955. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64956. isChecked: boolean;
  64957. /**
  64958. * Creates a new RadioButton
  64959. * @param name defines the control name
  64960. */
  64961. constructor(name?: string | undefined);
  64962. protected _getTypeName(): string;
  64963. _draw(context: CanvasRenderingContext2D): void;
  64964. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64965. /**
  64966. * Utility function to easily create a radio button with a header
  64967. * @param title defines the label to use for the header
  64968. * @param group defines the group to use for the radio button
  64969. * @param isChecked defines the initial state of the radio button
  64970. * @param onValueChanged defines the callback to call when value changes
  64971. * @returns a StackPanel containing the radio button and a textBlock
  64972. */
  64973. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64974. }
  64975. }
  64976. declare module BABYLON.GUI {
  64977. /**
  64978. * Class used to create slider controls
  64979. */
  64980. export class BaseSlider extends Control {
  64981. name?: string | undefined;
  64982. protected _thumbWidth: ValueAndUnit;
  64983. private _minimum;
  64984. private _maximum;
  64985. private _value;
  64986. private _isVertical;
  64987. protected _barOffset: ValueAndUnit;
  64988. private _isThumbClamped;
  64989. protected _displayThumb: boolean;
  64990. private _step;
  64991. private _lastPointerDownID;
  64992. protected _effectiveBarOffset: number;
  64993. protected _renderLeft: number;
  64994. protected _renderTop: number;
  64995. protected _renderWidth: number;
  64996. protected _renderHeight: number;
  64997. protected _backgroundBoxLength: number;
  64998. protected _backgroundBoxThickness: number;
  64999. protected _effectiveThumbThickness: number;
  65000. /** BABYLON.Observable raised when the sldier value changes */
  65001. onValueChangedObservable: BABYLON.Observable<number>;
  65002. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65003. displayThumb: boolean;
  65004. /** Gets or sets a step to apply to values (0 by default) */
  65005. step: number;
  65006. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65007. barOffset: string | number;
  65008. /** Gets main bar offset in pixels*/
  65009. readonly barOffsetInPixels: number;
  65010. /** Gets or sets thumb width */
  65011. thumbWidth: string | number;
  65012. /** Gets thumb width in pixels */
  65013. readonly thumbWidthInPixels: number;
  65014. /** Gets or sets minimum value */
  65015. minimum: number;
  65016. /** Gets or sets maximum value */
  65017. maximum: number;
  65018. /** Gets or sets current value */
  65019. value: number;
  65020. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65021. isVertical: boolean;
  65022. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65023. isThumbClamped: boolean;
  65024. /**
  65025. * Creates a new BaseSlider
  65026. * @param name defines the control name
  65027. */
  65028. constructor(name?: string | undefined);
  65029. protected _getTypeName(): string;
  65030. protected _getThumbPosition(): number;
  65031. protected _getThumbThickness(type: string): number;
  65032. protected _prepareRenderingData(type: string): void;
  65033. private _pointerIsDown;
  65034. /** @hidden */
  65035. protected _updateValueFromPointer(x: number, y: number): void;
  65036. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65037. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65038. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65039. }
  65040. }
  65041. declare module BABYLON.GUI {
  65042. /**
  65043. * Class used to create slider controls
  65044. */
  65045. export class Slider extends BaseSlider {
  65046. name?: string | undefined;
  65047. private _background;
  65048. private _borderColor;
  65049. private _isThumbCircle;
  65050. protected _displayValueBar: boolean;
  65051. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65052. displayValueBar: boolean;
  65053. /** Gets or sets border color */
  65054. borderColor: string;
  65055. /** Gets or sets background color */
  65056. background: string;
  65057. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65058. isThumbCircle: boolean;
  65059. /**
  65060. * Creates a new Slider
  65061. * @param name defines the control name
  65062. */
  65063. constructor(name?: string | undefined);
  65064. protected _getTypeName(): string;
  65065. _draw(context: CanvasRenderingContext2D): void;
  65066. }
  65067. }
  65068. declare module BABYLON.GUI {
  65069. /** Class used to create a RadioGroup
  65070. * which contains groups of radio buttons
  65071. */
  65072. export class SelectorGroup {
  65073. /** name of SelectorGroup */
  65074. name: string;
  65075. private _groupPanel;
  65076. private _selectors;
  65077. private _groupHeader;
  65078. /**
  65079. * Creates a new SelectorGroup
  65080. * @param name of group, used as a group heading
  65081. */
  65082. constructor(
  65083. /** name of SelectorGroup */
  65084. name: string);
  65085. /** Gets the groupPanel of the SelectorGroup */
  65086. readonly groupPanel: StackPanel;
  65087. /** Gets the selectors array */
  65088. readonly selectors: StackPanel[];
  65089. /** Gets and sets the group header */
  65090. header: string;
  65091. /** @hidden */
  65092. private _addGroupHeader;
  65093. /** @hidden*/
  65094. _getSelector(selectorNb: number): StackPanel | undefined;
  65095. /** Removes the selector at the given position
  65096. * @param selectorNb the position of the selector within the group
  65097. */
  65098. removeSelector(selectorNb: number): void;
  65099. }
  65100. /** Class used to create a CheckboxGroup
  65101. * which contains groups of checkbox buttons
  65102. */
  65103. export class CheckboxGroup extends SelectorGroup {
  65104. /** Adds a checkbox as a control
  65105. * @param text is the label for the selector
  65106. * @param func is the function called when the Selector is checked
  65107. * @param checked is true when Selector is checked
  65108. */
  65109. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65110. /** @hidden */
  65111. _setSelectorLabel(selectorNb: number, label: string): void;
  65112. /** @hidden */
  65113. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65114. /** @hidden */
  65115. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65116. /** @hidden */
  65117. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65118. }
  65119. /** Class used to create a RadioGroup
  65120. * which contains groups of radio buttons
  65121. */
  65122. export class RadioGroup extends SelectorGroup {
  65123. private _selectNb;
  65124. /** Adds a radio button as a control
  65125. * @param label is the label for the selector
  65126. * @param func is the function called when the Selector is checked
  65127. * @param checked is true when Selector is checked
  65128. */
  65129. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65130. /** @hidden */
  65131. _setSelectorLabel(selectorNb: number, label: string): void;
  65132. /** @hidden */
  65133. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65134. /** @hidden */
  65135. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65136. /** @hidden */
  65137. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65138. }
  65139. /** Class used to create a SliderGroup
  65140. * which contains groups of slider buttons
  65141. */
  65142. export class SliderGroup extends SelectorGroup {
  65143. /**
  65144. * Adds a slider to the SelectorGroup
  65145. * @param label is the label for the SliderBar
  65146. * @param func is the function called when the Slider moves
  65147. * @param unit is a string describing the units used, eg degrees or metres
  65148. * @param min is the minimum value for the Slider
  65149. * @param max is the maximum value for the Slider
  65150. * @param value is the start value for the Slider between min and max
  65151. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65152. */
  65153. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65154. /** @hidden */
  65155. _setSelectorLabel(selectorNb: number, label: string): void;
  65156. /** @hidden */
  65157. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65158. /** @hidden */
  65159. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65160. /** @hidden */
  65161. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65162. }
  65163. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65164. * @see http://doc.babylonjs.com/how_to/selector
  65165. */
  65166. export class SelectionPanel extends Rectangle {
  65167. /** name of SelectionPanel */
  65168. name: string;
  65169. /** an array of SelectionGroups */
  65170. groups: SelectorGroup[];
  65171. private _panel;
  65172. private _buttonColor;
  65173. private _buttonBackground;
  65174. private _headerColor;
  65175. private _barColor;
  65176. private _barHeight;
  65177. private _spacerHeight;
  65178. private _labelColor;
  65179. private _groups;
  65180. private _bars;
  65181. /**
  65182. * Creates a new SelectionPanel
  65183. * @param name of SelectionPanel
  65184. * @param groups is an array of SelectionGroups
  65185. */
  65186. constructor(
  65187. /** name of SelectionPanel */
  65188. name: string,
  65189. /** an array of SelectionGroups */
  65190. groups?: SelectorGroup[]);
  65191. protected _getTypeName(): string;
  65192. /** Gets or sets the headerColor */
  65193. headerColor: string;
  65194. private _setHeaderColor;
  65195. /** Gets or sets the button color */
  65196. buttonColor: string;
  65197. private _setbuttonColor;
  65198. /** Gets or sets the label color */
  65199. labelColor: string;
  65200. private _setLabelColor;
  65201. /** Gets or sets the button background */
  65202. buttonBackground: string;
  65203. private _setButtonBackground;
  65204. /** Gets or sets the color of separator bar */
  65205. barColor: string;
  65206. private _setBarColor;
  65207. /** Gets or sets the height of separator bar */
  65208. barHeight: string;
  65209. private _setBarHeight;
  65210. /** Gets or sets the height of spacers*/
  65211. spacerHeight: string;
  65212. private _setSpacerHeight;
  65213. /** Adds a bar between groups */
  65214. private _addSpacer;
  65215. /** Add a group to the selection panel
  65216. * @param group is the selector group to add
  65217. */
  65218. addGroup(group: SelectorGroup): void;
  65219. /** Remove the group from the given position
  65220. * @param groupNb is the position of the group in the list
  65221. */
  65222. removeGroup(groupNb: number): void;
  65223. /** Change a group header label
  65224. * @param label is the new group header label
  65225. * @param groupNb is the number of the group to relabel
  65226. * */
  65227. setHeaderName(label: string, groupNb: number): void;
  65228. /** Change selector label to the one given
  65229. * @param label is the new selector label
  65230. * @param groupNb is the number of the groupcontaining the selector
  65231. * @param selectorNb is the number of the selector within a group to relabel
  65232. * */
  65233. relabel(label: string, groupNb: number, selectorNb: number): void;
  65234. /** For a given group position remove the selector at the given position
  65235. * @param groupNb is the number of the group to remove the selector from
  65236. * @param selectorNb is the number of the selector within the group
  65237. */
  65238. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65239. /** For a given group position of correct type add a checkbox button
  65240. * @param groupNb is the number of the group to remove the selector from
  65241. * @param label is the label for the selector
  65242. * @param func is the function called when the Selector is checked
  65243. * @param checked is true when Selector is checked
  65244. */
  65245. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65246. /** For a given group position of correct type add a radio button
  65247. * @param groupNb is the number of the group to remove the selector from
  65248. * @param label is the label for the selector
  65249. * @param func is the function called when the Selector is checked
  65250. * @param checked is true when Selector is checked
  65251. */
  65252. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65253. /**
  65254. * For a given slider group add a slider
  65255. * @param groupNb is the number of the group to add the slider to
  65256. * @param label is the label for the Slider
  65257. * @param func is the function called when the Slider moves
  65258. * @param unit is a string describing the units used, eg degrees or metres
  65259. * @param min is the minimum value for the Slider
  65260. * @param max is the maximum value for the Slider
  65261. * @param value is the start value for the Slider between min and max
  65262. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65263. */
  65264. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65265. }
  65266. }
  65267. declare module BABYLON.GUI {
  65268. /**
  65269. * Class used to hold a the container for ScrollViewer
  65270. * @hidden
  65271. */
  65272. export class _ScrollViewerWindow extends Container {
  65273. parentClientWidth: number;
  65274. parentClientHeight: number;
  65275. /**
  65276. * Creates a new ScrollViewerWindow
  65277. * @param name of ScrollViewerWindow
  65278. */
  65279. constructor(name?: string);
  65280. protected _getTypeName(): string;
  65281. /** @hidden */
  65282. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65283. protected _postMeasure(): void;
  65284. }
  65285. }
  65286. declare module BABYLON.GUI {
  65287. /**
  65288. * Class used to create slider controls
  65289. */
  65290. export class ScrollBar extends BaseSlider {
  65291. name?: string | undefined;
  65292. private _background;
  65293. private _borderColor;
  65294. private _thumbMeasure;
  65295. /** Gets or sets border color */
  65296. borderColor: string;
  65297. /** Gets or sets background color */
  65298. background: string;
  65299. /**
  65300. * Creates a new Slider
  65301. * @param name defines the control name
  65302. */
  65303. constructor(name?: string | undefined);
  65304. protected _getTypeName(): string;
  65305. protected _getThumbThickness(): number;
  65306. _draw(context: CanvasRenderingContext2D): void;
  65307. private _first;
  65308. private _originX;
  65309. private _originY;
  65310. /** @hidden */
  65311. protected _updateValueFromPointer(x: number, y: number): void;
  65312. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65313. }
  65314. }
  65315. declare module BABYLON.GUI {
  65316. /**
  65317. * Class used to hold a viewer window and sliders in a grid
  65318. */
  65319. export class ScrollViewer extends Rectangle {
  65320. private _grid;
  65321. private _horizontalBarSpace;
  65322. private _verticalBarSpace;
  65323. private _dragSpace;
  65324. private _horizontalBar;
  65325. private _verticalBar;
  65326. private _barColor;
  65327. private _barBackground;
  65328. private _barSize;
  65329. private _endLeft;
  65330. private _endTop;
  65331. private _window;
  65332. private _pointerIsOver;
  65333. private _wheelPrecision;
  65334. private _onPointerObserver;
  65335. private _clientWidth;
  65336. private _clientHeight;
  65337. /**
  65338. * Gets the horizontal scrollbar
  65339. */
  65340. readonly horizontalBar: ScrollBar;
  65341. /**
  65342. * Gets the vertical scrollbar
  65343. */
  65344. readonly verticalBar: ScrollBar;
  65345. /**
  65346. * Adds a new control to the current container
  65347. * @param control defines the control to add
  65348. * @returns the current container
  65349. */
  65350. addControl(control: BABYLON.Nullable<Control>): Container;
  65351. /**
  65352. * Removes a control from the current container
  65353. * @param control defines the control to remove
  65354. * @returns the current container
  65355. */
  65356. removeControl(control: Control): Container;
  65357. /** Gets the list of children */
  65358. readonly children: Control[];
  65359. _flagDescendantsAsMatrixDirty(): void;
  65360. /**
  65361. * Creates a new ScrollViewer
  65362. * @param name of ScrollViewer
  65363. */
  65364. constructor(name?: string);
  65365. /** Reset the scroll viewer window to initial size */
  65366. resetWindow(): void;
  65367. protected _getTypeName(): string;
  65368. private _buildClientSizes;
  65369. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65370. protected _postMeasure(): void;
  65371. /**
  65372. * Gets or sets the mouse wheel precision
  65373. * from 0 to 1 with a default value of 0.05
  65374. * */
  65375. wheelPrecision: number;
  65376. /** Gets or sets the bar color */
  65377. barColor: string;
  65378. /** Gets or sets the size of the bar */
  65379. barSize: number;
  65380. /** Gets or sets the bar background */
  65381. barBackground: string;
  65382. /** @hidden */
  65383. private _updateScroller;
  65384. _link(host: AdvancedDynamicTexture): void;
  65385. /** @hidden */
  65386. private _attachWheel;
  65387. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65388. /** Releases associated resources */
  65389. dispose(): void;
  65390. }
  65391. }
  65392. declare module BABYLON.GUI {
  65393. /** Class used to render a grid */
  65394. export class DisplayGrid extends Control {
  65395. name?: string | undefined;
  65396. private _cellWidth;
  65397. private _cellHeight;
  65398. private _minorLineTickness;
  65399. private _minorLineColor;
  65400. private _majorLineTickness;
  65401. private _majorLineColor;
  65402. private _majorLineFrequency;
  65403. private _background;
  65404. private _displayMajorLines;
  65405. private _displayMinorLines;
  65406. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65407. displayMinorLines: boolean;
  65408. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65409. displayMajorLines: boolean;
  65410. /** Gets or sets background color (Black by default) */
  65411. background: string;
  65412. /** Gets or sets the width of each cell (20 by default) */
  65413. cellWidth: number;
  65414. /** Gets or sets the height of each cell (20 by default) */
  65415. cellHeight: number;
  65416. /** Gets or sets the tickness of minor lines (1 by default) */
  65417. minorLineTickness: number;
  65418. /** Gets or sets the color of minor lines (DarkGray by default) */
  65419. minorLineColor: string;
  65420. /** Gets or sets the tickness of major lines (2 by default) */
  65421. majorLineTickness: number;
  65422. /** Gets or sets the color of major lines (White by default) */
  65423. majorLineColor: string;
  65424. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65425. majorLineFrequency: number;
  65426. /**
  65427. * Creates a new GridDisplayRectangle
  65428. * @param name defines the control name
  65429. */
  65430. constructor(name?: string | undefined);
  65431. _draw(context: CanvasRenderingContext2D): void;
  65432. protected _getTypeName(): string;
  65433. }
  65434. }
  65435. declare module BABYLON.GUI {
  65436. /**
  65437. * Class used to create slider controls based on images
  65438. */
  65439. export class ImageBasedSlider extends BaseSlider {
  65440. name?: string | undefined;
  65441. private _backgroundImage;
  65442. private _thumbImage;
  65443. private _valueBarImage;
  65444. private _tempMeasure;
  65445. displayThumb: boolean;
  65446. /**
  65447. * Gets or sets the image used to render the background
  65448. */
  65449. backgroundImage: Image;
  65450. /**
  65451. * Gets or sets the image used to render the value bar
  65452. */
  65453. valueBarImage: Image;
  65454. /**
  65455. * Gets or sets the image used to render the thumb
  65456. */
  65457. thumbImage: Image;
  65458. /**
  65459. * Creates a new ImageBasedSlider
  65460. * @param name defines the control name
  65461. */
  65462. constructor(name?: string | undefined);
  65463. protected _getTypeName(): string;
  65464. _draw(context: CanvasRenderingContext2D): void;
  65465. }
  65466. }
  65467. declare module BABYLON.GUI {
  65468. /**
  65469. * Forcing an export so that this code will execute
  65470. * @hidden
  65471. */
  65472. const name = "Statics";
  65473. }
  65474. declare module BABYLON.GUI {
  65475. /**
  65476. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65477. */
  65478. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65479. /**
  65480. * Define the instrumented AdvancedDynamicTexture.
  65481. */
  65482. texture: AdvancedDynamicTexture;
  65483. private _captureRenderTime;
  65484. private _renderTime;
  65485. private _captureLayoutTime;
  65486. private _layoutTime;
  65487. private _onBeginRenderObserver;
  65488. private _onEndRenderObserver;
  65489. private _onBeginLayoutObserver;
  65490. private _onEndLayoutObserver;
  65491. /**
  65492. * Gets the perf counter used to capture render time
  65493. */
  65494. readonly renderTimeCounter: BABYLON.PerfCounter;
  65495. /**
  65496. * Gets the perf counter used to capture layout time
  65497. */
  65498. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65499. /**
  65500. * Enable or disable the render time capture
  65501. */
  65502. captureRenderTime: boolean;
  65503. /**
  65504. * Enable or disable the layout time capture
  65505. */
  65506. captureLayoutTime: boolean;
  65507. /**
  65508. * Instantiates a new advanced dynamic texture instrumentation.
  65509. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65510. * @param texture Defines the AdvancedDynamicTexture to instrument
  65511. */
  65512. constructor(
  65513. /**
  65514. * Define the instrumented AdvancedDynamicTexture.
  65515. */
  65516. texture: AdvancedDynamicTexture);
  65517. /**
  65518. * Dispose and release associated resources.
  65519. */
  65520. dispose(): void;
  65521. }
  65522. }
  65523. declare module BABYLON.GUI {
  65524. /**
  65525. * Class used to create containers for controls
  65526. */
  65527. export class Container3D extends Control3D {
  65528. private _blockLayout;
  65529. /**
  65530. * Gets the list of child controls
  65531. */
  65532. protected _children: Control3D[];
  65533. /**
  65534. * Gets the list of child controls
  65535. */
  65536. readonly children: Array<Control3D>;
  65537. /**
  65538. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65539. * This is helpful to optimize layout operation when adding multiple children in a row
  65540. */
  65541. blockLayout: boolean;
  65542. /**
  65543. * Creates a new container
  65544. * @param name defines the container name
  65545. */
  65546. constructor(name?: string);
  65547. /**
  65548. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65549. * @returns the current container
  65550. */
  65551. updateLayout(): Container3D;
  65552. /**
  65553. * Gets a boolean indicating if the given control is in the children of this control
  65554. * @param control defines the control to check
  65555. * @returns true if the control is in the child list
  65556. */
  65557. containsControl(control: Control3D): boolean;
  65558. /**
  65559. * Adds a control to the children of this control
  65560. * @param control defines the control to add
  65561. * @returns the current container
  65562. */
  65563. addControl(control: Control3D): Container3D;
  65564. /**
  65565. * This function will be called everytime a new control is added
  65566. */
  65567. protected _arrangeChildren(): void;
  65568. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65569. /**
  65570. * Removes a control from the children of this control
  65571. * @param control defines the control to remove
  65572. * @returns the current container
  65573. */
  65574. removeControl(control: Control3D): Container3D;
  65575. protected _getTypeName(): string;
  65576. /**
  65577. * Releases all associated resources
  65578. */
  65579. dispose(): void;
  65580. /** Control rotation will remain unchanged */
  65581. static readonly UNSET_ORIENTATION: number;
  65582. /** Control will rotate to make it look at sphere central axis */
  65583. static readonly FACEORIGIN_ORIENTATION: number;
  65584. /** Control will rotate to make it look back at sphere central axis */
  65585. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65586. /** Control will rotate to look at z axis (0, 0, 1) */
  65587. static readonly FACEFORWARD_ORIENTATION: number;
  65588. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65589. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65590. }
  65591. }
  65592. declare module BABYLON.GUI {
  65593. /**
  65594. * Class used to manage 3D user interface
  65595. * @see http://doc.babylonjs.com/how_to/gui3d
  65596. */
  65597. export class GUI3DManager implements BABYLON.IDisposable {
  65598. private _scene;
  65599. private _sceneDisposeObserver;
  65600. private _utilityLayer;
  65601. private _rootContainer;
  65602. private _pointerObserver;
  65603. private _pointerOutObserver;
  65604. /** @hidden */
  65605. _lastPickedControl: Control3D;
  65606. /** @hidden */
  65607. _lastControlOver: {
  65608. [pointerId: number]: Control3D;
  65609. };
  65610. /** @hidden */
  65611. _lastControlDown: {
  65612. [pointerId: number]: Control3D;
  65613. };
  65614. /**
  65615. * BABYLON.Observable raised when the point picked by the pointer events changed
  65616. */
  65617. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65618. /** @hidden */
  65619. _sharedMaterials: {
  65620. [key: string]: BABYLON.Material;
  65621. };
  65622. /** Gets the hosting scene */
  65623. readonly scene: BABYLON.Scene;
  65624. /** Gets associated utility layer */
  65625. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65626. /**
  65627. * Creates a new GUI3DManager
  65628. * @param scene
  65629. */
  65630. constructor(scene?: BABYLON.Scene);
  65631. private _handlePointerOut;
  65632. private _doPicking;
  65633. /**
  65634. * Gets the root container
  65635. */
  65636. readonly rootContainer: Container3D;
  65637. /**
  65638. * Gets a boolean indicating if the given control is in the root child list
  65639. * @param control defines the control to check
  65640. * @returns true if the control is in the root child list
  65641. */
  65642. containsControl(control: Control3D): boolean;
  65643. /**
  65644. * Adds a control to the root child list
  65645. * @param control defines the control to add
  65646. * @returns the current manager
  65647. */
  65648. addControl(control: Control3D): GUI3DManager;
  65649. /**
  65650. * Removes a control from the root child list
  65651. * @param control defines the control to remove
  65652. * @returns the current container
  65653. */
  65654. removeControl(control: Control3D): GUI3DManager;
  65655. /**
  65656. * Releases all associated resources
  65657. */
  65658. dispose(): void;
  65659. }
  65660. }
  65661. declare module BABYLON.GUI {
  65662. /**
  65663. * Class used to transport BABYLON.Vector3 information for pointer events
  65664. */
  65665. export class Vector3WithInfo extends BABYLON.Vector3 {
  65666. /** defines the current mouse button index */
  65667. buttonIndex: number;
  65668. /**
  65669. * Creates a new Vector3WithInfo
  65670. * @param source defines the vector3 data to transport
  65671. * @param buttonIndex defines the current mouse button index
  65672. */
  65673. constructor(source: BABYLON.Vector3,
  65674. /** defines the current mouse button index */
  65675. buttonIndex?: number);
  65676. }
  65677. }
  65678. declare module BABYLON.GUI {
  65679. /**
  65680. * Class used as base class for controls
  65681. */
  65682. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65683. /** Defines the control name */
  65684. name?: string | undefined;
  65685. /** @hidden */
  65686. _host: GUI3DManager;
  65687. private _node;
  65688. private _downCount;
  65689. private _enterCount;
  65690. private _downPointerIds;
  65691. private _isVisible;
  65692. /** Gets or sets the control position in world space */
  65693. position: BABYLON.Vector3;
  65694. /** Gets or sets the control scaling in world space */
  65695. scaling: BABYLON.Vector3;
  65696. /** Callback used to start pointer enter animation */
  65697. pointerEnterAnimation: () => void;
  65698. /** Callback used to start pointer out animation */
  65699. pointerOutAnimation: () => void;
  65700. /** Callback used to start pointer down animation */
  65701. pointerDownAnimation: () => void;
  65702. /** Callback used to start pointer up animation */
  65703. pointerUpAnimation: () => void;
  65704. /**
  65705. * An event triggered when the pointer move over the control
  65706. */
  65707. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65708. /**
  65709. * An event triggered when the pointer move out of the control
  65710. */
  65711. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65712. /**
  65713. * An event triggered when the pointer taps the control
  65714. */
  65715. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65716. /**
  65717. * An event triggered when pointer is up
  65718. */
  65719. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65720. /**
  65721. * An event triggered when a control is clicked on (with a mouse)
  65722. */
  65723. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65724. /**
  65725. * An event triggered when pointer enters the control
  65726. */
  65727. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65728. /**
  65729. * Gets or sets the parent container
  65730. */
  65731. parent: BABYLON.Nullable<Container3D>;
  65732. private _behaviors;
  65733. /**
  65734. * Gets the list of attached behaviors
  65735. * @see http://doc.babylonjs.com/features/behaviour
  65736. */
  65737. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65738. /**
  65739. * Attach a behavior to the control
  65740. * @see http://doc.babylonjs.com/features/behaviour
  65741. * @param behavior defines the behavior to attach
  65742. * @returns the current control
  65743. */
  65744. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65745. /**
  65746. * Remove an attached behavior
  65747. * @see http://doc.babylonjs.com/features/behaviour
  65748. * @param behavior defines the behavior to attach
  65749. * @returns the current control
  65750. */
  65751. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65752. /**
  65753. * Gets an attached behavior by name
  65754. * @param name defines the name of the behavior to look for
  65755. * @see http://doc.babylonjs.com/features/behaviour
  65756. * @returns null if behavior was not found else the requested behavior
  65757. */
  65758. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65759. /** Gets or sets a boolean indicating if the control is visible */
  65760. isVisible: boolean;
  65761. /**
  65762. * Creates a new control
  65763. * @param name defines the control name
  65764. */
  65765. constructor(
  65766. /** Defines the control name */
  65767. name?: string | undefined);
  65768. /**
  65769. * Gets a string representing the class name
  65770. */
  65771. readonly typeName: string;
  65772. /**
  65773. * Get the current class name of the control.
  65774. * @returns current class name
  65775. */
  65776. getClassName(): string;
  65777. protected _getTypeName(): string;
  65778. /**
  65779. * Gets the transform node used by this control
  65780. */
  65781. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65782. /**
  65783. * Gets the mesh used to render this control
  65784. */
  65785. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65786. /**
  65787. * Link the control as child of the given node
  65788. * @param node defines the node to link to. Use null to unlink the control
  65789. * @returns the current control
  65790. */
  65791. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65792. /** @hidden **/
  65793. _prepareNode(scene: BABYLON.Scene): void;
  65794. /**
  65795. * Node creation.
  65796. * Can be overriden by children
  65797. * @param scene defines the scene where the node must be attached
  65798. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65799. */
  65800. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65801. /**
  65802. * Affect a material to the given mesh
  65803. * @param mesh defines the mesh which will represent the control
  65804. */
  65805. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65806. /** @hidden */
  65807. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65808. /** @hidden */
  65809. _onPointerEnter(target: Control3D): boolean;
  65810. /** @hidden */
  65811. _onPointerOut(target: Control3D): void;
  65812. /** @hidden */
  65813. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65814. /** @hidden */
  65815. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65816. /** @hidden */
  65817. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65818. /** @hidden */
  65819. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65820. /** @hidden */
  65821. _disposeNode(): void;
  65822. /**
  65823. * Releases all associated resources
  65824. */
  65825. dispose(): void;
  65826. }
  65827. }
  65828. declare module BABYLON.GUI {
  65829. /**
  65830. * Class used as a root to all buttons
  65831. */
  65832. export class AbstractButton3D extends Control3D {
  65833. /**
  65834. * Creates a new button
  65835. * @param name defines the control name
  65836. */
  65837. constructor(name?: string);
  65838. protected _getTypeName(): string;
  65839. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65840. }
  65841. }
  65842. declare module BABYLON.GUI {
  65843. /**
  65844. * Class used to create a button in 3D
  65845. */
  65846. export class Button3D extends AbstractButton3D {
  65847. /** @hidden */
  65848. protected _currentMaterial: BABYLON.Material;
  65849. private _facadeTexture;
  65850. private _content;
  65851. private _contentResolution;
  65852. private _contentScaleRatio;
  65853. /**
  65854. * Gets or sets the texture resolution used to render content (512 by default)
  65855. */
  65856. contentResolution: BABYLON.int;
  65857. /**
  65858. * Gets or sets the texture scale ratio used to render content (2 by default)
  65859. */
  65860. contentScaleRatio: number;
  65861. protected _disposeFacadeTexture(): void;
  65862. protected _resetContent(): void;
  65863. /**
  65864. * Creates a new button
  65865. * @param name defines the control name
  65866. */
  65867. constructor(name?: string);
  65868. /**
  65869. * Gets or sets the GUI 2D content used to display the button's facade
  65870. */
  65871. content: Control;
  65872. /**
  65873. * Apply the facade texture (created from the content property).
  65874. * This function can be overloaded by child classes
  65875. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65876. */
  65877. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65878. protected _getTypeName(): string;
  65879. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65880. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65881. /**
  65882. * Releases all associated resources
  65883. */
  65884. dispose(): void;
  65885. }
  65886. }
  65887. declare module BABYLON.GUI {
  65888. /**
  65889. * Abstract class used to create a container panel deployed on the surface of a volume
  65890. */
  65891. export abstract class VolumeBasedPanel extends Container3D {
  65892. private _columns;
  65893. private _rows;
  65894. private _rowThenColum;
  65895. private _orientation;
  65896. protected _cellWidth: number;
  65897. protected _cellHeight: number;
  65898. /**
  65899. * Gets or sets the distance between elements
  65900. */
  65901. margin: number;
  65902. /**
  65903. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65904. * | Value | Type | Description |
  65905. * | ----- | ----------------------------------- | ----------- |
  65906. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65907. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65908. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65909. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65910. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65911. */
  65912. orientation: number;
  65913. /**
  65914. * Gets or sets the number of columns requested (10 by default).
  65915. * The panel will automatically compute the number of rows based on number of child controls.
  65916. */
  65917. columns: BABYLON.int;
  65918. /**
  65919. * Gets or sets a the number of rows requested.
  65920. * The panel will automatically compute the number of columns based on number of child controls.
  65921. */
  65922. rows: BABYLON.int;
  65923. /**
  65924. * Creates new VolumeBasedPanel
  65925. */
  65926. constructor();
  65927. protected _arrangeChildren(): void;
  65928. /** Child classes must implement this function to provide correct control positioning */
  65929. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65930. /** Child classes can implement this function to provide additional processing */
  65931. protected _finalProcessing(): void;
  65932. }
  65933. }
  65934. declare module BABYLON.GUI {
  65935. /**
  65936. * Class used to create a container panel deployed on the surface of a cylinder
  65937. */
  65938. export class CylinderPanel extends VolumeBasedPanel {
  65939. private _radius;
  65940. /**
  65941. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65942. */
  65943. radius: BABYLON.float;
  65944. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65945. private _cylindricalMapping;
  65946. }
  65947. }
  65948. declare module BABYLON.GUI {
  65949. /** @hidden */
  65950. export var fluentVertexShader: {
  65951. name: string;
  65952. shader: string;
  65953. };
  65954. }
  65955. declare module BABYLON.GUI {
  65956. /** @hidden */
  65957. export var fluentPixelShader: {
  65958. name: string;
  65959. shader: string;
  65960. };
  65961. }
  65962. declare module BABYLON.GUI {
  65963. /** @hidden */
  65964. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65965. INNERGLOW: boolean;
  65966. BORDER: boolean;
  65967. HOVERLIGHT: boolean;
  65968. TEXTURE: boolean;
  65969. constructor();
  65970. }
  65971. /**
  65972. * Class used to render controls with fluent desgin
  65973. */
  65974. export class FluentMaterial extends BABYLON.PushMaterial {
  65975. /**
  65976. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65977. */
  65978. innerGlowColorIntensity: number;
  65979. /**
  65980. * Gets or sets the inner glow color (white by default)
  65981. */
  65982. innerGlowColor: BABYLON.Color3;
  65983. /**
  65984. * Gets or sets alpha value (default is 1.0)
  65985. */
  65986. alpha: number;
  65987. /**
  65988. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65989. */
  65990. albedoColor: BABYLON.Color3;
  65991. /**
  65992. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65993. */
  65994. renderBorders: boolean;
  65995. /**
  65996. * Gets or sets border width (default is 0.5)
  65997. */
  65998. borderWidth: number;
  65999. /**
  66000. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66001. */
  66002. edgeSmoothingValue: number;
  66003. /**
  66004. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66005. */
  66006. borderMinValue: number;
  66007. /**
  66008. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66009. */
  66010. renderHoverLight: boolean;
  66011. /**
  66012. * Gets or sets the radius used to render the hover light (default is 1.0)
  66013. */
  66014. hoverRadius: number;
  66015. /**
  66016. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66017. */
  66018. hoverColor: BABYLON.Color4;
  66019. /**
  66020. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66021. */
  66022. hoverPosition: BABYLON.Vector3;
  66023. private _albedoTexture;
  66024. /** Gets or sets the texture to use for albedo color */
  66025. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66026. /**
  66027. * Creates a new Fluent material
  66028. * @param name defines the name of the material
  66029. * @param scene defines the hosting scene
  66030. */
  66031. constructor(name: string, scene: BABYLON.Scene);
  66032. needAlphaBlending(): boolean;
  66033. needAlphaTesting(): boolean;
  66034. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66035. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66036. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66037. getActiveTextures(): BABYLON.BaseTexture[];
  66038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66039. dispose(forceDisposeEffect?: boolean): void;
  66040. clone(name: string): FluentMaterial;
  66041. serialize(): any;
  66042. getClassName(): string;
  66043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66044. }
  66045. }
  66046. declare module BABYLON.GUI {
  66047. /**
  66048. * Class used to create a holographic button in 3D
  66049. */
  66050. export class HolographicButton extends Button3D {
  66051. private _backPlate;
  66052. private _textPlate;
  66053. private _frontPlate;
  66054. private _text;
  66055. private _imageUrl;
  66056. private _shareMaterials;
  66057. private _frontMaterial;
  66058. private _backMaterial;
  66059. private _plateMaterial;
  66060. private _pickedPointObserver;
  66061. private _tooltipFade;
  66062. private _tooltipTextBlock;
  66063. private _tooltipTexture;
  66064. private _tooltipMesh;
  66065. private _tooltipHoverObserver;
  66066. private _tooltipOutObserver;
  66067. private _disposeTooltip;
  66068. /**
  66069. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66070. */
  66071. tooltipText: BABYLON.Nullable<string>;
  66072. /**
  66073. * Gets or sets text for the button
  66074. */
  66075. text: string;
  66076. /**
  66077. * Gets or sets the image url for the button
  66078. */
  66079. imageUrl: string;
  66080. /**
  66081. * Gets the back material used by this button
  66082. */
  66083. readonly backMaterial: FluentMaterial;
  66084. /**
  66085. * Gets the front material used by this button
  66086. */
  66087. readonly frontMaterial: FluentMaterial;
  66088. /**
  66089. * Gets the plate material used by this button
  66090. */
  66091. readonly plateMaterial: BABYLON.StandardMaterial;
  66092. /**
  66093. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66094. */
  66095. readonly shareMaterials: boolean;
  66096. /**
  66097. * Creates a new button
  66098. * @param name defines the control name
  66099. */
  66100. constructor(name?: string, shareMaterials?: boolean);
  66101. protected _getTypeName(): string;
  66102. private _rebuildContent;
  66103. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66104. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66105. private _createBackMaterial;
  66106. private _createFrontMaterial;
  66107. private _createPlateMaterial;
  66108. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66109. /**
  66110. * Releases all associated resources
  66111. */
  66112. dispose(): void;
  66113. }
  66114. }
  66115. declare module BABYLON.GUI {
  66116. /**
  66117. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66118. */
  66119. export class MeshButton3D extends Button3D {
  66120. /** @hidden */
  66121. protected _currentMesh: BABYLON.Mesh;
  66122. /**
  66123. * Creates a new 3D button based on a mesh
  66124. * @param mesh mesh to become a 3D button
  66125. * @param name defines the control name
  66126. */
  66127. constructor(mesh: BABYLON.Mesh, name?: string);
  66128. protected _getTypeName(): string;
  66129. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66130. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66131. }
  66132. }
  66133. declare module BABYLON.GUI {
  66134. /**
  66135. * Class used to create a container panel deployed on the surface of a plane
  66136. */
  66137. export class PlanePanel extends VolumeBasedPanel {
  66138. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66139. }
  66140. }
  66141. declare module BABYLON.GUI {
  66142. /**
  66143. * Class used to create a container panel where items get randomized planar mapping
  66144. */
  66145. export class ScatterPanel extends VolumeBasedPanel {
  66146. private _iteration;
  66147. /**
  66148. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66149. */
  66150. iteration: BABYLON.float;
  66151. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66152. private _scatterMapping;
  66153. protected _finalProcessing(): void;
  66154. }
  66155. }
  66156. declare module BABYLON.GUI {
  66157. /**
  66158. * Class used to create a container panel deployed on the surface of a sphere
  66159. */
  66160. export class SpherePanel extends VolumeBasedPanel {
  66161. private _radius;
  66162. /**
  66163. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66164. */
  66165. radius: BABYLON.float;
  66166. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66167. private _sphericalMapping;
  66168. }
  66169. }
  66170. declare module BABYLON.GUI {
  66171. /**
  66172. * Class used to create a stack panel in 3D on XY plane
  66173. */
  66174. export class StackPanel3D extends Container3D {
  66175. private _isVertical;
  66176. /**
  66177. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66178. */
  66179. isVertical: boolean;
  66180. /**
  66181. * Gets or sets the distance between elements
  66182. */
  66183. margin: number;
  66184. /**
  66185. * Creates new StackPanel
  66186. * @param isVertical
  66187. */
  66188. constructor(isVertical?: boolean);
  66189. protected _arrangeChildren(): void;
  66190. }
  66191. }
  66192. declare module BABYLON {
  66193. /**
  66194. * Mode that determines the coordinate system to use.
  66195. */
  66196. export enum GLTFLoaderCoordinateSystemMode {
  66197. /**
  66198. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66199. */
  66200. AUTO = 0,
  66201. /**
  66202. * Sets the useRightHandedSystem flag on the scene.
  66203. */
  66204. FORCE_RIGHT_HANDED = 1
  66205. }
  66206. /**
  66207. * Mode that determines what animations will start.
  66208. */
  66209. export enum GLTFLoaderAnimationStartMode {
  66210. /**
  66211. * No animation will start.
  66212. */
  66213. NONE = 0,
  66214. /**
  66215. * The first animation will start.
  66216. */
  66217. FIRST = 1,
  66218. /**
  66219. * All animations will start.
  66220. */
  66221. ALL = 2
  66222. }
  66223. /**
  66224. * Interface that contains the data for the glTF asset.
  66225. */
  66226. export interface IGLTFLoaderData {
  66227. /**
  66228. * Object that represents the glTF JSON.
  66229. */
  66230. json: Object;
  66231. /**
  66232. * The BIN chunk of a binary glTF.
  66233. */
  66234. bin: Nullable<ArrayBufferView>;
  66235. }
  66236. /**
  66237. * Interface for extending the loader.
  66238. */
  66239. export interface IGLTFLoaderExtension {
  66240. /**
  66241. * The name of this extension.
  66242. */
  66243. readonly name: string;
  66244. /**
  66245. * Defines whether this extension is enabled.
  66246. */
  66247. enabled: boolean;
  66248. }
  66249. /**
  66250. * Loader state.
  66251. */
  66252. export enum GLTFLoaderState {
  66253. /**
  66254. * The asset is loading.
  66255. */
  66256. LOADING = 0,
  66257. /**
  66258. * The asset is ready for rendering.
  66259. */
  66260. READY = 1,
  66261. /**
  66262. * The asset is completely loaded.
  66263. */
  66264. COMPLETE = 2
  66265. }
  66266. /** @hidden */
  66267. export interface IGLTFLoader extends IDisposable {
  66268. readonly state: Nullable<GLTFLoaderState>;
  66269. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66270. meshes: AbstractMesh[];
  66271. particleSystems: IParticleSystem[];
  66272. skeletons: Skeleton[];
  66273. animationGroups: AnimationGroup[];
  66274. }>;
  66275. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66276. }
  66277. /**
  66278. * File loader for loading glTF files into a scene.
  66279. */
  66280. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66281. /** @hidden */
  66282. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66283. /** @hidden */
  66284. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66285. /**
  66286. * Raised when the asset has been parsed
  66287. */
  66288. onParsedObservable: Observable<IGLTFLoaderData>;
  66289. private _onParsedObserver;
  66290. /**
  66291. * Raised when the asset has been parsed
  66292. */
  66293. onParsed: (loaderData: IGLTFLoaderData) => void;
  66294. /**
  66295. * 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.
  66296. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66297. * Defaults to true.
  66298. * @hidden
  66299. */
  66300. static IncrementalLoading: boolean;
  66301. /**
  66302. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66303. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66304. * @hidden
  66305. */
  66306. static HomogeneousCoordinates: boolean;
  66307. /**
  66308. * The coordinate system mode. Defaults to AUTO.
  66309. */
  66310. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66311. /**
  66312. * The animation start mode. Defaults to FIRST.
  66313. */
  66314. animationStartMode: GLTFLoaderAnimationStartMode;
  66315. /**
  66316. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66317. */
  66318. compileMaterials: boolean;
  66319. /**
  66320. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66321. */
  66322. useClipPlane: boolean;
  66323. /**
  66324. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66325. */
  66326. compileShadowGenerators: boolean;
  66327. /**
  66328. * Defines if the Alpha blended materials are only applied as coverage.
  66329. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66330. * If true, no extra effects are applied to transparent pixels.
  66331. */
  66332. transparencyAsCoverage: boolean;
  66333. /**
  66334. * Function called before loading a url referenced by the asset.
  66335. */
  66336. preprocessUrlAsync: (url: string) => Promise<string>;
  66337. /**
  66338. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66339. */
  66340. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66341. private _onMeshLoadedObserver;
  66342. /**
  66343. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66344. */
  66345. onMeshLoaded: (mesh: AbstractMesh) => void;
  66346. /**
  66347. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66348. */
  66349. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66350. private _onTextureLoadedObserver;
  66351. /**
  66352. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66353. */
  66354. onTextureLoaded: (texture: BaseTexture) => void;
  66355. /**
  66356. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66357. */
  66358. readonly onMaterialLoadedObservable: Observable<Material>;
  66359. private _onMaterialLoadedObserver;
  66360. /**
  66361. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66362. */
  66363. onMaterialLoaded: (material: Material) => void;
  66364. /**
  66365. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66366. */
  66367. readonly onCameraLoadedObservable: Observable<Camera>;
  66368. private _onCameraLoadedObserver;
  66369. /**
  66370. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66371. */
  66372. onCameraLoaded: (camera: Camera) => void;
  66373. /**
  66374. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66375. * For assets with LODs, raised when all of the LODs are complete.
  66376. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66377. */
  66378. readonly onCompleteObservable: Observable<void>;
  66379. private _onCompleteObserver;
  66380. /**
  66381. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66382. * For assets with LODs, raised when all of the LODs are complete.
  66383. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66384. */
  66385. onComplete: () => void;
  66386. /**
  66387. * Observable raised when an error occurs.
  66388. */
  66389. readonly onErrorObservable: Observable<any>;
  66390. private _onErrorObserver;
  66391. /**
  66392. * Callback raised when an error occurs.
  66393. */
  66394. onError: (reason: any) => void;
  66395. /**
  66396. * Observable raised after the loader is disposed.
  66397. */
  66398. readonly onDisposeObservable: Observable<void>;
  66399. private _onDisposeObserver;
  66400. /**
  66401. * Callback raised after the loader is disposed.
  66402. */
  66403. onDispose: () => void;
  66404. /**
  66405. * Observable raised after a loader extension is created.
  66406. * Set additional options for a loader extension in this event.
  66407. */
  66408. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66409. private _onExtensionLoadedObserver;
  66410. /**
  66411. * Callback raised after a loader extension is created.
  66412. */
  66413. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66414. /**
  66415. * Defines if the loader logging is enabled.
  66416. */
  66417. loggingEnabled: boolean;
  66418. /**
  66419. * Defines if the loader should capture performance counters.
  66420. */
  66421. capturePerformanceCounters: boolean;
  66422. /**
  66423. * Defines if the loader should validate the asset.
  66424. */
  66425. validate: boolean;
  66426. /**
  66427. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66428. */
  66429. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66430. private _onValidatedObserver;
  66431. /**
  66432. * Callback raised after a loader extension is created.
  66433. */
  66434. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66435. private _loader;
  66436. /**
  66437. * Name of the loader ("gltf")
  66438. */
  66439. name: string;
  66440. /**
  66441. * Supported file extensions of the loader (.gltf, .glb)
  66442. */
  66443. extensions: ISceneLoaderPluginExtensions;
  66444. /**
  66445. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66446. */
  66447. dispose(): void;
  66448. /** @hidden */
  66449. _clear(): void;
  66450. /**
  66451. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66452. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66453. * @param scene the scene the meshes should be added to
  66454. * @param data the glTF data to load
  66455. * @param rootUrl root url to load from
  66456. * @param onProgress event that fires when loading progress has occured
  66457. * @param fileName Defines the name of the file to load
  66458. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66459. */
  66460. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66461. meshes: AbstractMesh[];
  66462. particleSystems: IParticleSystem[];
  66463. skeletons: Skeleton[];
  66464. animationGroups: AnimationGroup[];
  66465. }>;
  66466. /**
  66467. * Imports all objects from the loaded glTF data and adds them to the scene
  66468. * @param scene the scene the objects should be added to
  66469. * @param data the glTF data to load
  66470. * @param rootUrl root url to load from
  66471. * @param onProgress event that fires when loading progress has occured
  66472. * @param fileName Defines the name of the file to load
  66473. * @returns a promise which completes when objects have been loaded to the scene
  66474. */
  66475. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66476. /**
  66477. * Load into an asset container.
  66478. * @param scene The scene to load into
  66479. * @param data The data to import
  66480. * @param rootUrl The root url for scene and resources
  66481. * @param onProgress The callback when the load progresses
  66482. * @param fileName Defines the name of the file to load
  66483. * @returns The loaded asset container
  66484. */
  66485. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66486. /**
  66487. * If the data string can be loaded directly.
  66488. * @param data string contianing the file data
  66489. * @returns if the data can be loaded directly
  66490. */
  66491. canDirectLoad(data: string): boolean;
  66492. /**
  66493. * Rewrites a url by combining a root url and response url.
  66494. */
  66495. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66496. /**
  66497. * Instantiates a glTF file loader plugin.
  66498. * @returns the created plugin
  66499. */
  66500. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66501. /**
  66502. * The loader state or null if the loader is not active.
  66503. */
  66504. readonly loaderState: Nullable<GLTFLoaderState>;
  66505. /**
  66506. * Returns a promise that resolves when the asset is completely loaded.
  66507. * @returns a promise that resolves when the asset is completely loaded.
  66508. */
  66509. whenCompleteAsync(): Promise<void>;
  66510. private _parseAsync;
  66511. private _validateAsync;
  66512. private _getLoader;
  66513. private _unpackBinary;
  66514. private _unpackBinaryV1;
  66515. private _unpackBinaryV2;
  66516. private static _parseVersion;
  66517. private static _compareVersion;
  66518. private static _decodeBufferToText;
  66519. private static readonly _logSpaces;
  66520. private _logIndentLevel;
  66521. private _loggingEnabled;
  66522. /** @hidden */
  66523. _log: (message: string) => void;
  66524. /** @hidden */
  66525. _logOpen(message: string): void;
  66526. /** @hidden */
  66527. _logClose(): void;
  66528. private _logEnabled;
  66529. private _logDisabled;
  66530. private _capturePerformanceCounters;
  66531. /** @hidden */
  66532. _startPerformanceCounter: (counterName: string) => void;
  66533. /** @hidden */
  66534. _endPerformanceCounter: (counterName: string) => void;
  66535. private _startPerformanceCounterEnabled;
  66536. private _startPerformanceCounterDisabled;
  66537. private _endPerformanceCounterEnabled;
  66538. private _endPerformanceCounterDisabled;
  66539. }
  66540. }
  66541. declare module BABYLON.GLTF1 {
  66542. /**
  66543. * Enums
  66544. * @hidden
  66545. */
  66546. export enum EComponentType {
  66547. BYTE = 5120,
  66548. UNSIGNED_BYTE = 5121,
  66549. SHORT = 5122,
  66550. UNSIGNED_SHORT = 5123,
  66551. FLOAT = 5126
  66552. }
  66553. /** @hidden */
  66554. export enum EShaderType {
  66555. FRAGMENT = 35632,
  66556. VERTEX = 35633
  66557. }
  66558. /** @hidden */
  66559. export enum EParameterType {
  66560. BYTE = 5120,
  66561. UNSIGNED_BYTE = 5121,
  66562. SHORT = 5122,
  66563. UNSIGNED_SHORT = 5123,
  66564. INT = 5124,
  66565. UNSIGNED_INT = 5125,
  66566. FLOAT = 5126,
  66567. FLOAT_VEC2 = 35664,
  66568. FLOAT_VEC3 = 35665,
  66569. FLOAT_VEC4 = 35666,
  66570. INT_VEC2 = 35667,
  66571. INT_VEC3 = 35668,
  66572. INT_VEC4 = 35669,
  66573. BOOL = 35670,
  66574. BOOL_VEC2 = 35671,
  66575. BOOL_VEC3 = 35672,
  66576. BOOL_VEC4 = 35673,
  66577. FLOAT_MAT2 = 35674,
  66578. FLOAT_MAT3 = 35675,
  66579. FLOAT_MAT4 = 35676,
  66580. SAMPLER_2D = 35678
  66581. }
  66582. /** @hidden */
  66583. export enum ETextureWrapMode {
  66584. CLAMP_TO_EDGE = 33071,
  66585. MIRRORED_REPEAT = 33648,
  66586. REPEAT = 10497
  66587. }
  66588. /** @hidden */
  66589. export enum ETextureFilterType {
  66590. NEAREST = 9728,
  66591. LINEAR = 9728,
  66592. NEAREST_MIPMAP_NEAREST = 9984,
  66593. LINEAR_MIPMAP_NEAREST = 9985,
  66594. NEAREST_MIPMAP_LINEAR = 9986,
  66595. LINEAR_MIPMAP_LINEAR = 9987
  66596. }
  66597. /** @hidden */
  66598. export enum ETextureFormat {
  66599. ALPHA = 6406,
  66600. RGB = 6407,
  66601. RGBA = 6408,
  66602. LUMINANCE = 6409,
  66603. LUMINANCE_ALPHA = 6410
  66604. }
  66605. /** @hidden */
  66606. export enum ECullingType {
  66607. FRONT = 1028,
  66608. BACK = 1029,
  66609. FRONT_AND_BACK = 1032
  66610. }
  66611. /** @hidden */
  66612. export enum EBlendingFunction {
  66613. ZERO = 0,
  66614. ONE = 1,
  66615. SRC_COLOR = 768,
  66616. ONE_MINUS_SRC_COLOR = 769,
  66617. DST_COLOR = 774,
  66618. ONE_MINUS_DST_COLOR = 775,
  66619. SRC_ALPHA = 770,
  66620. ONE_MINUS_SRC_ALPHA = 771,
  66621. DST_ALPHA = 772,
  66622. ONE_MINUS_DST_ALPHA = 773,
  66623. CONSTANT_COLOR = 32769,
  66624. ONE_MINUS_CONSTANT_COLOR = 32770,
  66625. CONSTANT_ALPHA = 32771,
  66626. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66627. SRC_ALPHA_SATURATE = 776
  66628. }
  66629. /** @hidden */
  66630. export interface IGLTFProperty {
  66631. extensions?: {
  66632. [key: string]: any;
  66633. };
  66634. extras?: Object;
  66635. }
  66636. /** @hidden */
  66637. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66638. name?: string;
  66639. }
  66640. /** @hidden */
  66641. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66642. bufferView: string;
  66643. byteOffset: number;
  66644. byteStride: number;
  66645. count: number;
  66646. type: string;
  66647. componentType: EComponentType;
  66648. max?: number[];
  66649. min?: number[];
  66650. name?: string;
  66651. }
  66652. /** @hidden */
  66653. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66654. buffer: string;
  66655. byteOffset: number;
  66656. byteLength: number;
  66657. byteStride: number;
  66658. target?: number;
  66659. }
  66660. /** @hidden */
  66661. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66662. uri: string;
  66663. byteLength?: number;
  66664. type?: string;
  66665. }
  66666. /** @hidden */
  66667. export interface IGLTFShader extends IGLTFChildRootProperty {
  66668. uri: string;
  66669. type: EShaderType;
  66670. }
  66671. /** @hidden */
  66672. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66673. attributes: string[];
  66674. fragmentShader: string;
  66675. vertexShader: string;
  66676. }
  66677. /** @hidden */
  66678. export interface IGLTFTechniqueParameter {
  66679. type: number;
  66680. count?: number;
  66681. semantic?: string;
  66682. node?: string;
  66683. value?: number | boolean | string | Array<any>;
  66684. source?: string;
  66685. babylonValue?: any;
  66686. }
  66687. /** @hidden */
  66688. export interface IGLTFTechniqueCommonProfile {
  66689. lightingModel: string;
  66690. texcoordBindings: Object;
  66691. parameters?: Array<any>;
  66692. }
  66693. /** @hidden */
  66694. export interface IGLTFTechniqueStatesFunctions {
  66695. blendColor?: number[];
  66696. blendEquationSeparate?: number[];
  66697. blendFuncSeparate?: number[];
  66698. colorMask: boolean[];
  66699. cullFace: number[];
  66700. }
  66701. /** @hidden */
  66702. export interface IGLTFTechniqueStates {
  66703. enable: number[];
  66704. functions: IGLTFTechniqueStatesFunctions;
  66705. }
  66706. /** @hidden */
  66707. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66708. parameters: {
  66709. [key: string]: IGLTFTechniqueParameter;
  66710. };
  66711. program: string;
  66712. attributes: {
  66713. [key: string]: string;
  66714. };
  66715. uniforms: {
  66716. [key: string]: string;
  66717. };
  66718. states: IGLTFTechniqueStates;
  66719. }
  66720. /** @hidden */
  66721. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66722. technique?: string;
  66723. values: string[];
  66724. }
  66725. /** @hidden */
  66726. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66727. attributes: {
  66728. [key: string]: string;
  66729. };
  66730. indices: string;
  66731. material: string;
  66732. mode?: number;
  66733. }
  66734. /** @hidden */
  66735. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66736. primitives: IGLTFMeshPrimitive[];
  66737. }
  66738. /** @hidden */
  66739. export interface IGLTFImage extends IGLTFChildRootProperty {
  66740. uri: string;
  66741. }
  66742. /** @hidden */
  66743. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66744. magFilter?: number;
  66745. minFilter?: number;
  66746. wrapS?: number;
  66747. wrapT?: number;
  66748. }
  66749. /** @hidden */
  66750. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66751. sampler: string;
  66752. source: string;
  66753. format?: ETextureFormat;
  66754. internalFormat?: ETextureFormat;
  66755. target?: number;
  66756. type?: number;
  66757. babylonTexture?: Texture;
  66758. }
  66759. /** @hidden */
  66760. export interface IGLTFAmbienLight {
  66761. color?: number[];
  66762. }
  66763. /** @hidden */
  66764. export interface IGLTFDirectionalLight {
  66765. color?: number[];
  66766. }
  66767. /** @hidden */
  66768. export interface IGLTFPointLight {
  66769. color?: number[];
  66770. constantAttenuation?: number;
  66771. linearAttenuation?: number;
  66772. quadraticAttenuation?: number;
  66773. }
  66774. /** @hidden */
  66775. export interface IGLTFSpotLight {
  66776. color?: number[];
  66777. constantAttenuation?: number;
  66778. fallOfAngle?: number;
  66779. fallOffExponent?: number;
  66780. linearAttenuation?: number;
  66781. quadraticAttenuation?: number;
  66782. }
  66783. /** @hidden */
  66784. export interface IGLTFLight extends IGLTFChildRootProperty {
  66785. type: string;
  66786. }
  66787. /** @hidden */
  66788. export interface IGLTFCameraOrthographic {
  66789. xmag: number;
  66790. ymag: number;
  66791. zfar: number;
  66792. znear: number;
  66793. }
  66794. /** @hidden */
  66795. export interface IGLTFCameraPerspective {
  66796. aspectRatio: number;
  66797. yfov: number;
  66798. zfar: number;
  66799. znear: number;
  66800. }
  66801. /** @hidden */
  66802. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66803. type: string;
  66804. }
  66805. /** @hidden */
  66806. export interface IGLTFAnimationChannelTarget {
  66807. id: string;
  66808. path: string;
  66809. }
  66810. /** @hidden */
  66811. export interface IGLTFAnimationChannel {
  66812. sampler: string;
  66813. target: IGLTFAnimationChannelTarget;
  66814. }
  66815. /** @hidden */
  66816. export interface IGLTFAnimationSampler {
  66817. input: string;
  66818. output: string;
  66819. interpolation?: string;
  66820. }
  66821. /** @hidden */
  66822. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66823. channels?: IGLTFAnimationChannel[];
  66824. parameters?: {
  66825. [key: string]: string;
  66826. };
  66827. samplers?: {
  66828. [key: string]: IGLTFAnimationSampler;
  66829. };
  66830. }
  66831. /** @hidden */
  66832. export interface IGLTFNodeInstanceSkin {
  66833. skeletons: string[];
  66834. skin: string;
  66835. meshes: string[];
  66836. }
  66837. /** @hidden */
  66838. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66839. bindShapeMatrix: number[];
  66840. inverseBindMatrices: string;
  66841. jointNames: string[];
  66842. babylonSkeleton?: Skeleton;
  66843. }
  66844. /** @hidden */
  66845. export interface IGLTFNode extends IGLTFChildRootProperty {
  66846. camera?: string;
  66847. children: string[];
  66848. skin?: string;
  66849. jointName?: string;
  66850. light?: string;
  66851. matrix: number[];
  66852. mesh?: string;
  66853. meshes?: string[];
  66854. rotation?: number[];
  66855. scale?: number[];
  66856. translation?: number[];
  66857. babylonNode?: Node;
  66858. }
  66859. /** @hidden */
  66860. export interface IGLTFScene extends IGLTFChildRootProperty {
  66861. nodes: string[];
  66862. }
  66863. /** @hidden */
  66864. export interface IGLTFRuntime {
  66865. extensions: {
  66866. [key: string]: any;
  66867. };
  66868. accessors: {
  66869. [key: string]: IGLTFAccessor;
  66870. };
  66871. buffers: {
  66872. [key: string]: IGLTFBuffer;
  66873. };
  66874. bufferViews: {
  66875. [key: string]: IGLTFBufferView;
  66876. };
  66877. meshes: {
  66878. [key: string]: IGLTFMesh;
  66879. };
  66880. lights: {
  66881. [key: string]: IGLTFLight;
  66882. };
  66883. cameras: {
  66884. [key: string]: IGLTFCamera;
  66885. };
  66886. nodes: {
  66887. [key: string]: IGLTFNode;
  66888. };
  66889. images: {
  66890. [key: string]: IGLTFImage;
  66891. };
  66892. textures: {
  66893. [key: string]: IGLTFTexture;
  66894. };
  66895. shaders: {
  66896. [key: string]: IGLTFShader;
  66897. };
  66898. programs: {
  66899. [key: string]: IGLTFProgram;
  66900. };
  66901. samplers: {
  66902. [key: string]: IGLTFSampler;
  66903. };
  66904. techniques: {
  66905. [key: string]: IGLTFTechnique;
  66906. };
  66907. materials: {
  66908. [key: string]: IGLTFMaterial;
  66909. };
  66910. animations: {
  66911. [key: string]: IGLTFAnimation;
  66912. };
  66913. skins: {
  66914. [key: string]: IGLTFSkins;
  66915. };
  66916. currentScene?: Object;
  66917. scenes: {
  66918. [key: string]: IGLTFScene;
  66919. };
  66920. extensionsUsed: string[];
  66921. extensionsRequired?: string[];
  66922. buffersCount: number;
  66923. shaderscount: number;
  66924. scene: Scene;
  66925. rootUrl: string;
  66926. loadedBufferCount: number;
  66927. loadedBufferViews: {
  66928. [name: string]: ArrayBufferView;
  66929. };
  66930. loadedShaderCount: number;
  66931. importOnlyMeshes: boolean;
  66932. importMeshesNames?: string[];
  66933. dummyNodes: Node[];
  66934. }
  66935. /** @hidden */
  66936. export interface INodeToRoot {
  66937. bone: Bone;
  66938. node: IGLTFNode;
  66939. id: string;
  66940. }
  66941. /** @hidden */
  66942. export interface IJointNode {
  66943. node: IGLTFNode;
  66944. id: string;
  66945. }
  66946. }
  66947. declare module BABYLON.GLTF1 {
  66948. /**
  66949. * Utils functions for GLTF
  66950. * @hidden
  66951. */
  66952. export class GLTFUtils {
  66953. /**
  66954. * Sets the given "parameter" matrix
  66955. * @param scene: the Scene object
  66956. * @param source: the source node where to pick the matrix
  66957. * @param parameter: the GLTF technique parameter
  66958. * @param uniformName: the name of the shader's uniform
  66959. * @param shaderMaterial: the shader material
  66960. */
  66961. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66962. /**
  66963. * Sets the given "parameter" matrix
  66964. * @param shaderMaterial: the shader material
  66965. * @param uniform: the name of the shader's uniform
  66966. * @param value: the value of the uniform
  66967. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66968. */
  66969. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66970. /**
  66971. * Returns the wrap mode of the texture
  66972. * @param mode: the mode value
  66973. */
  66974. static GetWrapMode(mode: number): number;
  66975. /**
  66976. * Returns the byte stride giving an accessor
  66977. * @param accessor: the GLTF accessor objet
  66978. */
  66979. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66980. /**
  66981. * Returns the texture filter mode giving a mode value
  66982. * @param mode: the filter mode value
  66983. */
  66984. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66985. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66986. /**
  66987. * Returns a buffer from its accessor
  66988. * @param gltfRuntime: the GLTF runtime
  66989. * @param accessor: the GLTF accessor
  66990. */
  66991. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66992. /**
  66993. * Decodes a buffer view into a string
  66994. * @param view: the buffer view
  66995. */
  66996. static DecodeBufferToText(view: ArrayBufferView): string;
  66997. /**
  66998. * Returns the default material of gltf. Related to
  66999. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67000. * @param scene: the Babylon.js scene
  67001. */
  67002. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67003. private static _DefaultMaterial;
  67004. }
  67005. }
  67006. declare module BABYLON.GLTF1 {
  67007. /**
  67008. * Implementation of the base glTF spec
  67009. * @hidden
  67010. */
  67011. export class GLTFLoaderBase {
  67012. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67013. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67014. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67015. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67016. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67017. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67018. }
  67019. /**
  67020. * glTF V1 Loader
  67021. * @hidden
  67022. */
  67023. export class GLTFLoader implements IGLTFLoader {
  67024. static Extensions: {
  67025. [name: string]: GLTFLoaderExtension;
  67026. };
  67027. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67028. state: Nullable<GLTFLoaderState>;
  67029. dispose(): void;
  67030. private _importMeshAsync;
  67031. /**
  67032. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67033. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67034. * @param scene the scene the meshes should be added to
  67035. * @param data gltf data containing information of the meshes in a loaded file
  67036. * @param rootUrl root url to load from
  67037. * @param onProgress event that fires when loading progress has occured
  67038. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67039. */
  67040. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67041. meshes: AbstractMesh[];
  67042. particleSystems: IParticleSystem[];
  67043. skeletons: Skeleton[];
  67044. animationGroups: AnimationGroup[];
  67045. }>;
  67046. private _loadAsync;
  67047. /**
  67048. * Imports all objects from a loaded gltf file and adds them to the scene
  67049. * @param scene the scene the objects should be added to
  67050. * @param data gltf data containing information of the meshes in a loaded file
  67051. * @param rootUrl root url to load from
  67052. * @param onProgress event that fires when loading progress has occured
  67053. * @returns a promise which completes when objects have been loaded to the scene
  67054. */
  67055. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67056. private _loadShadersAsync;
  67057. private _loadBuffersAsync;
  67058. private _createNodes;
  67059. }
  67060. /** @hidden */
  67061. export abstract class GLTFLoaderExtension {
  67062. private _name;
  67063. constructor(name: string);
  67064. readonly name: string;
  67065. /**
  67066. * Defines an override for loading the runtime
  67067. * Return true to stop further extensions from loading the runtime
  67068. */
  67069. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67070. /**
  67071. * Defines an onverride for creating gltf runtime
  67072. * Return true to stop further extensions from creating the runtime
  67073. */
  67074. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67075. /**
  67076. * Defines an override for loading buffers
  67077. * Return true to stop further extensions from loading this buffer
  67078. */
  67079. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67080. /**
  67081. * Defines an override for loading texture buffers
  67082. * Return true to stop further extensions from loading this texture data
  67083. */
  67084. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67085. /**
  67086. * Defines an override for creating textures
  67087. * Return true to stop further extensions from loading this texture
  67088. */
  67089. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67090. /**
  67091. * Defines an override for loading shader strings
  67092. * Return true to stop further extensions from loading this shader data
  67093. */
  67094. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67095. /**
  67096. * Defines an override for loading materials
  67097. * Return true to stop further extensions from loading this material
  67098. */
  67099. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67100. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67101. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67102. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67103. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67104. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67105. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67106. private static LoadTextureBufferAsync;
  67107. private static CreateTextureAsync;
  67108. private static ApplyExtensions;
  67109. }
  67110. }
  67111. declare module BABYLON.GLTF1 {
  67112. /** @hidden */
  67113. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67114. private _bin;
  67115. constructor();
  67116. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67117. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67118. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67119. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67120. }
  67121. }
  67122. declare module BABYLON.GLTF1 {
  67123. /** @hidden */
  67124. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67125. constructor();
  67126. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67127. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67128. private _loadTexture;
  67129. }
  67130. }
  67131. declare module BABYLON.GLTF2.Loader {
  67132. /**
  67133. * Loader interface with an index field.
  67134. */
  67135. export interface IArrayItem {
  67136. /**
  67137. * The index of this item in the array.
  67138. */
  67139. index: number;
  67140. }
  67141. /**
  67142. * Loader interface with additional members.
  67143. */
  67144. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67145. /** @hidden */
  67146. _data?: Promise<ArrayBufferView>;
  67147. /** @hidden */
  67148. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67149. }
  67150. /**
  67151. * Loader interface with additional members.
  67152. */
  67153. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67154. }
  67155. /** @hidden */
  67156. export interface _IAnimationSamplerData {
  67157. input: Float32Array;
  67158. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67159. output: Float32Array;
  67160. }
  67161. /**
  67162. * Loader interface with additional members.
  67163. */
  67164. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67165. /** @hidden */
  67166. _data?: Promise<_IAnimationSamplerData>;
  67167. }
  67168. /**
  67169. * Loader interface with additional members.
  67170. */
  67171. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67172. channels: IAnimationChannel[];
  67173. samplers: IAnimationSampler[];
  67174. /** @hidden */
  67175. _babylonAnimationGroup?: AnimationGroup;
  67176. }
  67177. /**
  67178. * Loader interface with additional members.
  67179. */
  67180. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67181. /** @hidden */
  67182. _data?: Promise<ArrayBufferView>;
  67183. }
  67184. /**
  67185. * Loader interface with additional members.
  67186. */
  67187. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67188. /** @hidden */
  67189. _data?: Promise<ArrayBufferView>;
  67190. /** @hidden */
  67191. _babylonBuffer?: Promise<Buffer>;
  67192. }
  67193. /**
  67194. * Loader interface with additional members.
  67195. */
  67196. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67197. }
  67198. /**
  67199. * Loader interface with additional members.
  67200. */
  67201. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67202. /** @hidden */
  67203. _data?: Promise<ArrayBufferView>;
  67204. }
  67205. /**
  67206. * Loader interface with additional members.
  67207. */
  67208. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67209. }
  67210. /**
  67211. * Loader interface with additional members.
  67212. */
  67213. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67214. }
  67215. /**
  67216. * Loader interface with additional members.
  67217. */
  67218. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67219. baseColorTexture?: ITextureInfo;
  67220. metallicRoughnessTexture?: ITextureInfo;
  67221. }
  67222. /**
  67223. * Loader interface with additional members.
  67224. */
  67225. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67226. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67227. normalTexture?: IMaterialNormalTextureInfo;
  67228. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67229. emissiveTexture?: ITextureInfo;
  67230. /** @hidden */
  67231. _data?: {
  67232. [babylonDrawMode: number]: {
  67233. babylonMaterial: Material;
  67234. babylonMeshes: AbstractMesh[];
  67235. promise: Promise<void>;
  67236. };
  67237. };
  67238. }
  67239. /**
  67240. * Loader interface with additional members.
  67241. */
  67242. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67243. primitives: IMeshPrimitive[];
  67244. }
  67245. /**
  67246. * Loader interface with additional members.
  67247. */
  67248. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67249. /** @hidden */
  67250. _instanceData?: {
  67251. babylonSourceMesh: Mesh;
  67252. promise: Promise<any>;
  67253. };
  67254. }
  67255. /**
  67256. * Loader interface with additional members.
  67257. */
  67258. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67259. /**
  67260. * The parent glTF node.
  67261. */
  67262. parent?: INode;
  67263. /** @hidden */
  67264. _babylonTransformNode?: TransformNode;
  67265. /** @hidden */
  67266. _primitiveBabylonMeshes?: AbstractMesh[];
  67267. /** @hidden */
  67268. _babylonBones?: Bone[];
  67269. /** @hidden */
  67270. _numMorphTargets?: number;
  67271. }
  67272. /** @hidden */
  67273. export interface _ISamplerData {
  67274. noMipMaps: boolean;
  67275. samplingMode: number;
  67276. wrapU: number;
  67277. wrapV: number;
  67278. }
  67279. /**
  67280. * Loader interface with additional members.
  67281. */
  67282. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67283. /** @hidden */
  67284. _data?: _ISamplerData;
  67285. }
  67286. /**
  67287. * Loader interface with additional members.
  67288. */
  67289. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67290. }
  67291. /**
  67292. * Loader interface with additional members.
  67293. */
  67294. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67295. /** @hidden */
  67296. _data?: {
  67297. babylonSkeleton: Skeleton;
  67298. promise: Promise<void>;
  67299. };
  67300. }
  67301. /**
  67302. * Loader interface with additional members.
  67303. */
  67304. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67305. }
  67306. /**
  67307. * Loader interface with additional members.
  67308. */
  67309. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67310. }
  67311. /**
  67312. * Loader interface with additional members.
  67313. */
  67314. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67315. accessors?: IAccessor[];
  67316. animations?: IAnimation[];
  67317. buffers?: IBuffer[];
  67318. bufferViews?: IBufferView[];
  67319. cameras?: ICamera[];
  67320. images?: IImage[];
  67321. materials?: IMaterial[];
  67322. meshes?: IMesh[];
  67323. nodes?: INode[];
  67324. samplers?: ISampler[];
  67325. scenes?: IScene[];
  67326. skins?: ISkin[];
  67327. textures?: ITexture[];
  67328. }
  67329. }
  67330. declare module BABYLON.GLTF2 {
  67331. /**
  67332. * Interface for a glTF loader extension.
  67333. */
  67334. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67335. /**
  67336. * Called after the loader state changes to LOADING.
  67337. */
  67338. onLoading?(): void;
  67339. /**
  67340. * Called after the loader state changes to READY.
  67341. */
  67342. onReady?(): void;
  67343. /**
  67344. * Define this method to modify the default behavior when loading scenes.
  67345. * @param context The context when loading the asset
  67346. * @param scene The glTF scene property
  67347. * @returns A promise that resolves when the load is complete or null if not handled
  67348. */
  67349. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67350. /**
  67351. * Define this method to modify the default behavior when loading nodes.
  67352. * @param context The context when loading the asset
  67353. * @param node The glTF node property
  67354. * @param assign A function called synchronously after parsing the glTF properties
  67355. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67356. */
  67357. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67358. /**
  67359. * Define this method to modify the default behavior when loading cameras.
  67360. * @param context The context when loading the asset
  67361. * @param camera The glTF camera property
  67362. * @param assign A function called synchronously after parsing the glTF properties
  67363. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67364. */
  67365. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67366. /**
  67367. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67368. * @param context The context when loading the asset
  67369. * @param primitive The glTF mesh primitive property
  67370. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67371. */
  67372. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67373. /**
  67374. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67375. * @param context The context when loading the asset
  67376. * @param name The mesh name when loading the asset
  67377. * @param node The glTF node when loading the asset
  67378. * @param mesh The glTF mesh when loading the asset
  67379. * @param primitive The glTF mesh primitive property
  67380. * @param assign A function called synchronously after parsing the glTF properties
  67381. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67382. */
  67383. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67384. /**
  67385. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67386. * @param context The context when loading the asset
  67387. * @param material The glTF material property
  67388. * @param assign A function called synchronously after parsing the glTF properties
  67389. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67390. */
  67391. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67392. /**
  67393. * Define this method to modify the default behavior when creating materials.
  67394. * @param context The context when loading the asset
  67395. * @param material The glTF material property
  67396. * @param babylonDrawMode The draw mode for the Babylon material
  67397. * @returns The Babylon material or null if not handled
  67398. */
  67399. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67400. /**
  67401. * Define this method to modify the default behavior when loading material properties.
  67402. * @param context The context when loading the asset
  67403. * @param material The glTF material property
  67404. * @param babylonMaterial The Babylon material
  67405. * @returns A promise that resolves when the load is complete or null if not handled
  67406. */
  67407. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67408. /**
  67409. * Define this method to modify the default behavior when loading texture infos.
  67410. * @param context The context when loading the asset
  67411. * @param textureInfo The glTF texture info property
  67412. * @param assign A function called synchronously after parsing the glTF properties
  67413. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67414. */
  67415. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67416. /**
  67417. * Define this method to modify the default behavior when loading animations.
  67418. * @param context The context when loading the asset
  67419. * @param animation The glTF animation property
  67420. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67421. */
  67422. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67423. /**
  67424. * @hidden Define this method to modify the default behavior when loading skins.
  67425. * @param context The context when loading the asset
  67426. * @param node The glTF node property
  67427. * @param skin The glTF skin property
  67428. * @returns A promise that resolves when the load is complete or null if not handled
  67429. */
  67430. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67431. /**
  67432. * @hidden Define this method to modify the default behavior when loading uris.
  67433. * @param context The context when loading the asset
  67434. * @param property The glTF property associated with the uri
  67435. * @param uri The uri to load
  67436. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67437. */
  67438. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67439. }
  67440. }
  67441. declare module BABYLON.GLTF2 {
  67442. /**
  67443. * Helper class for working with arrays when loading the glTF asset
  67444. */
  67445. export class ArrayItem {
  67446. /**
  67447. * Gets an item from the given array.
  67448. * @param context The context when loading the asset
  67449. * @param array The array to get the item from
  67450. * @param index The index to the array
  67451. * @returns The array item
  67452. */
  67453. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67454. /**
  67455. * Assign an `index` field to each item of the given array.
  67456. * @param array The array of items
  67457. */
  67458. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67459. }
  67460. /**
  67461. * The glTF 2.0 loader
  67462. */
  67463. export class GLTFLoader implements IGLTFLoader {
  67464. /** @hidden */
  67465. _completePromises: Promise<any>[];
  67466. private _disposed;
  67467. private _parent;
  67468. private _state;
  67469. private _extensions;
  67470. private _rootUrl;
  67471. private _fileName;
  67472. private _uniqueRootUrl;
  67473. private _gltf;
  67474. private _babylonScene;
  67475. private _rootBabylonMesh;
  67476. private _defaultBabylonMaterialData;
  67477. private _progressCallback?;
  67478. private _requests;
  67479. private static readonly _DefaultSampler;
  67480. private static _ExtensionNames;
  67481. private static _ExtensionFactories;
  67482. /**
  67483. * Registers a loader extension.
  67484. * @param name The name of the loader extension.
  67485. * @param factory The factory function that creates the loader extension.
  67486. */
  67487. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67488. /**
  67489. * Unregisters a loader extension.
  67490. * @param name The name of the loader extenion.
  67491. * @returns A boolean indicating whether the extension has been unregistered
  67492. */
  67493. static UnregisterExtension(name: string): boolean;
  67494. /**
  67495. * Gets the loader state.
  67496. */
  67497. readonly state: Nullable<GLTFLoaderState>;
  67498. /**
  67499. * The glTF object parsed from the JSON.
  67500. */
  67501. readonly gltf: IGLTF;
  67502. /**
  67503. * The Babylon scene when loading the asset.
  67504. */
  67505. readonly babylonScene: Scene;
  67506. /**
  67507. * The root Babylon mesh when loading the asset.
  67508. */
  67509. readonly rootBabylonMesh: Mesh;
  67510. /** @hidden */
  67511. constructor(parent: GLTFFileLoader);
  67512. /** @hidden */
  67513. dispose(): void;
  67514. /** @hidden */
  67515. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67516. meshes: AbstractMesh[];
  67517. particleSystems: IParticleSystem[];
  67518. skeletons: Skeleton[];
  67519. animationGroups: AnimationGroup[];
  67520. }>;
  67521. /** @hidden */
  67522. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67523. private _loadAsync;
  67524. private _loadData;
  67525. private _setupData;
  67526. private _loadExtensions;
  67527. private _checkExtensions;
  67528. private _setState;
  67529. private _createRootNode;
  67530. /**
  67531. * Loads a glTF scene.
  67532. * @param context The context when loading the asset
  67533. * @param scene The glTF scene property
  67534. * @returns A promise that resolves when the load is complete
  67535. */
  67536. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67537. private _forEachPrimitive;
  67538. private _getMeshes;
  67539. private _getSkeletons;
  67540. private _getAnimationGroups;
  67541. private _startAnimations;
  67542. /**
  67543. * Loads a glTF node.
  67544. * @param context The context when loading the asset
  67545. * @param node The glTF node property
  67546. * @param assign A function called synchronously after parsing the glTF properties
  67547. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67548. */
  67549. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67550. private _loadMeshAsync;
  67551. /**
  67552. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67553. * @param context The context when loading the asset
  67554. * @param name The mesh name when loading the asset
  67555. * @param node The glTF node when loading the asset
  67556. * @param mesh The glTF mesh when loading the asset
  67557. * @param primitive The glTF mesh primitive property
  67558. * @param assign A function called synchronously after parsing the glTF properties
  67559. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67560. */
  67561. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67562. private _loadVertexDataAsync;
  67563. private _createMorphTargets;
  67564. private _loadMorphTargetsAsync;
  67565. private _loadMorphTargetVertexDataAsync;
  67566. private static _LoadTransform;
  67567. private _loadSkinAsync;
  67568. private _loadBones;
  67569. private _loadBone;
  67570. private _loadSkinInverseBindMatricesDataAsync;
  67571. private _updateBoneMatrices;
  67572. private _getNodeMatrix;
  67573. /**
  67574. * Loads a glTF camera.
  67575. * @param context The context when loading the asset
  67576. * @param camera The glTF camera property
  67577. * @param assign A function called synchronously after parsing the glTF properties
  67578. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67579. */
  67580. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67581. private _loadAnimationsAsync;
  67582. /**
  67583. * Loads a glTF animation.
  67584. * @param context The context when loading the asset
  67585. * @param animation The glTF animation property
  67586. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67587. */
  67588. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67589. /**
  67590. * @hidden Loads a glTF animation channel.
  67591. * @param context The context when loading the asset
  67592. * @param animationContext The context of the animation when loading the asset
  67593. * @param animation The glTF animation property
  67594. * @param channel The glTF animation channel property
  67595. * @param babylonAnimationGroup The babylon animation group property
  67596. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67597. * @returns A void promise when the channel load is complete
  67598. */
  67599. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67600. private _loadAnimationSamplerAsync;
  67601. private _loadBufferAsync;
  67602. /**
  67603. * Loads a glTF buffer view.
  67604. * @param context The context when loading the asset
  67605. * @param bufferView The glTF buffer view property
  67606. * @returns A promise that resolves with the loaded data when the load is complete
  67607. */
  67608. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67609. private _loadAccessorAsync;
  67610. private _loadFloatAccessorAsync;
  67611. private _loadIndicesAccessorAsync;
  67612. private _loadVertexBufferViewAsync;
  67613. private _loadVertexAccessorAsync;
  67614. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67615. /** @hidden */
  67616. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67617. private _createDefaultMaterial;
  67618. /**
  67619. * Creates a Babylon material from a glTF material.
  67620. * @param context The context when loading the asset
  67621. * @param material The glTF material property
  67622. * @param babylonDrawMode The draw mode for the Babylon material
  67623. * @returns The Babylon material
  67624. */
  67625. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67626. /**
  67627. * Loads properties from a glTF material into a Babylon material.
  67628. * @param context The context when loading the asset
  67629. * @param material The glTF material property
  67630. * @param babylonMaterial The Babylon material
  67631. * @returns A promise that resolves when the load is complete
  67632. */
  67633. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67634. /**
  67635. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67636. * @param context The context when loading the asset
  67637. * @param material The glTF material property
  67638. * @param babylonMaterial The Babylon material
  67639. * @returns A promise that resolves when the load is complete
  67640. */
  67641. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67642. /**
  67643. * Loads the alpha properties from a glTF material into a Babylon material.
  67644. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67645. * @param context The context when loading the asset
  67646. * @param material The glTF material property
  67647. * @param babylonMaterial The Babylon material
  67648. */
  67649. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67650. /**
  67651. * Loads a glTF texture info.
  67652. * @param context The context when loading the asset
  67653. * @param textureInfo The glTF texture info property
  67654. * @param assign A function called synchronously after parsing the glTF properties
  67655. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67656. */
  67657. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67658. private _loadTextureAsync;
  67659. private _loadSampler;
  67660. /**
  67661. * Loads a glTF image.
  67662. * @param context The context when loading the asset
  67663. * @param image The glTF image property
  67664. * @returns A promise that resolves with the loaded data when the load is complete
  67665. */
  67666. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67667. /**
  67668. * Loads a glTF uri.
  67669. * @param context The context when loading the asset
  67670. * @param property The glTF property associated with the uri
  67671. * @param uri The base64 or relative uri
  67672. * @returns A promise that resolves with the loaded data when the load is complete
  67673. */
  67674. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67675. private _onProgress;
  67676. /**
  67677. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67678. * @param babylonObject the Babylon object with metadata
  67679. * @param pointer the JSON pointer
  67680. */
  67681. static AddPointerMetadata(babylonObject: {
  67682. metadata: any;
  67683. }, pointer: string): void;
  67684. private static _GetTextureWrapMode;
  67685. private static _GetTextureSamplingMode;
  67686. private static _GetTypedArrayConstructor;
  67687. private static _GetTypedArray;
  67688. private static _GetNumComponents;
  67689. private static _ValidateUri;
  67690. private static _GetDrawMode;
  67691. private _compileMaterialsAsync;
  67692. private _compileShadowGeneratorsAsync;
  67693. private _forEachExtensions;
  67694. private _applyExtensions;
  67695. private _extensionsOnLoading;
  67696. private _extensionsOnReady;
  67697. private _extensionsLoadSceneAsync;
  67698. private _extensionsLoadNodeAsync;
  67699. private _extensionsLoadCameraAsync;
  67700. private _extensionsLoadVertexDataAsync;
  67701. private _extensionsLoadMeshPrimitiveAsync;
  67702. private _extensionsLoadMaterialAsync;
  67703. private _extensionsCreateMaterial;
  67704. private _extensionsLoadMaterialPropertiesAsync;
  67705. private _extensionsLoadTextureInfoAsync;
  67706. private _extensionsLoadAnimationAsync;
  67707. private _extensionsLoadSkinAsync;
  67708. private _extensionsLoadUriAsync;
  67709. /**
  67710. * Helper method called by a loader extension to load an glTF extension.
  67711. * @param context The context when loading the asset
  67712. * @param property The glTF property to load the extension from
  67713. * @param extensionName The name of the extension to load
  67714. * @param actionAsync The action to run
  67715. * @returns The promise returned by actionAsync or null if the extension does not exist
  67716. */
  67717. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67718. /**
  67719. * Helper method called by a loader extension to load a glTF extra.
  67720. * @param context The context when loading the asset
  67721. * @param property The glTF property to load the extra from
  67722. * @param extensionName The name of the extension to load
  67723. * @param actionAsync The action to run
  67724. * @returns The promise returned by actionAsync or null if the extra does not exist
  67725. */
  67726. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67727. /**
  67728. * Increments the indentation level and logs a message.
  67729. * @param message The message to log
  67730. */
  67731. logOpen(message: string): void;
  67732. /**
  67733. * Decrements the indentation level.
  67734. */
  67735. logClose(): void;
  67736. /**
  67737. * Logs a message
  67738. * @param message The message to log
  67739. */
  67740. log(message: string): void;
  67741. /**
  67742. * Starts a performance counter.
  67743. * @param counterName The name of the performance counter
  67744. */
  67745. startPerformanceCounter(counterName: string): void;
  67746. /**
  67747. * Ends a performance counter.
  67748. * @param counterName The name of the performance counter
  67749. */
  67750. endPerformanceCounter(counterName: string): void;
  67751. }
  67752. }
  67753. declare module BABYLON.GLTF2.Loader.Extensions {
  67754. /**
  67755. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67756. */
  67757. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67758. /** The name of this extension. */
  67759. readonly name: string;
  67760. /** Defines whether this extension is enabled. */
  67761. enabled: boolean;
  67762. private _loader;
  67763. private _lights?;
  67764. /** @hidden */
  67765. constructor(loader: GLTFLoader);
  67766. /** @hidden */
  67767. dispose(): void;
  67768. /** @hidden */
  67769. onLoading(): void;
  67770. /** @hidden */
  67771. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67772. private _loadLightAsync;
  67773. }
  67774. }
  67775. declare module BABYLON.GLTF2.Loader.Extensions {
  67776. /**
  67777. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67778. */
  67779. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67780. /** The name of this extension. */
  67781. readonly name: string;
  67782. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67783. dracoCompression?: DracoCompression;
  67784. /** Defines whether this extension is enabled. */
  67785. enabled: boolean;
  67786. private _loader;
  67787. /** @hidden */
  67788. constructor(loader: GLTFLoader);
  67789. /** @hidden */
  67790. dispose(): void;
  67791. /** @hidden */
  67792. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67793. }
  67794. }
  67795. declare module BABYLON.GLTF2.Loader.Extensions {
  67796. /**
  67797. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67798. */
  67799. export class KHR_lights implements IGLTFLoaderExtension {
  67800. /** The name of this extension. */
  67801. readonly name: string;
  67802. /** Defines whether this extension is enabled. */
  67803. enabled: boolean;
  67804. private _loader;
  67805. private _lights?;
  67806. /** @hidden */
  67807. constructor(loader: GLTFLoader);
  67808. /** @hidden */
  67809. dispose(): void;
  67810. /** @hidden */
  67811. onLoading(): void;
  67812. /** @hidden */
  67813. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67814. }
  67815. }
  67816. declare module BABYLON.GLTF2.Loader.Extensions {
  67817. /**
  67818. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67819. */
  67820. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67821. /** The name of this extension. */
  67822. readonly name: string;
  67823. /** Defines whether this extension is enabled. */
  67824. enabled: boolean;
  67825. private _loader;
  67826. /** @hidden */
  67827. constructor(loader: GLTFLoader);
  67828. /** @hidden */
  67829. dispose(): void;
  67830. /** @hidden */
  67831. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67832. private _loadSpecularGlossinessPropertiesAsync;
  67833. }
  67834. }
  67835. declare module BABYLON.GLTF2.Loader.Extensions {
  67836. /**
  67837. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67838. */
  67839. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67840. /** The name of this extension. */
  67841. readonly name: string;
  67842. /** Defines whether this extension is enabled. */
  67843. enabled: boolean;
  67844. private _loader;
  67845. /** @hidden */
  67846. constructor(loader: GLTFLoader);
  67847. /** @hidden */
  67848. dispose(): void;
  67849. /** @hidden */
  67850. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67851. private _loadUnlitPropertiesAsync;
  67852. }
  67853. }
  67854. declare module BABYLON.GLTF2.Loader.Extensions {
  67855. /**
  67856. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67857. */
  67858. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67859. /** The name of this extension. */
  67860. readonly name: string;
  67861. /** Defines whether this extension is enabled. */
  67862. enabled: boolean;
  67863. private _loader;
  67864. /** @hidden */
  67865. constructor(loader: GLTFLoader);
  67866. /** @hidden */
  67867. dispose(): void;
  67868. /** @hidden */
  67869. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67870. }
  67871. }
  67872. declare module BABYLON.GLTF2.Loader.Extensions {
  67873. /**
  67874. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67875. */
  67876. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67877. /** The name of this extension. */
  67878. readonly name: string;
  67879. /** Defines whether this extension is enabled. */
  67880. enabled: boolean;
  67881. private _loader;
  67882. private _clips;
  67883. private _emitters;
  67884. /** @hidden */
  67885. constructor(loader: GLTFLoader);
  67886. /** @hidden */
  67887. dispose(): void;
  67888. /** @hidden */
  67889. onLoading(): void;
  67890. /** @hidden */
  67891. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67892. /** @hidden */
  67893. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67894. /** @hidden */
  67895. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67896. private _loadClipAsync;
  67897. private _loadEmitterAsync;
  67898. private _getEventAction;
  67899. private _loadAnimationEventAsync;
  67900. }
  67901. }
  67902. declare module BABYLON.GLTF2.Loader.Extensions {
  67903. /**
  67904. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67905. */
  67906. export class MSFT_lod implements IGLTFLoaderExtension {
  67907. /** The name of this extension. */
  67908. readonly name: string;
  67909. /** Defines whether this extension is enabled. */
  67910. enabled: boolean;
  67911. /**
  67912. * Maximum number of LODs to load, starting from the lowest LOD.
  67913. */
  67914. maxLODsToLoad: number;
  67915. /**
  67916. * Observable raised when all node LODs of one level are loaded.
  67917. * The event data is the index of the loaded LOD starting from zero.
  67918. * Dispose the loader to cancel the loading of the next level of LODs.
  67919. */
  67920. onNodeLODsLoadedObservable: Observable<number>;
  67921. /**
  67922. * Observable raised when all material LODs of one level are loaded.
  67923. * The event data is the index of the loaded LOD starting from zero.
  67924. * Dispose the loader to cancel the loading of the next level of LODs.
  67925. */
  67926. onMaterialLODsLoadedObservable: Observable<number>;
  67927. private _loader;
  67928. private _nodeIndexLOD;
  67929. private _nodeSignalLODs;
  67930. private _nodePromiseLODs;
  67931. private _materialIndexLOD;
  67932. private _materialSignalLODs;
  67933. private _materialPromiseLODs;
  67934. /** @hidden */
  67935. constructor(loader: GLTFLoader);
  67936. /** @hidden */
  67937. dispose(): void;
  67938. /** @hidden */
  67939. onReady(): void;
  67940. /** @hidden */
  67941. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67942. /** @hidden */
  67943. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67944. /** @hidden */
  67945. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67946. /**
  67947. * Gets an array of LOD properties from lowest to highest.
  67948. */
  67949. private _getLODs;
  67950. private _disposeUnusedMaterials;
  67951. }
  67952. }
  67953. declare module BABYLON.GLTF2.Loader.Extensions {
  67954. /** @hidden */
  67955. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67956. readonly name: string;
  67957. enabled: boolean;
  67958. private _loader;
  67959. constructor(loader: GLTFLoader);
  67960. dispose(): void;
  67961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67962. }
  67963. }
  67964. declare module BABYLON.GLTF2.Loader.Extensions {
  67965. /** @hidden */
  67966. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67967. readonly name: string;
  67968. enabled: boolean;
  67969. private _loader;
  67970. constructor(loader: GLTFLoader);
  67971. dispose(): void;
  67972. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67973. }
  67974. }
  67975. declare module BABYLON.GLTF2.Loader.Extensions {
  67976. /**
  67977. * Store glTF extras (if present) in BJS objects' metadata
  67978. */
  67979. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67980. /** The name of this extension. */
  67981. readonly name: string;
  67982. /** Defines whether this extension is enabled. */
  67983. enabled: boolean;
  67984. private _loader;
  67985. private _assignExtras;
  67986. /** @hidden */
  67987. constructor(loader: GLTFLoader);
  67988. /** @hidden */
  67989. dispose(): void;
  67990. /** @hidden */
  67991. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67992. /** @hidden */
  67993. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67994. /** @hidden */
  67995. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /**
  68000. * Class reading and parsing the MTL file bundled with the obj file.
  68001. */
  68002. export class MTLFileLoader {
  68003. /**
  68004. * All material loaded from the mtl will be set here
  68005. */
  68006. materials: StandardMaterial[];
  68007. /**
  68008. * This function will read the mtl file and create each material described inside
  68009. * This function could be improve by adding :
  68010. * -some component missing (Ni, Tf...)
  68011. * -including the specific options available
  68012. *
  68013. * @param scene defines the scene the material will be created in
  68014. * @param data defines the mtl data to parse
  68015. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68016. */
  68017. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68018. /**
  68019. * Gets the texture for the material.
  68020. *
  68021. * If the material is imported from input file,
  68022. * We sanitize the url to ensure it takes the textre from aside the material.
  68023. *
  68024. * @param rootUrl The root url to load from
  68025. * @param value The value stored in the mtl
  68026. * @return The Texture
  68027. */
  68028. private static _getTexture;
  68029. }
  68030. /**
  68031. * Options for loading OBJ/MTL files
  68032. */
  68033. type MeshLoadOptions = {
  68034. /**
  68035. * Defines if UVs are optimized by default during load.
  68036. */
  68037. OptimizeWithUV: boolean;
  68038. /**
  68039. * Defines custom scaling of UV coordinates of loaded meshes.
  68040. */
  68041. UVScaling: Vector2;
  68042. /**
  68043. * Invert model on y-axis (does a model scaling inversion)
  68044. */
  68045. InvertY: boolean;
  68046. /**
  68047. * Invert Y-Axis of referenced textures on load
  68048. */
  68049. InvertTextureY: boolean;
  68050. /**
  68051. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68052. */
  68053. ImportVertexColors: boolean;
  68054. /**
  68055. * Compute the normals for the model, even if normals are present in the file.
  68056. */
  68057. ComputeNormals: boolean;
  68058. /**
  68059. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68060. */
  68061. SkipMaterials: boolean;
  68062. /**
  68063. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68064. */
  68065. MaterialLoadingFailsSilently: boolean;
  68066. };
  68067. /**
  68068. * OBJ file type loader.
  68069. * This is a babylon scene loader plugin.
  68070. */
  68071. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68072. /**
  68073. * Defines if UVs are optimized by default during load.
  68074. */
  68075. static OPTIMIZE_WITH_UV: boolean;
  68076. /**
  68077. * Invert model on y-axis (does a model scaling inversion)
  68078. */
  68079. static INVERT_Y: boolean;
  68080. /**
  68081. * Invert Y-Axis of referenced textures on load
  68082. */
  68083. static INVERT_TEXTURE_Y: boolean;
  68084. /**
  68085. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68086. */
  68087. static IMPORT_VERTEX_COLORS: boolean;
  68088. /**
  68089. * Compute the normals for the model, even if normals are present in the file.
  68090. */
  68091. static COMPUTE_NORMALS: boolean;
  68092. /**
  68093. * Defines custom scaling of UV coordinates of loaded meshes.
  68094. */
  68095. static UV_SCALING: Vector2;
  68096. /**
  68097. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68098. */
  68099. static SKIP_MATERIALS: boolean;
  68100. /**
  68101. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68102. *
  68103. * Defaults to true for backwards compatibility.
  68104. */
  68105. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68106. /**
  68107. * Defines the name of the plugin.
  68108. */
  68109. name: string;
  68110. /**
  68111. * Defines the extension the plugin is able to load.
  68112. */
  68113. extensions: string;
  68114. /** @hidden */
  68115. obj: RegExp;
  68116. /** @hidden */
  68117. group: RegExp;
  68118. /** @hidden */
  68119. mtllib: RegExp;
  68120. /** @hidden */
  68121. usemtl: RegExp;
  68122. /** @hidden */
  68123. smooth: RegExp;
  68124. /** @hidden */
  68125. vertexPattern: RegExp;
  68126. /** @hidden */
  68127. normalPattern: RegExp;
  68128. /** @hidden */
  68129. uvPattern: RegExp;
  68130. /** @hidden */
  68131. facePattern1: RegExp;
  68132. /** @hidden */
  68133. facePattern2: RegExp;
  68134. /** @hidden */
  68135. facePattern3: RegExp;
  68136. /** @hidden */
  68137. facePattern4: RegExp;
  68138. /** @hidden */
  68139. facePattern5: RegExp;
  68140. private _meshLoadOptions;
  68141. /**
  68142. * Creates loader for .OBJ files
  68143. *
  68144. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68145. */
  68146. constructor(meshLoadOptions?: MeshLoadOptions);
  68147. private static readonly currentMeshLoadOptions;
  68148. /**
  68149. * Calls synchronously the MTL file attached to this obj.
  68150. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68151. * Without this function materials are not displayed in the first frame (but displayed after).
  68152. * In consequence it is impossible to get material information in your HTML file
  68153. *
  68154. * @param url The URL of the MTL file
  68155. * @param rootUrl
  68156. * @param onSuccess Callback function to be called when the MTL file is loaded
  68157. * @private
  68158. */
  68159. private _loadMTL;
  68160. /**
  68161. * Instantiates a OBJ file loader plugin.
  68162. * @returns the created plugin
  68163. */
  68164. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68165. /**
  68166. * If the data string can be loaded directly.
  68167. *
  68168. * @param data string containing the file data
  68169. * @returns if the data can be loaded directly
  68170. */
  68171. canDirectLoad(data: string): boolean;
  68172. /**
  68173. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68174. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68175. * @param scene the scene the meshes should be added to
  68176. * @param data the OBJ data to load
  68177. * @param rootUrl root url to load from
  68178. * @param onProgress event that fires when loading progress has occured
  68179. * @param fileName Defines the name of the file to load
  68180. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68181. */
  68182. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68183. meshes: AbstractMesh[];
  68184. particleSystems: IParticleSystem[];
  68185. skeletons: Skeleton[];
  68186. animationGroups: AnimationGroup[];
  68187. }>;
  68188. /**
  68189. * Imports all objects from the loaded OBJ data and adds them to the scene
  68190. * @param scene the scene the objects should be added to
  68191. * @param data the OBJ data to load
  68192. * @param rootUrl root url to load from
  68193. * @param onProgress event that fires when loading progress has occured
  68194. * @param fileName Defines the name of the file to load
  68195. * @returns a promise which completes when objects have been loaded to the scene
  68196. */
  68197. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68198. /**
  68199. * Load into an asset container.
  68200. * @param scene The scene to load into
  68201. * @param data The data to import
  68202. * @param rootUrl The root url for scene and resources
  68203. * @param onProgress The callback when the load progresses
  68204. * @param fileName Defines the name of the file to load
  68205. * @returns The loaded asset container
  68206. */
  68207. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68208. /**
  68209. * Read the OBJ file and create an Array of meshes.
  68210. * Each mesh contains all information given by the OBJ and the MTL file.
  68211. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68212. *
  68213. * @param meshesNames
  68214. * @param scene Scene The scene where are displayed the data
  68215. * @param data String The content of the obj file
  68216. * @param rootUrl String The path to the folder
  68217. * @returns Array<AbstractMesh>
  68218. * @private
  68219. */
  68220. private _parseSolid;
  68221. }
  68222. }
  68223. declare module BABYLON {
  68224. /**
  68225. * STL file type loader.
  68226. * This is a babylon scene loader plugin.
  68227. */
  68228. export class STLFileLoader implements ISceneLoaderPlugin {
  68229. /** @hidden */
  68230. solidPattern: RegExp;
  68231. /** @hidden */
  68232. facetsPattern: RegExp;
  68233. /** @hidden */
  68234. normalPattern: RegExp;
  68235. /** @hidden */
  68236. vertexPattern: RegExp;
  68237. /**
  68238. * Defines the name of the plugin.
  68239. */
  68240. name: string;
  68241. /**
  68242. * Defines the extensions the stl loader is able to load.
  68243. * force data to come in as an ArrayBuffer
  68244. * we'll convert to string if it looks like it's an ASCII .stl
  68245. */
  68246. extensions: ISceneLoaderPluginExtensions;
  68247. /**
  68248. * Import meshes into a scene.
  68249. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68250. * @param scene The scene to import into
  68251. * @param data The data to import
  68252. * @param rootUrl The root url for scene and resources
  68253. * @param meshes The meshes array to import into
  68254. * @param particleSystems The particle systems array to import into
  68255. * @param skeletons The skeletons array to import into
  68256. * @param onError The callback when import fails
  68257. * @returns True if successful or false otherwise
  68258. */
  68259. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68260. /**
  68261. * Load into a scene.
  68262. * @param scene The scene to load into
  68263. * @param data The data to import
  68264. * @param rootUrl The root url for scene and resources
  68265. * @param onError The callback when import fails
  68266. * @returns true if successful or false otherwise
  68267. */
  68268. load(scene: Scene, data: any, rootUrl: string): boolean;
  68269. /**
  68270. * Load into an asset container.
  68271. * @param scene The scene to load into
  68272. * @param data The data to import
  68273. * @param rootUrl The root url for scene and resources
  68274. * @param onError The callback when import fails
  68275. * @returns The loaded asset container
  68276. */
  68277. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68278. private _isBinary;
  68279. private _parseBinary;
  68280. private _parseASCII;
  68281. }
  68282. }
  68283. declare module BABYLON {
  68284. /**
  68285. * Class for generating OBJ data from a Babylon scene.
  68286. */
  68287. export class OBJExport {
  68288. /**
  68289. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68290. * @param mesh defines the list of meshes to serialize
  68291. * @param materials defines if materials should be exported
  68292. * @param matlibname defines the name of the associated mtl file
  68293. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68294. * @returns the OBJ content
  68295. */
  68296. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68297. /**
  68298. * Exports the material(s) of a mesh in .MTL file format (text)
  68299. * @param mesh defines the mesh to extract the material from
  68300. * @returns the mtl content
  68301. */
  68302. static MTL(mesh: Mesh): string;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export var __IGLTFExporterExtension: number;
  68308. /**
  68309. * Interface for extending the exporter
  68310. * @hidden
  68311. */
  68312. export interface IGLTFExporterExtension {
  68313. /**
  68314. * The name of this extension
  68315. */
  68316. readonly name: string;
  68317. /**
  68318. * Defines whether this extension is enabled
  68319. */
  68320. enabled: boolean;
  68321. /**
  68322. * Defines whether this extension is required
  68323. */
  68324. required: boolean;
  68325. }
  68326. }
  68327. declare module BABYLON.GLTF2.Exporter {
  68328. /** @hidden */
  68329. export var __IGLTFExporterExtensionV2: number;
  68330. /**
  68331. * Interface for a glTF exporter extension
  68332. * @hidden
  68333. */
  68334. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68335. /**
  68336. * Define this method to modify the default behavior before exporting a texture
  68337. * @param context The context when loading the asset
  68338. * @param babylonTexture The glTF texture info property
  68339. * @param mimeType The mime-type of the generated image
  68340. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68341. */
  68342. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68343. /**
  68344. * Define this method to modify the default behavior when exporting texture info
  68345. * @param context The context when loading the asset
  68346. * @param meshPrimitive glTF mesh primitive
  68347. * @param babylonSubMesh Babylon submesh
  68348. * @param binaryWriter glTF serializer binary writer instance
  68349. * @returns nullable IMeshPrimitive promise
  68350. */
  68351. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68352. /**
  68353. * Define this method to modify the default behavior when exporting a node
  68354. * @param context The context when exporting the node
  68355. * @param node glTF node
  68356. * @param babylonNode BabylonJS node
  68357. * @returns nullable INode promise
  68358. */
  68359. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68360. /**
  68361. * Called after the exporter state changes to EXPORTING
  68362. */
  68363. onExporting?(): void;
  68364. }
  68365. }
  68366. declare module BABYLON.GLTF2.Exporter {
  68367. /**
  68368. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68369. * @hidden
  68370. */
  68371. export class _GLTFMaterialExporter {
  68372. /**
  68373. * Represents the dielectric specular values for R, G and B
  68374. */
  68375. private static readonly _DielectricSpecular;
  68376. /**
  68377. * Allows the maximum specular power to be defined for material calculations
  68378. */
  68379. private static readonly _MaxSpecularPower;
  68380. /**
  68381. * Mapping to store textures
  68382. */
  68383. private _textureMap;
  68384. /**
  68385. * Numeric tolerance value
  68386. */
  68387. private static readonly _Epsilon;
  68388. /**
  68389. * Reference to the glTF Exporter
  68390. */
  68391. private _exporter;
  68392. constructor(exporter: _Exporter);
  68393. /**
  68394. * Specifies if two colors are approximately equal in value
  68395. * @param color1 first color to compare to
  68396. * @param color2 second color to compare to
  68397. * @param epsilon threshold value
  68398. */
  68399. private static FuzzyEquals;
  68400. /**
  68401. * Gets the materials from a Babylon scene and converts them to glTF materials
  68402. * @param scene babylonjs scene
  68403. * @param mimeType texture mime type
  68404. * @param images array of images
  68405. * @param textures array of textures
  68406. * @param materials array of materials
  68407. * @param imageData mapping of texture names to base64 textures
  68408. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68409. */
  68410. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68411. /**
  68412. * Makes a copy of the glTF material without the texture parameters
  68413. * @param originalMaterial original glTF material
  68414. * @returns glTF material without texture parameters
  68415. */
  68416. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68417. /**
  68418. * Specifies if the material has any texture parameters present
  68419. * @param material glTF Material
  68420. * @returns boolean specifying if texture parameters are present
  68421. */
  68422. _hasTexturesPresent(material: IMaterial): boolean;
  68423. /**
  68424. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68425. * @param babylonStandardMaterial
  68426. * @returns glTF Metallic Roughness Material representation
  68427. */
  68428. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68429. /**
  68430. * Computes the metallic factor
  68431. * @param diffuse diffused value
  68432. * @param specular specular value
  68433. * @param oneMinusSpecularStrength one minus the specular strength
  68434. * @returns metallic value
  68435. */
  68436. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68437. /**
  68438. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68439. * @param glTFMaterial glTF material
  68440. * @param babylonMaterial Babylon material
  68441. */
  68442. private static _SetAlphaMode;
  68443. /**
  68444. * Converts a Babylon Standard Material to a glTF Material
  68445. * @param babylonStandardMaterial BJS Standard Material
  68446. * @param mimeType mime type to use for the textures
  68447. * @param images array of glTF image interfaces
  68448. * @param textures array of glTF texture interfaces
  68449. * @param materials array of glTF material interfaces
  68450. * @param imageData map of image file name to data
  68451. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68452. */
  68453. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68454. /**
  68455. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68456. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68457. * @param mimeType mime type to use for the textures
  68458. * @param images array of glTF image interfaces
  68459. * @param textures array of glTF texture interfaces
  68460. * @param materials array of glTF material interfaces
  68461. * @param imageData map of image file name to data
  68462. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68463. */
  68464. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68465. /**
  68466. * Converts an image typed array buffer to a base64 image
  68467. * @param buffer typed array buffer
  68468. * @param width width of the image
  68469. * @param height height of the image
  68470. * @param mimeType mimetype of the image
  68471. * @returns base64 image string
  68472. */
  68473. private _createBase64FromCanvasAsync;
  68474. /**
  68475. * Generates a white texture based on the specified width and height
  68476. * @param width width of the texture in pixels
  68477. * @param height height of the texture in pixels
  68478. * @param scene babylonjs scene
  68479. * @returns white texture
  68480. */
  68481. private _createWhiteTexture;
  68482. /**
  68483. * 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
  68484. * @param texture1 first texture to resize
  68485. * @param texture2 second texture to resize
  68486. * @param scene babylonjs scene
  68487. * @returns resized textures or null
  68488. */
  68489. private _resizeTexturesToSameDimensions;
  68490. /**
  68491. * Converts an array of pixels to a Float32Array
  68492. * Throws an error if the pixel format is not supported
  68493. * @param pixels - array buffer containing pixel values
  68494. * @returns Float32 of pixels
  68495. */
  68496. private _convertPixelArrayToFloat32;
  68497. /**
  68498. * Convert Specular Glossiness Textures to Metallic Roughness
  68499. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68500. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68501. * @param diffuseTexture texture used to store diffuse information
  68502. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68503. * @param factors specular glossiness material factors
  68504. * @param mimeType the mime type to use for the texture
  68505. * @returns pbr metallic roughness interface or null
  68506. */
  68507. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68508. /**
  68509. * Converts specular glossiness material properties to metallic roughness
  68510. * @param specularGlossiness interface with specular glossiness material properties
  68511. * @returns interface with metallic roughness material properties
  68512. */
  68513. private _convertSpecularGlossinessToMetallicRoughness;
  68514. /**
  68515. * Calculates the surface reflectance, independent of lighting conditions
  68516. * @param color Color source to calculate brightness from
  68517. * @returns number representing the perceived brightness, or zero if color is undefined
  68518. */
  68519. private _getPerceivedBrightness;
  68520. /**
  68521. * Returns the maximum color component value
  68522. * @param color
  68523. * @returns maximum color component value, or zero if color is null or undefined
  68524. */
  68525. private _getMaxComponent;
  68526. /**
  68527. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68528. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68529. * @param mimeType mime type to use for the textures
  68530. * @param images array of glTF image interfaces
  68531. * @param textures array of glTF texture interfaces
  68532. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68533. * @param imageData map of image file name to data
  68534. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68535. * @returns glTF PBR Metallic Roughness factors
  68536. */
  68537. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68538. private _getGLTFTextureSampler;
  68539. private _getGLTFTextureWrapMode;
  68540. private _getGLTFTextureWrapModesSampler;
  68541. /**
  68542. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68543. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68544. * @param mimeType mime type to use for the textures
  68545. * @param images array of glTF image interfaces
  68546. * @param textures array of glTF texture interfaces
  68547. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68548. * @param imageData map of image file name to data
  68549. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68550. * @returns glTF PBR Metallic Roughness factors
  68551. */
  68552. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68553. /**
  68554. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68555. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68556. * @param mimeType mime type to use for the textures
  68557. * @param images array of glTF image interfaces
  68558. * @param textures array of glTF texture interfaces
  68559. * @param materials array of glTF material interfaces
  68560. * @param imageData map of image file name to data
  68561. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68562. */
  68563. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68564. private setMetallicRoughnessPbrMaterial;
  68565. private getPixelsFromTexture;
  68566. /**
  68567. * Extracts a texture from a Babylon texture into file data and glTF data
  68568. * @param babylonTexture Babylon texture to extract
  68569. * @param mimeType Mime Type of the babylonTexture
  68570. * @return glTF texture info, or null if the texture format is not supported
  68571. */
  68572. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68573. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68574. /**
  68575. * Builds a texture from base64 string
  68576. * @param base64Texture base64 texture string
  68577. * @param baseTextureName Name to use for the texture
  68578. * @param mimeType image mime type for the texture
  68579. * @param images array of images
  68580. * @param textures array of textures
  68581. * @param imageData map of image data
  68582. * @returns glTF texture info, or null if the texture format is not supported
  68583. */
  68584. private _getTextureInfoFromBase64;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * Class for holding and downloading glTF file data
  68590. */
  68591. export class GLTFData {
  68592. /**
  68593. * Object which contains the file name as the key and its data as the value
  68594. */
  68595. glTFFiles: {
  68596. [fileName: string]: string | Blob;
  68597. };
  68598. /**
  68599. * Initializes the glTF file object
  68600. */
  68601. constructor();
  68602. /**
  68603. * Downloads the glTF data as files based on their names and data
  68604. */
  68605. downloadFiles(): void;
  68606. }
  68607. }
  68608. declare module BABYLON {
  68609. /**
  68610. * Holds a collection of exporter options and parameters
  68611. */
  68612. export interface IExportOptions {
  68613. /**
  68614. * Function which indicates whether a babylon node should be exported or not
  68615. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68616. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68617. */
  68618. shouldExportNode?(node: Node): boolean;
  68619. /**
  68620. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68621. * @param metadata source metadata to read from
  68622. * @returns the data to store to glTF node extras
  68623. */
  68624. metadataSelector?(metadata: any): any;
  68625. /**
  68626. * The sample rate to bake animation curves
  68627. */
  68628. animationSampleRate?: number;
  68629. /**
  68630. * Begin serialization without waiting for the scene to be ready
  68631. */
  68632. exportWithoutWaitingForScene?: boolean;
  68633. }
  68634. /**
  68635. * Class for generating glTF data from a Babylon scene.
  68636. */
  68637. export class GLTF2Export {
  68638. /**
  68639. * Exports the geometry of the scene to .gltf file format asynchronously
  68640. * @param scene Babylon scene with scene hierarchy information
  68641. * @param filePrefix File prefix to use when generating the glTF file
  68642. * @param options Exporter options
  68643. * @returns Returns an object with a .gltf file and associates texture names
  68644. * as keys and their data and paths as values
  68645. */
  68646. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68647. private static _PreExportAsync;
  68648. private static _PostExportAsync;
  68649. /**
  68650. * Exports the geometry of the scene to .glb file format asychronously
  68651. * @param scene Babylon scene with scene hierarchy information
  68652. * @param filePrefix File prefix to use when generating glb file
  68653. * @param options Exporter options
  68654. * @returns Returns an object with a .glb filename as key and data as value
  68655. */
  68656. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68657. }
  68658. }
  68659. declare module BABYLON.GLTF2.Exporter {
  68660. /**
  68661. * @hidden
  68662. */
  68663. export class _GLTFUtilities {
  68664. /**
  68665. * Creates a buffer view based on the supplied arguments
  68666. * @param bufferIndex index value of the specified buffer
  68667. * @param byteOffset byte offset value
  68668. * @param byteLength byte length of the bufferView
  68669. * @param byteStride byte distance between conequential elements
  68670. * @param name name of the buffer view
  68671. * @returns bufferView for glTF
  68672. */
  68673. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68674. /**
  68675. * Creates an accessor based on the supplied arguments
  68676. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68677. * @param name The name of the accessor
  68678. * @param type The type of the accessor
  68679. * @param componentType The datatype of components in the attribute
  68680. * @param count The number of attributes referenced by this accessor
  68681. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68682. * @param min Minimum value of each component in this attribute
  68683. * @param max Maximum value of each component in this attribute
  68684. * @returns accessor for glTF
  68685. */
  68686. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68687. /**
  68688. * Calculates the minimum and maximum values of an array of position floats
  68689. * @param positions Positions array of a mesh
  68690. * @param vertexStart Starting vertex offset to calculate min and max values
  68691. * @param vertexCount Number of vertices to check for min and max values
  68692. * @returns min number array and max number array
  68693. */
  68694. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68695. min: number[];
  68696. max: number[];
  68697. };
  68698. /**
  68699. * Converts a new right-handed Vector3
  68700. * @param vector vector3 array
  68701. * @returns right-handed Vector3
  68702. */
  68703. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68704. /**
  68705. * Converts a Vector3 to right-handed
  68706. * @param vector Vector3 to convert to right-handed
  68707. */
  68708. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68709. /**
  68710. * Converts a three element number array to right-handed
  68711. * @param vector number array to convert to right-handed
  68712. */
  68713. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68714. /**
  68715. * Converts a new right-handed Vector3
  68716. * @param vector vector3 array
  68717. * @returns right-handed Vector3
  68718. */
  68719. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68720. /**
  68721. * Converts a Vector3 to right-handed
  68722. * @param vector Vector3 to convert to right-handed
  68723. */
  68724. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68725. /**
  68726. * Converts a three element number array to right-handed
  68727. * @param vector number array to convert to right-handed
  68728. */
  68729. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68730. /**
  68731. * Converts a Vector4 to right-handed
  68732. * @param vector Vector4 to convert to right-handed
  68733. */
  68734. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68735. /**
  68736. * Converts a Vector4 to right-handed
  68737. * @param vector Vector4 to convert to right-handed
  68738. */
  68739. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68740. /**
  68741. * Converts a Quaternion to right-handed
  68742. * @param quaternion Source quaternion to convert to right-handed
  68743. */
  68744. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68745. /**
  68746. * Converts a Quaternion to right-handed
  68747. * @param quaternion Source quaternion to convert to right-handed
  68748. */
  68749. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68750. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68751. }
  68752. }
  68753. declare module BABYLON.GLTF2.Exporter {
  68754. /**
  68755. * Converts Babylon Scene into glTF 2.0.
  68756. * @hidden
  68757. */
  68758. export class _Exporter {
  68759. /**
  68760. * Stores the glTF to export
  68761. */
  68762. _glTF: IGLTF;
  68763. /**
  68764. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68765. */
  68766. _bufferViews: IBufferView[];
  68767. /**
  68768. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68769. */
  68770. _accessors: IAccessor[];
  68771. /**
  68772. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68773. */
  68774. private _nodes;
  68775. /**
  68776. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68777. */
  68778. private _scenes;
  68779. /**
  68780. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68781. */
  68782. private _meshes;
  68783. /**
  68784. * Stores all the generated material information, which represents the appearance of each primitive
  68785. */
  68786. _materials: IMaterial[];
  68787. _materialMap: {
  68788. [materialID: number]: number;
  68789. };
  68790. /**
  68791. * Stores all the generated texture information, which is referenced by glTF materials
  68792. */
  68793. _textures: ITexture[];
  68794. /**
  68795. * Stores all the generated image information, which is referenced by glTF textures
  68796. */
  68797. _images: IImage[];
  68798. /**
  68799. * Stores all the texture samplers
  68800. */
  68801. _samplers: ISampler[];
  68802. /**
  68803. * Stores all the generated animation samplers, which is referenced by glTF animations
  68804. */
  68805. /**
  68806. * Stores the animations for glTF models
  68807. */
  68808. private _animations;
  68809. /**
  68810. * Stores the total amount of bytes stored in the glTF buffer
  68811. */
  68812. private _totalByteLength;
  68813. /**
  68814. * Stores a reference to the Babylon scene containing the source geometry and material information
  68815. */
  68816. _babylonScene: Scene;
  68817. /**
  68818. * Stores a map of the image data, where the key is the file name and the value
  68819. * is the image data
  68820. */
  68821. _imageData: {
  68822. [fileName: string]: {
  68823. data: Uint8Array;
  68824. mimeType: ImageMimeType;
  68825. };
  68826. };
  68827. /**
  68828. * Stores a map of the unique id of a node to its index in the node array
  68829. */
  68830. private _nodeMap;
  68831. /**
  68832. * Specifies if the Babylon scene should be converted to right-handed on export
  68833. */
  68834. _convertToRightHandedSystem: boolean;
  68835. /**
  68836. * Baked animation sample rate
  68837. */
  68838. private _animationSampleRate;
  68839. private _options;
  68840. private _localEngine;
  68841. _glTFMaterialExporter: _GLTFMaterialExporter;
  68842. private _extensions;
  68843. private static _ExtensionNames;
  68844. private static _ExtensionFactories;
  68845. private _applyExtensions;
  68846. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68847. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68848. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68849. private _forEachExtensions;
  68850. private _extensionsOnExporting;
  68851. /**
  68852. * Load glTF serializer extensions
  68853. */
  68854. private _loadExtensions;
  68855. /**
  68856. * Creates a glTF Exporter instance, which can accept optional exporter options
  68857. * @param babylonScene Babylon scene object
  68858. * @param options Options to modify the behavior of the exporter
  68859. */
  68860. constructor(babylonScene: Scene, options?: IExportOptions);
  68861. /**
  68862. * Registers a glTF exporter extension
  68863. * @param name Name of the extension to export
  68864. * @param factory The factory function that creates the exporter extension
  68865. */
  68866. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68867. /**
  68868. * Un-registers an exporter extension
  68869. * @param name The name fo the exporter extension
  68870. * @returns A boolean indicating whether the extension has been un-registered
  68871. */
  68872. static UnregisterExtension(name: string): boolean;
  68873. /**
  68874. * Lazy load a local engine with premultiplied alpha set to false
  68875. */
  68876. _getLocalEngine(): Engine;
  68877. private reorderIndicesBasedOnPrimitiveMode;
  68878. /**
  68879. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68880. * clock-wise during export to glTF
  68881. * @param submesh BabylonJS submesh
  68882. * @param primitiveMode Primitive mode of the mesh
  68883. * @param sideOrientation the winding order of the submesh
  68884. * @param vertexBufferKind The type of vertex attribute
  68885. * @param meshAttributeArray The vertex attribute data
  68886. * @param byteOffset The offset to the binary data
  68887. * @param binaryWriter The binary data for the glTF file
  68888. */
  68889. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68890. /**
  68891. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68892. * clock-wise during export to glTF
  68893. * @param submesh BabylonJS submesh
  68894. * @param primitiveMode Primitive mode of the mesh
  68895. * @param sideOrientation the winding order of the submesh
  68896. * @param vertexBufferKind The type of vertex attribute
  68897. * @param meshAttributeArray The vertex attribute data
  68898. * @param byteOffset The offset to the binary data
  68899. * @param binaryWriter The binary data for the glTF file
  68900. */
  68901. private reorderTriangleFillMode;
  68902. /**
  68903. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68904. * clock-wise during export to glTF
  68905. * @param submesh BabylonJS submesh
  68906. * @param primitiveMode Primitive mode of the mesh
  68907. * @param sideOrientation the winding order of the submesh
  68908. * @param vertexBufferKind The type of vertex attribute
  68909. * @param meshAttributeArray The vertex attribute data
  68910. * @param byteOffset The offset to the binary data
  68911. * @param binaryWriter The binary data for the glTF file
  68912. */
  68913. private reorderTriangleStripDrawMode;
  68914. /**
  68915. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68916. * clock-wise during export to glTF
  68917. * @param submesh BabylonJS submesh
  68918. * @param primitiveMode Primitive mode of the mesh
  68919. * @param sideOrientation the winding order of the submesh
  68920. * @param vertexBufferKind The type of vertex attribute
  68921. * @param meshAttributeArray The vertex attribute data
  68922. * @param byteOffset The offset to the binary data
  68923. * @param binaryWriter The binary data for the glTF file
  68924. */
  68925. private reorderTriangleFanMode;
  68926. /**
  68927. * Writes the vertex attribute data to binary
  68928. * @param vertices The vertices to write to the binary writer
  68929. * @param byteOffset The offset into the binary writer to overwrite binary data
  68930. * @param vertexAttributeKind The vertex attribute type
  68931. * @param meshAttributeArray The vertex attribute data
  68932. * @param binaryWriter The writer containing the binary data
  68933. */
  68934. private writeVertexAttributeData;
  68935. /**
  68936. * Writes mesh attribute data to a data buffer
  68937. * Returns the bytelength of the data
  68938. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68939. * @param meshAttributeArray Array containing the attribute data
  68940. * @param binaryWriter The buffer to write the binary data to
  68941. * @param indices Used to specify the order of the vertex data
  68942. */
  68943. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68944. /**
  68945. * Generates glTF json data
  68946. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68947. * @param glTFPrefix Text to use when prefixing a glTF file
  68948. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68949. * @returns json data as string
  68950. */
  68951. private generateJSON;
  68952. /**
  68953. * Generates data for .gltf and .bin files based on the glTF prefix string
  68954. * @param glTFPrefix Text to use when prefixing a glTF file
  68955. * @returns GLTFData with glTF file data
  68956. */
  68957. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68958. /**
  68959. * Creates a binary buffer for glTF
  68960. * @returns array buffer for binary data
  68961. */
  68962. private _generateBinaryAsync;
  68963. /**
  68964. * Pads the number to a multiple of 4
  68965. * @param num number to pad
  68966. * @returns padded number
  68967. */
  68968. private _getPadding;
  68969. /**
  68970. * Generates a glb file from the json and binary data
  68971. * Returns an object with the glb file name as the key and data as the value
  68972. * @param glTFPrefix
  68973. * @returns object with glb filename as key and data as value
  68974. */
  68975. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68976. /**
  68977. * Sets the TRS for each node
  68978. * @param node glTF Node for storing the transformation data
  68979. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68980. */
  68981. private setNodeTransformation;
  68982. private getVertexBufferFromMesh;
  68983. /**
  68984. * Creates a bufferview based on the vertices type for the Babylon mesh
  68985. * @param kind Indicates the type of vertices data
  68986. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68987. * @param binaryWriter The buffer to write the bufferview data to
  68988. */
  68989. private createBufferViewKind;
  68990. /**
  68991. * The primitive mode of the Babylon mesh
  68992. * @param babylonMesh The BabylonJS mesh
  68993. */
  68994. private getMeshPrimitiveMode;
  68995. /**
  68996. * Sets the primitive mode of the glTF mesh primitive
  68997. * @param meshPrimitive glTF mesh primitive
  68998. * @param primitiveMode The primitive mode
  68999. */
  69000. private setPrimitiveMode;
  69001. /**
  69002. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69003. * @param meshPrimitive glTF mesh primitive
  69004. * @param attributeKind vertex attribute
  69005. * @returns boolean specifying if uv coordinates are present
  69006. */
  69007. private setAttributeKind;
  69008. /**
  69009. * Sets data for the primitive attributes of each submesh
  69010. * @param mesh glTF Mesh object to store the primitive attribute information
  69011. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69012. * @param binaryWriter Buffer to write the attribute data to
  69013. */
  69014. private setPrimitiveAttributesAsync;
  69015. /**
  69016. * Creates a glTF scene based on the array of meshes
  69017. * Returns the the total byte offset
  69018. * @param babylonScene Babylon scene to get the mesh data from
  69019. * @param binaryWriter Buffer to write binary data to
  69020. */
  69021. private createSceneAsync;
  69022. /**
  69023. * Creates a mapping of Node unique id to node index and handles animations
  69024. * @param babylonScene Babylon Scene
  69025. * @param nodes Babylon transform nodes
  69026. * @param binaryWriter Buffer to write binary data to
  69027. * @returns Node mapping of unique id to index
  69028. */
  69029. private createNodeMapAndAnimationsAsync;
  69030. /**
  69031. * Creates a glTF node from a Babylon mesh
  69032. * @param babylonMesh Source Babylon mesh
  69033. * @param binaryWriter Buffer for storing geometry data
  69034. * @returns glTF node
  69035. */
  69036. private createNodeAsync;
  69037. }
  69038. /**
  69039. * @hidden
  69040. *
  69041. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69042. */
  69043. export class _BinaryWriter {
  69044. /**
  69045. * Array buffer which stores all binary data
  69046. */
  69047. private _arrayBuffer;
  69048. /**
  69049. * View of the array buffer
  69050. */
  69051. private _dataView;
  69052. /**
  69053. * byte offset of data in array buffer
  69054. */
  69055. private _byteOffset;
  69056. /**
  69057. * Initialize binary writer with an initial byte length
  69058. * @param byteLength Initial byte length of the array buffer
  69059. */
  69060. constructor(byteLength: number);
  69061. /**
  69062. * Resize the array buffer to the specified byte length
  69063. * @param byteLength
  69064. */
  69065. private resizeBuffer;
  69066. /**
  69067. * Get an array buffer with the length of the byte offset
  69068. * @returns ArrayBuffer resized to the byte offset
  69069. */
  69070. getArrayBuffer(): ArrayBuffer;
  69071. /**
  69072. * Get the byte offset of the array buffer
  69073. * @returns byte offset
  69074. */
  69075. getByteOffset(): number;
  69076. /**
  69077. * Stores an UInt8 in the array buffer
  69078. * @param entry
  69079. * @param byteOffset If defined, specifies where to set the value as an offset.
  69080. */
  69081. setUInt8(entry: number, byteOffset?: number): void;
  69082. /**
  69083. * Gets an UInt32 in the array buffer
  69084. * @param entry
  69085. * @param byteOffset If defined, specifies where to set the value as an offset.
  69086. */
  69087. getUInt32(byteOffset: number): number;
  69088. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69089. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69090. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69091. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69092. /**
  69093. * Stores a Float32 in the array buffer
  69094. * @param entry
  69095. */
  69096. setFloat32(entry: number, byteOffset?: number): void;
  69097. /**
  69098. * Stores an UInt32 in the array buffer
  69099. * @param entry
  69100. * @param byteOffset If defined, specifies where to set the value as an offset.
  69101. */
  69102. setUInt32(entry: number, byteOffset?: number): void;
  69103. }
  69104. }
  69105. declare module BABYLON.GLTF2.Exporter {
  69106. /**
  69107. * @hidden
  69108. * Interface to store animation data.
  69109. */
  69110. export interface _IAnimationData {
  69111. /**
  69112. * Keyframe data.
  69113. */
  69114. inputs: number[];
  69115. /**
  69116. * Value data.
  69117. */
  69118. outputs: number[][];
  69119. /**
  69120. * Animation interpolation data.
  69121. */
  69122. samplerInterpolation: AnimationSamplerInterpolation;
  69123. /**
  69124. * Minimum keyframe value.
  69125. */
  69126. inputsMin: number;
  69127. /**
  69128. * Maximum keyframe value.
  69129. */
  69130. inputsMax: number;
  69131. }
  69132. /**
  69133. * @hidden
  69134. */
  69135. export interface _IAnimationInfo {
  69136. /**
  69137. * The target channel for the animation
  69138. */
  69139. animationChannelTargetPath: AnimationChannelTargetPath;
  69140. /**
  69141. * The glTF accessor type for the data.
  69142. */
  69143. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69144. /**
  69145. * Specifies if quaternions should be used.
  69146. */
  69147. useQuaternion: boolean;
  69148. }
  69149. /**
  69150. * @hidden
  69151. * Utility class for generating glTF animation data from BabylonJS.
  69152. */
  69153. export class _GLTFAnimation {
  69154. /**
  69155. * @ignore
  69156. *
  69157. * Creates glTF channel animation from BabylonJS animation.
  69158. * @param babylonTransformNode - BabylonJS mesh.
  69159. * @param animation - animation.
  69160. * @param animationChannelTargetPath - The target animation channel.
  69161. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69162. * @param useQuaternion - Specifies if quaternions are used.
  69163. * @returns nullable IAnimationData
  69164. */
  69165. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69166. private static _DeduceAnimationInfo;
  69167. /**
  69168. * @ignore
  69169. * Create node animations from the transform node animations
  69170. * @param babylonNode
  69171. * @param runtimeGLTFAnimation
  69172. * @param idleGLTFAnimations
  69173. * @param nodeMap
  69174. * @param nodes
  69175. * @param binaryWriter
  69176. * @param bufferViews
  69177. * @param accessors
  69178. * @param convertToRightHandedSystem
  69179. */
  69180. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69181. [key: number]: number;
  69182. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69183. /**
  69184. * @ignore
  69185. * Create node animations from the animation groups
  69186. * @param babylonScene
  69187. * @param glTFAnimations
  69188. * @param nodeMap
  69189. * @param nodes
  69190. * @param binaryWriter
  69191. * @param bufferViews
  69192. * @param accessors
  69193. * @param convertToRightHandedSystem
  69194. */
  69195. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69196. [key: number]: number;
  69197. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69198. private static AddAnimation;
  69199. /**
  69200. * Create a baked animation
  69201. * @param babylonTransformNode BabylonJS mesh
  69202. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69203. * @param animationChannelTargetPath animation target channel
  69204. * @param minFrame minimum animation frame
  69205. * @param maxFrame maximum animation frame
  69206. * @param fps frames per second of the animation
  69207. * @param inputs input key frames of the animation
  69208. * @param outputs output key frame data of the animation
  69209. * @param convertToRightHandedSystem converts the values to right-handed
  69210. * @param useQuaternion specifies if quaternions should be used
  69211. */
  69212. private static _CreateBakedAnimation;
  69213. private static _ConvertFactorToVector3OrQuaternion;
  69214. private static _SetInterpolatedValue;
  69215. /**
  69216. * Creates linear animation from the animation key frames
  69217. * @param babylonTransformNode BabylonJS mesh
  69218. * @param animation BabylonJS animation
  69219. * @param animationChannelTargetPath The target animation channel
  69220. * @param frameDelta The difference between the last and first frame of the animation
  69221. * @param inputs Array to store the key frame times
  69222. * @param outputs Array to store the key frame data
  69223. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69224. * @param useQuaternion Specifies if quaternions are used in the animation
  69225. */
  69226. private static _CreateLinearOrStepAnimation;
  69227. /**
  69228. * Creates cubic spline animation from the animation key frames
  69229. * @param babylonTransformNode BabylonJS mesh
  69230. * @param animation BabylonJS animation
  69231. * @param animationChannelTargetPath The target animation channel
  69232. * @param frameDelta The difference between the last and first frame of the animation
  69233. * @param inputs Array to store the key frame times
  69234. * @param outputs Array to store the key frame data
  69235. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69236. * @param useQuaternion Specifies if quaternions are used in the animation
  69237. */
  69238. private static _CreateCubicSplineAnimation;
  69239. private static _GetBasePositionRotationOrScale;
  69240. /**
  69241. * Adds a key frame value
  69242. * @param keyFrame
  69243. * @param animation
  69244. * @param outputs
  69245. * @param animationChannelTargetPath
  69246. * @param basePositionRotationOrScale
  69247. * @param convertToRightHandedSystem
  69248. * @param useQuaternion
  69249. */
  69250. private static _AddKeyframeValue;
  69251. /**
  69252. * Determine the interpolation based on the key frames
  69253. * @param keyFrames
  69254. * @param animationChannelTargetPath
  69255. * @param useQuaternion
  69256. */
  69257. private static _DeduceInterpolation;
  69258. /**
  69259. * Adds an input tangent or output tangent to the output data
  69260. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69261. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69262. * @param outputs The animation data by keyframe
  69263. * @param animationChannelTargetPath The target animation channel
  69264. * @param interpolation The interpolation type
  69265. * @param keyFrame The key frame with the animation data
  69266. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69267. * @param useQuaternion Specifies if quaternions are used
  69268. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69269. */
  69270. private static AddSplineTangent;
  69271. /**
  69272. * Get the minimum and maximum key frames' frame values
  69273. * @param keyFrames animation key frames
  69274. * @returns the minimum and maximum key frame value
  69275. */
  69276. private static calculateMinMaxKeyFrames;
  69277. }
  69278. }
  69279. declare module BABYLON.GLTF2.Exporter {
  69280. /** @hidden */
  69281. export var textureTransformPixelShader: {
  69282. name: string;
  69283. shader: string;
  69284. };
  69285. }
  69286. declare module BABYLON.GLTF2.Exporter.Extensions {
  69287. /**
  69288. * @hidden
  69289. */
  69290. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69291. /** Name of this extension */
  69292. readonly name: string;
  69293. /** Defines whether this extension is enabled */
  69294. enabled: boolean;
  69295. /** Defines whether this extension is required */
  69296. required: boolean;
  69297. /** Reference to the glTF exporter */
  69298. private _exporter;
  69299. constructor(exporter: _Exporter);
  69300. dispose(): void;
  69301. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69302. /**
  69303. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69304. * @param babylonTexture
  69305. * @param offset
  69306. * @param rotation
  69307. * @param scale
  69308. * @param scene
  69309. */
  69310. private _textureTransformTextureAsync;
  69311. }
  69312. }
  69313. declare module BABYLON.GLTF2.Exporter.Extensions {
  69314. /**
  69315. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69316. */
  69317. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69318. /** The name of this extension. */
  69319. readonly name: string;
  69320. /** Defines whether this extension is enabled. */
  69321. enabled: boolean;
  69322. /** Defines whether this extension is required */
  69323. required: boolean;
  69324. /** Reference to the glTF exporter */
  69325. private _exporter;
  69326. private _lights;
  69327. /** @hidden */
  69328. constructor(exporter: _Exporter);
  69329. /** @hidden */
  69330. dispose(): void;
  69331. /** @hidden */
  69332. onExporting(): void;
  69333. /**
  69334. * Define this method to modify the default behavior when exporting a node
  69335. * @param context The context when exporting the node
  69336. * @param node glTF node
  69337. * @param babylonNode BabylonJS node
  69338. * @returns nullable INode promise
  69339. */
  69340. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69341. }
  69342. }
  69343. declare module BABYLON {
  69344. /**
  69345. * Class for generating STL data from a Babylon scene.
  69346. */
  69347. export class STLExport {
  69348. /**
  69349. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69350. * @param meshes list defines the mesh to serialize
  69351. * @param download triggers the automatic download of the file.
  69352. * @param fileName changes the downloads fileName.
  69353. * @param binary changes the STL to a binary type.
  69354. * @param isLittleEndian toggle for binary type exporter.
  69355. * @returns the STL as UTF8 string
  69356. */
  69357. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69358. }
  69359. }
  69360. /**
  69361. * @ignoreChildren
  69362. * @ignore
  69363. */
  69364. declare module "babylonjs-gltf2interface" {
  69365. export = BABYLON.GLTF2;
  69366. }
  69367. /**
  69368. * Module for glTF 2.0 Interface
  69369. * @ignoreChildren
  69370. * @ignore
  69371. */
  69372. declare module BABYLON.GLTF2 {
  69373. /**
  69374. * The datatype of the components in the attribute
  69375. */
  69376. const enum AccessorComponentType {
  69377. /**
  69378. * Byte
  69379. */
  69380. BYTE = 5120,
  69381. /**
  69382. * Unsigned Byte
  69383. */
  69384. UNSIGNED_BYTE = 5121,
  69385. /**
  69386. * Short
  69387. */
  69388. SHORT = 5122,
  69389. /**
  69390. * Unsigned Short
  69391. */
  69392. UNSIGNED_SHORT = 5123,
  69393. /**
  69394. * Unsigned Int
  69395. */
  69396. UNSIGNED_INT = 5125,
  69397. /**
  69398. * Float
  69399. */
  69400. FLOAT = 5126,
  69401. }
  69402. /**
  69403. * Specifies if the attirbute is a scalar, vector, or matrix
  69404. */
  69405. const enum AccessorType {
  69406. /**
  69407. * Scalar
  69408. */
  69409. SCALAR = "SCALAR",
  69410. /**
  69411. * Vector2
  69412. */
  69413. VEC2 = "VEC2",
  69414. /**
  69415. * Vector3
  69416. */
  69417. VEC3 = "VEC3",
  69418. /**
  69419. * Vector4
  69420. */
  69421. VEC4 = "VEC4",
  69422. /**
  69423. * Matrix2x2
  69424. */
  69425. MAT2 = "MAT2",
  69426. /**
  69427. * Matrix3x3
  69428. */
  69429. MAT3 = "MAT3",
  69430. /**
  69431. * Matrix4x4
  69432. */
  69433. MAT4 = "MAT4",
  69434. }
  69435. /**
  69436. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69437. */
  69438. const enum AnimationChannelTargetPath {
  69439. /**
  69440. * Translation
  69441. */
  69442. TRANSLATION = "translation",
  69443. /**
  69444. * Rotation
  69445. */
  69446. ROTATION = "rotation",
  69447. /**
  69448. * Scale
  69449. */
  69450. SCALE = "scale",
  69451. /**
  69452. * Weights
  69453. */
  69454. WEIGHTS = "weights",
  69455. }
  69456. /**
  69457. * Interpolation algorithm
  69458. */
  69459. const enum AnimationSamplerInterpolation {
  69460. /**
  69461. * The animated values are linearly interpolated between keyframes
  69462. */
  69463. LINEAR = "LINEAR",
  69464. /**
  69465. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69466. */
  69467. STEP = "STEP",
  69468. /**
  69469. * The animation's interpolation is computed using a cubic spline with specified tangents
  69470. */
  69471. CUBICSPLINE = "CUBICSPLINE",
  69472. }
  69473. /**
  69474. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69475. */
  69476. const enum CameraType {
  69477. /**
  69478. * A perspective camera containing properties to create a perspective projection matrix
  69479. */
  69480. PERSPECTIVE = "perspective",
  69481. /**
  69482. * An orthographic camera containing properties to create an orthographic projection matrix
  69483. */
  69484. ORTHOGRAPHIC = "orthographic",
  69485. }
  69486. /**
  69487. * The mime-type of the image
  69488. */
  69489. const enum ImageMimeType {
  69490. /**
  69491. * JPEG Mime-type
  69492. */
  69493. JPEG = "image/jpeg",
  69494. /**
  69495. * PNG Mime-type
  69496. */
  69497. PNG = "image/png",
  69498. }
  69499. /**
  69500. * The alpha rendering mode of the material
  69501. */
  69502. const enum MaterialAlphaMode {
  69503. /**
  69504. * The alpha value is ignored and the rendered output is fully opaque
  69505. */
  69506. OPAQUE = "OPAQUE",
  69507. /**
  69508. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69509. */
  69510. MASK = "MASK",
  69511. /**
  69512. * 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)
  69513. */
  69514. BLEND = "BLEND",
  69515. }
  69516. /**
  69517. * The type of the primitives to render
  69518. */
  69519. const enum MeshPrimitiveMode {
  69520. /**
  69521. * Points
  69522. */
  69523. POINTS = 0,
  69524. /**
  69525. * Lines
  69526. */
  69527. LINES = 1,
  69528. /**
  69529. * Line Loop
  69530. */
  69531. LINE_LOOP = 2,
  69532. /**
  69533. * Line Strip
  69534. */
  69535. LINE_STRIP = 3,
  69536. /**
  69537. * Triangles
  69538. */
  69539. TRIANGLES = 4,
  69540. /**
  69541. * Triangle Strip
  69542. */
  69543. TRIANGLE_STRIP = 5,
  69544. /**
  69545. * Triangle Fan
  69546. */
  69547. TRIANGLE_FAN = 6,
  69548. }
  69549. /**
  69550. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69551. */
  69552. const enum TextureMagFilter {
  69553. /**
  69554. * Nearest
  69555. */
  69556. NEAREST = 9728,
  69557. /**
  69558. * Linear
  69559. */
  69560. LINEAR = 9729,
  69561. }
  69562. /**
  69563. * Minification filter. All valid values correspond to WebGL enums
  69564. */
  69565. const enum TextureMinFilter {
  69566. /**
  69567. * Nearest
  69568. */
  69569. NEAREST = 9728,
  69570. /**
  69571. * Linear
  69572. */
  69573. LINEAR = 9729,
  69574. /**
  69575. * Nearest Mip-Map Nearest
  69576. */
  69577. NEAREST_MIPMAP_NEAREST = 9984,
  69578. /**
  69579. * Linear Mipmap Nearest
  69580. */
  69581. LINEAR_MIPMAP_NEAREST = 9985,
  69582. /**
  69583. * Nearest Mipmap Linear
  69584. */
  69585. NEAREST_MIPMAP_LINEAR = 9986,
  69586. /**
  69587. * Linear Mipmap Linear
  69588. */
  69589. LINEAR_MIPMAP_LINEAR = 9987,
  69590. }
  69591. /**
  69592. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69593. */
  69594. const enum TextureWrapMode {
  69595. /**
  69596. * Clamp to Edge
  69597. */
  69598. CLAMP_TO_EDGE = 33071,
  69599. /**
  69600. * Mirrored Repeat
  69601. */
  69602. MIRRORED_REPEAT = 33648,
  69603. /**
  69604. * Repeat
  69605. */
  69606. REPEAT = 10497,
  69607. }
  69608. /**
  69609. * glTF Property
  69610. */
  69611. interface IProperty {
  69612. /**
  69613. * Dictionary object with extension-specific objects
  69614. */
  69615. extensions?: {
  69616. [key: string]: any;
  69617. };
  69618. /**
  69619. * Application-Specific data
  69620. */
  69621. extras?: any;
  69622. }
  69623. /**
  69624. * glTF Child of Root Property
  69625. */
  69626. interface IChildRootProperty extends IProperty {
  69627. /**
  69628. * The user-defined name of this object
  69629. */
  69630. name?: string;
  69631. }
  69632. /**
  69633. * Indices of those attributes that deviate from their initialization value
  69634. */
  69635. interface IAccessorSparseIndices extends IProperty {
  69636. /**
  69637. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69638. */
  69639. bufferView: number;
  69640. /**
  69641. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69642. */
  69643. byteOffset?: number;
  69644. /**
  69645. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69646. */
  69647. componentType: AccessorComponentType;
  69648. }
  69649. /**
  69650. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69651. */
  69652. interface IAccessorSparseValues extends IProperty {
  69653. /**
  69654. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69655. */
  69656. bufferView: number;
  69657. /**
  69658. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69659. */
  69660. byteOffset?: number;
  69661. }
  69662. /**
  69663. * Sparse storage of attributes that deviate from their initialization value
  69664. */
  69665. interface IAccessorSparse extends IProperty {
  69666. /**
  69667. * The number of attributes encoded in this sparse accessor
  69668. */
  69669. count: number;
  69670. /**
  69671. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69672. */
  69673. indices: IAccessorSparseIndices;
  69674. /**
  69675. * 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
  69676. */
  69677. values: IAccessorSparseValues;
  69678. }
  69679. /**
  69680. * 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
  69681. */
  69682. interface IAccessor extends IChildRootProperty {
  69683. /**
  69684. * The index of the bufferview
  69685. */
  69686. bufferView?: number;
  69687. /**
  69688. * The offset relative to the start of the bufferView in bytes
  69689. */
  69690. byteOffset?: number;
  69691. /**
  69692. * The datatype of components in the attribute
  69693. */
  69694. componentType: AccessorComponentType;
  69695. /**
  69696. * Specifies whether integer data values should be normalized
  69697. */
  69698. normalized?: boolean;
  69699. /**
  69700. * The number of attributes referenced by this accessor
  69701. */
  69702. count: number;
  69703. /**
  69704. * Specifies if the attribute is a scalar, vector, or matrix
  69705. */
  69706. type: AccessorType;
  69707. /**
  69708. * Maximum value of each component in this attribute
  69709. */
  69710. max?: number[];
  69711. /**
  69712. * Minimum value of each component in this attribute
  69713. */
  69714. min?: number[];
  69715. /**
  69716. * Sparse storage of attributes that deviate from their initialization value
  69717. */
  69718. sparse?: IAccessorSparse;
  69719. }
  69720. /**
  69721. * Targets an animation's sampler at a node's property
  69722. */
  69723. interface IAnimationChannel extends IProperty {
  69724. /**
  69725. * The index of a sampler in this animation used to compute the value for the target
  69726. */
  69727. sampler: number;
  69728. /**
  69729. * The index of the node and TRS property to target
  69730. */
  69731. target: IAnimationChannelTarget;
  69732. }
  69733. /**
  69734. * The index of the node and TRS property that an animation channel targets
  69735. */
  69736. interface IAnimationChannelTarget extends IProperty {
  69737. /**
  69738. * The index of the node to target
  69739. */
  69740. node: number;
  69741. /**
  69742. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69743. */
  69744. path: AnimationChannelTargetPath;
  69745. }
  69746. /**
  69747. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69748. */
  69749. interface IAnimationSampler extends IProperty {
  69750. /**
  69751. * The index of an accessor containing keyframe input values, e.g., time
  69752. */
  69753. input: number;
  69754. /**
  69755. * Interpolation algorithm
  69756. */
  69757. interpolation?: AnimationSamplerInterpolation;
  69758. /**
  69759. * The index of an accessor, containing keyframe output values
  69760. */
  69761. output: number;
  69762. }
  69763. /**
  69764. * A keyframe animation
  69765. */
  69766. interface IAnimation extends IChildRootProperty {
  69767. /**
  69768. * An array of channels, each of which targets an animation's sampler at a node's property
  69769. */
  69770. channels: IAnimationChannel[];
  69771. /**
  69772. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69773. */
  69774. samplers: IAnimationSampler[];
  69775. }
  69776. /**
  69777. * Metadata about the glTF asset
  69778. */
  69779. interface IAsset extends IChildRootProperty {
  69780. /**
  69781. * A copyright message suitable for display to credit the content creator
  69782. */
  69783. copyright?: string;
  69784. /**
  69785. * Tool that generated this glTF model. Useful for debugging
  69786. */
  69787. generator?: string;
  69788. /**
  69789. * The glTF version that this asset targets
  69790. */
  69791. version: string;
  69792. /**
  69793. * The minimum glTF version that this asset targets
  69794. */
  69795. minVersion?: string;
  69796. }
  69797. /**
  69798. * A buffer points to binary geometry, animation, or skins
  69799. */
  69800. interface IBuffer extends IChildRootProperty {
  69801. /**
  69802. * 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
  69803. */
  69804. uri?: string;
  69805. /**
  69806. * The length of the buffer in bytes
  69807. */
  69808. byteLength: number;
  69809. }
  69810. /**
  69811. * A view into a buffer generally representing a subset of the buffer
  69812. */
  69813. interface IBufferView extends IChildRootProperty {
  69814. /**
  69815. * The index of the buffer
  69816. */
  69817. buffer: number;
  69818. /**
  69819. * The offset into the buffer in bytes
  69820. */
  69821. byteOffset?: number;
  69822. /**
  69823. * The lenth of the bufferView in bytes
  69824. */
  69825. byteLength: number;
  69826. /**
  69827. * The stride, in bytes
  69828. */
  69829. byteStride?: number;
  69830. }
  69831. /**
  69832. * An orthographic camera containing properties to create an orthographic projection matrix
  69833. */
  69834. interface ICameraOrthographic extends IProperty {
  69835. /**
  69836. * The floating-point horizontal magnification of the view. Must not be zero
  69837. */
  69838. xmag: number;
  69839. /**
  69840. * The floating-point vertical magnification of the view. Must not be zero
  69841. */
  69842. ymag: number;
  69843. /**
  69844. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69845. */
  69846. zfar: number;
  69847. /**
  69848. * The floating-point distance to the near clipping plane
  69849. */
  69850. znear: number;
  69851. }
  69852. /**
  69853. * A perspective camera containing properties to create a perspective projection matrix
  69854. */
  69855. interface ICameraPerspective extends IProperty {
  69856. /**
  69857. * The floating-point aspect ratio of the field of view
  69858. */
  69859. aspectRatio?: number;
  69860. /**
  69861. * The floating-point vertical field of view in radians
  69862. */
  69863. yfov: number;
  69864. /**
  69865. * The floating-point distance to the far clipping plane
  69866. */
  69867. zfar?: number;
  69868. /**
  69869. * The floating-point distance to the near clipping plane
  69870. */
  69871. znear: number;
  69872. }
  69873. /**
  69874. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69875. */
  69876. interface ICamera extends IChildRootProperty {
  69877. /**
  69878. * An orthographic camera containing properties to create an orthographic projection matrix
  69879. */
  69880. orthographic?: ICameraOrthographic;
  69881. /**
  69882. * A perspective camera containing properties to create a perspective projection matrix
  69883. */
  69884. perspective?: ICameraPerspective;
  69885. /**
  69886. * Specifies if the camera uses a perspective or orthographic projection
  69887. */
  69888. type: CameraType;
  69889. }
  69890. /**
  69891. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69892. */
  69893. interface IImage extends IChildRootProperty {
  69894. /**
  69895. * 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
  69896. */
  69897. uri?: string;
  69898. /**
  69899. * The image's MIME type
  69900. */
  69901. mimeType?: ImageMimeType;
  69902. /**
  69903. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69904. */
  69905. bufferView?: number;
  69906. }
  69907. /**
  69908. * Material Normal Texture Info
  69909. */
  69910. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69911. /**
  69912. * The scalar multiplier applied to each normal vector of the normal texture
  69913. */
  69914. scale?: number;
  69915. }
  69916. /**
  69917. * Material Occlusion Texture Info
  69918. */
  69919. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69920. /**
  69921. * A scalar multiplier controlling the amount of occlusion applied
  69922. */
  69923. strength?: number;
  69924. }
  69925. /**
  69926. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69927. */
  69928. interface IMaterialPbrMetallicRoughness {
  69929. /**
  69930. * The material's base color factor
  69931. */
  69932. baseColorFactor?: number[];
  69933. /**
  69934. * The base color texture
  69935. */
  69936. baseColorTexture?: ITextureInfo;
  69937. /**
  69938. * The metalness of the material
  69939. */
  69940. metallicFactor?: number;
  69941. /**
  69942. * The roughness of the material
  69943. */
  69944. roughnessFactor?: number;
  69945. /**
  69946. * The metallic-roughness texture
  69947. */
  69948. metallicRoughnessTexture?: ITextureInfo;
  69949. }
  69950. /**
  69951. * The material appearance of a primitive
  69952. */
  69953. interface IMaterial extends IChildRootProperty {
  69954. /**
  69955. * 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
  69956. */
  69957. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69958. /**
  69959. * The normal map texture
  69960. */
  69961. normalTexture?: IMaterialNormalTextureInfo;
  69962. /**
  69963. * The occlusion map texture
  69964. */
  69965. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69966. /**
  69967. * The emissive map texture
  69968. */
  69969. emissiveTexture?: ITextureInfo;
  69970. /**
  69971. * 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
  69972. */
  69973. emissiveFactor?: number[];
  69974. /**
  69975. * The alpha rendering mode of the material
  69976. */
  69977. alphaMode?: MaterialAlphaMode;
  69978. /**
  69979. * The alpha cutoff value of the material
  69980. */
  69981. alphaCutoff?: number;
  69982. /**
  69983. * Specifies whether the material is double sided
  69984. */
  69985. doubleSided?: boolean;
  69986. }
  69987. /**
  69988. * Geometry to be rendered with the given material
  69989. */
  69990. interface IMeshPrimitive extends IProperty {
  69991. /**
  69992. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69993. */
  69994. attributes: {
  69995. [name: string]: number;
  69996. };
  69997. /**
  69998. * The index of the accessor that contains the indices
  69999. */
  70000. indices?: number;
  70001. /**
  70002. * The index of the material to apply to this primitive when rendering
  70003. */
  70004. material?: number;
  70005. /**
  70006. * The type of primitives to render. All valid values correspond to WebGL enums
  70007. */
  70008. mode?: MeshPrimitiveMode;
  70009. /**
  70010. * 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
  70011. */
  70012. targets?: {
  70013. [name: string]: number;
  70014. }[];
  70015. }
  70016. /**
  70017. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70018. */
  70019. interface IMesh extends IChildRootProperty {
  70020. /**
  70021. * An array of primitives, each defining geometry to be rendered with a material
  70022. */
  70023. primitives: IMeshPrimitive[];
  70024. /**
  70025. * Array of weights to be applied to the Morph Targets
  70026. */
  70027. weights?: number[];
  70028. }
  70029. /**
  70030. * A node in the node hierarchy
  70031. */
  70032. interface INode extends IChildRootProperty {
  70033. /**
  70034. * The index of the camera referenced by this node
  70035. */
  70036. camera?: number;
  70037. /**
  70038. * The indices of this node's children
  70039. */
  70040. children?: number[];
  70041. /**
  70042. * The index of the skin referenced by this node
  70043. */
  70044. skin?: number;
  70045. /**
  70046. * A floating-point 4x4 transformation matrix stored in column-major order
  70047. */
  70048. matrix?: number[];
  70049. /**
  70050. * The index of the mesh in this node
  70051. */
  70052. mesh?: number;
  70053. /**
  70054. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70055. */
  70056. rotation?: number[];
  70057. /**
  70058. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70059. */
  70060. scale?: number[];
  70061. /**
  70062. * The node's translation along the x, y, and z axes
  70063. */
  70064. translation?: number[];
  70065. /**
  70066. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70067. */
  70068. weights?: number[];
  70069. }
  70070. /**
  70071. * Texture sampler properties for filtering and wrapping modes
  70072. */
  70073. interface ISampler extends IChildRootProperty {
  70074. /**
  70075. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70076. */
  70077. magFilter?: TextureMagFilter;
  70078. /**
  70079. * Minification filter. All valid values correspond to WebGL enums
  70080. */
  70081. minFilter?: TextureMinFilter;
  70082. /**
  70083. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70084. */
  70085. wrapS?: TextureWrapMode;
  70086. /**
  70087. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70088. */
  70089. wrapT?: TextureWrapMode;
  70090. }
  70091. /**
  70092. * The root nodes of a scene
  70093. */
  70094. interface IScene extends IChildRootProperty {
  70095. /**
  70096. * The indices of each root node
  70097. */
  70098. nodes: number[];
  70099. }
  70100. /**
  70101. * Joints and matrices defining a skin
  70102. */
  70103. interface ISkin extends IChildRootProperty {
  70104. /**
  70105. * 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
  70106. */
  70107. inverseBindMatrices?: number;
  70108. /**
  70109. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70110. */
  70111. skeleton?: number;
  70112. /**
  70113. * 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)
  70114. */
  70115. joints: number[];
  70116. }
  70117. /**
  70118. * A texture and its sampler
  70119. */
  70120. interface ITexture extends IChildRootProperty {
  70121. /**
  70122. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70123. */
  70124. sampler?: number;
  70125. /**
  70126. * The index of the image used by this texture
  70127. */
  70128. source: number;
  70129. }
  70130. /**
  70131. * Reference to a texture
  70132. */
  70133. interface ITextureInfo extends IProperty {
  70134. /**
  70135. * The index of the texture
  70136. */
  70137. index: number;
  70138. /**
  70139. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70140. */
  70141. texCoord?: number;
  70142. }
  70143. /**
  70144. * The root object for a glTF asset
  70145. */
  70146. interface IGLTF extends IProperty {
  70147. /**
  70148. * An array of accessors. An accessor is a typed view into a bufferView
  70149. */
  70150. accessors?: IAccessor[];
  70151. /**
  70152. * An array of keyframe animations
  70153. */
  70154. animations?: IAnimation[];
  70155. /**
  70156. * Metadata about the glTF asset
  70157. */
  70158. asset: IAsset;
  70159. /**
  70160. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70161. */
  70162. buffers?: IBuffer[];
  70163. /**
  70164. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70165. */
  70166. bufferViews?: IBufferView[];
  70167. /**
  70168. * An array of cameras
  70169. */
  70170. cameras?: ICamera[];
  70171. /**
  70172. * Names of glTF extensions used somewhere in this asset
  70173. */
  70174. extensionsUsed?: string[];
  70175. /**
  70176. * Names of glTF extensions required to properly load this asset
  70177. */
  70178. extensionsRequired?: string[];
  70179. /**
  70180. * An array of images. An image defines data used to create a texture
  70181. */
  70182. images?: IImage[];
  70183. /**
  70184. * An array of materials. A material defines the appearance of a primitive
  70185. */
  70186. materials?: IMaterial[];
  70187. /**
  70188. * An array of meshes. A mesh is a set of primitives to be rendered
  70189. */
  70190. meshes?: IMesh[];
  70191. /**
  70192. * An array of nodes
  70193. */
  70194. nodes?: INode[];
  70195. /**
  70196. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70197. */
  70198. samplers?: ISampler[];
  70199. /**
  70200. * The index of the default scene
  70201. */
  70202. scene?: number;
  70203. /**
  70204. * An array of scenes
  70205. */
  70206. scenes?: IScene[];
  70207. /**
  70208. * An array of skins. A skin is defined by joints and matrices
  70209. */
  70210. skins?: ISkin[];
  70211. /**
  70212. * An array of textures
  70213. */
  70214. textures?: ITexture[];
  70215. }
  70216. /**
  70217. * The glTF validation results
  70218. */
  70219. interface IGLTFValidationResults {
  70220. info: {
  70221. generator: string;
  70222. hasAnimations: boolean;
  70223. hasDefaultScene: boolean;
  70224. hasMaterials: boolean;
  70225. hasMorphTargets: boolean;
  70226. hasSkins: boolean;
  70227. hasTextures: boolean;
  70228. maxAttributesUsed: number;
  70229. primitivesCount: number
  70230. };
  70231. issues: {
  70232. messages: Array<string>;
  70233. numErrors: number;
  70234. numHints: number;
  70235. numInfos: number;
  70236. numWarnings: number;
  70237. truncated: boolean
  70238. };
  70239. mimeType: string;
  70240. uri: string;
  70241. validatedAt: string;
  70242. validatorVersion: string;
  70243. }
  70244. /**
  70245. * The glTF validation options
  70246. */
  70247. interface IGLTFValidationOptions {
  70248. uri?: string;
  70249. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70250. validateAccessorData?: boolean;
  70251. maxIssues?: number;
  70252. ignoredIssues?: Array<string>;
  70253. severityOverrides?: Object;
  70254. }
  70255. /**
  70256. * The glTF validator object
  70257. */
  70258. interface IGLTFValidator {
  70259. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70260. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70261. }
  70262. }
  70263. declare module BABYLON {
  70264. /** @hidden */
  70265. export var cellPixelShader: {
  70266. name: string;
  70267. shader: string;
  70268. };
  70269. }
  70270. declare module BABYLON {
  70271. /** @hidden */
  70272. export var cellVertexShader: {
  70273. name: string;
  70274. shader: string;
  70275. };
  70276. }
  70277. declare module BABYLON {
  70278. export class CellMaterial extends BABYLON.PushMaterial {
  70279. private _diffuseTexture;
  70280. diffuseTexture: BABYLON.BaseTexture;
  70281. diffuseColor: BABYLON.Color3;
  70282. _computeHighLevel: boolean;
  70283. computeHighLevel: boolean;
  70284. private _disableLighting;
  70285. disableLighting: boolean;
  70286. private _maxSimultaneousLights;
  70287. maxSimultaneousLights: number;
  70288. private _renderId;
  70289. constructor(name: string, scene: BABYLON.Scene);
  70290. needAlphaBlending(): boolean;
  70291. needAlphaTesting(): boolean;
  70292. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70293. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70294. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70295. getAnimatables(): BABYLON.IAnimatable[];
  70296. getActiveTextures(): BABYLON.BaseTexture[];
  70297. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70298. dispose(forceDisposeEffect?: boolean): void;
  70299. getClassName(): string;
  70300. clone(name: string): CellMaterial;
  70301. serialize(): any;
  70302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70303. }
  70304. }
  70305. declare module BABYLON {
  70306. export class CustomShaderStructure {
  70307. FragmentStore: string;
  70308. VertexStore: string;
  70309. constructor();
  70310. }
  70311. export class ShaderSpecialParts {
  70312. constructor();
  70313. Fragment_Begin: string;
  70314. Fragment_Definitions: string;
  70315. Fragment_MainBegin: string;
  70316. Fragment_Custom_Diffuse: string;
  70317. Fragment_Before_Lights: string;
  70318. Fragment_Before_Fog: string;
  70319. Fragment_Custom_Alpha: string;
  70320. Fragment_Before_FragColor: string;
  70321. Vertex_Begin: string;
  70322. Vertex_Definitions: string;
  70323. Vertex_MainBegin: string;
  70324. Vertex_Before_PositionUpdated: string;
  70325. Vertex_Before_NormalUpdated: string;
  70326. Vertex_MainEnd: string;
  70327. }
  70328. export class CustomMaterial extends BABYLON.StandardMaterial {
  70329. static ShaderIndexer: number;
  70330. CustomParts: ShaderSpecialParts;
  70331. _isCreatedShader: boolean;
  70332. _createdShaderName: string;
  70333. _customUniform: string[];
  70334. _newUniforms: string[];
  70335. _newUniformInstances: any[];
  70336. _newSamplerInstances: BABYLON.Texture[];
  70337. FragmentShader: string;
  70338. VertexShader: string;
  70339. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70340. ReviewUniform(name: string, arr: string[]): string[];
  70341. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70342. constructor(name: string, scene: BABYLON.Scene);
  70343. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70344. Fragment_Begin(shaderPart: string): CustomMaterial;
  70345. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70346. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70347. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70348. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70349. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70350. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70351. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70352. Vertex_Begin(shaderPart: string): CustomMaterial;
  70353. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70354. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70355. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70356. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70357. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70358. }
  70359. }
  70360. declare module BABYLON {
  70361. export class ShaderAlebdoParts {
  70362. constructor();
  70363. Fragment_Begin: string;
  70364. Fragment_Definitions: string;
  70365. Fragment_MainBegin: string;
  70366. Fragment_Custom_Albedo: string;
  70367. Fragment_Before_Lights: string;
  70368. Fragment_Custom_MetallicRoughness: string;
  70369. Fragment_Custom_MicroSurface: string;
  70370. Fragment_Before_Fog: string;
  70371. Fragment_Custom_Alpha: string;
  70372. Fragment_Before_FragColor: string;
  70373. Vertex_Begin: string;
  70374. Vertex_Definitions: string;
  70375. Vertex_MainBegin: string;
  70376. Vertex_Before_PositionUpdated: string;
  70377. Vertex_Before_NormalUpdated: string;
  70378. Vertex_MainEnd: string;
  70379. }
  70380. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70381. static ShaderIndexer: number;
  70382. CustomParts: ShaderAlebdoParts;
  70383. _isCreatedShader: boolean;
  70384. _createdShaderName: string;
  70385. _customUniform: string[];
  70386. _newUniforms: string[];
  70387. _newUniformInstances: any[];
  70388. _newSamplerInstances: BABYLON.Texture[];
  70389. FragmentShader: string;
  70390. VertexShader: string;
  70391. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70392. ReviewUniform(name: string, arr: string[]): string[];
  70393. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70394. constructor(name: string, scene: BABYLON.Scene);
  70395. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70396. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70397. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70398. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70399. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70400. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70401. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70402. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70403. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70404. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70405. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70406. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70407. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70408. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70409. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70410. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70411. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /** @hidden */
  70416. export var firePixelShader: {
  70417. name: string;
  70418. shader: string;
  70419. };
  70420. }
  70421. declare module BABYLON {
  70422. /** @hidden */
  70423. export var fireVertexShader: {
  70424. name: string;
  70425. shader: string;
  70426. };
  70427. }
  70428. declare module BABYLON {
  70429. export class FireMaterial extends BABYLON.PushMaterial {
  70430. private _diffuseTexture;
  70431. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70432. private _distortionTexture;
  70433. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70434. private _opacityTexture;
  70435. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70436. diffuseColor: BABYLON.Color3;
  70437. speed: number;
  70438. private _scaledDiffuse;
  70439. private _renderId;
  70440. private _lastTime;
  70441. constructor(name: string, scene: BABYLON.Scene);
  70442. needAlphaBlending(): boolean;
  70443. needAlphaTesting(): boolean;
  70444. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70446. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70447. getAnimatables(): BABYLON.IAnimatable[];
  70448. getActiveTextures(): BABYLON.BaseTexture[];
  70449. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70450. getClassName(): string;
  70451. dispose(forceDisposeEffect?: boolean): void;
  70452. clone(name: string): FireMaterial;
  70453. serialize(): any;
  70454. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70455. }
  70456. }
  70457. declare module BABYLON {
  70458. /** @hidden */
  70459. export var furPixelShader: {
  70460. name: string;
  70461. shader: string;
  70462. };
  70463. }
  70464. declare module BABYLON {
  70465. /** @hidden */
  70466. export var furVertexShader: {
  70467. name: string;
  70468. shader: string;
  70469. };
  70470. }
  70471. declare module BABYLON {
  70472. export class FurMaterial extends BABYLON.PushMaterial {
  70473. private _diffuseTexture;
  70474. diffuseTexture: BABYLON.BaseTexture;
  70475. private _heightTexture;
  70476. heightTexture: BABYLON.BaseTexture;
  70477. diffuseColor: BABYLON.Color3;
  70478. furLength: number;
  70479. furAngle: number;
  70480. furColor: BABYLON.Color3;
  70481. furOffset: number;
  70482. furSpacing: number;
  70483. furGravity: BABYLON.Vector3;
  70484. furSpeed: number;
  70485. furDensity: number;
  70486. furOcclusion: number;
  70487. furTexture: BABYLON.DynamicTexture;
  70488. private _disableLighting;
  70489. disableLighting: boolean;
  70490. private _maxSimultaneousLights;
  70491. maxSimultaneousLights: number;
  70492. highLevelFur: boolean;
  70493. _meshes: BABYLON.AbstractMesh[];
  70494. private _renderId;
  70495. private _furTime;
  70496. constructor(name: string, scene: BABYLON.Scene);
  70497. furTime: number;
  70498. needAlphaBlending(): boolean;
  70499. needAlphaTesting(): boolean;
  70500. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70501. updateFur(): void;
  70502. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70503. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70504. getAnimatables(): BABYLON.IAnimatable[];
  70505. getActiveTextures(): BABYLON.BaseTexture[];
  70506. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70507. dispose(forceDisposeEffect?: boolean): void;
  70508. clone(name: string): FurMaterial;
  70509. serialize(): any;
  70510. getClassName(): string;
  70511. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70512. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70513. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70514. }
  70515. }
  70516. declare module BABYLON {
  70517. /** @hidden */
  70518. export var gradientPixelShader: {
  70519. name: string;
  70520. shader: string;
  70521. };
  70522. }
  70523. declare module BABYLON {
  70524. /** @hidden */
  70525. export var gradientVertexShader: {
  70526. name: string;
  70527. shader: string;
  70528. };
  70529. }
  70530. declare module BABYLON {
  70531. export class GradientMaterial extends BABYLON.PushMaterial {
  70532. private _maxSimultaneousLights;
  70533. maxSimultaneousLights: number;
  70534. topColor: BABYLON.Color3;
  70535. topColorAlpha: number;
  70536. bottomColor: BABYLON.Color3;
  70537. bottomColorAlpha: number;
  70538. offset: number;
  70539. scale: number;
  70540. smoothness: number;
  70541. private _disableLighting;
  70542. disableLighting: boolean;
  70543. private _renderId;
  70544. constructor(name: string, scene: BABYLON.Scene);
  70545. needAlphaBlending(): boolean;
  70546. needAlphaTesting(): boolean;
  70547. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70548. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70549. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70550. getAnimatables(): BABYLON.IAnimatable[];
  70551. dispose(forceDisposeEffect?: boolean): void;
  70552. clone(name: string): GradientMaterial;
  70553. serialize(): any;
  70554. getClassName(): string;
  70555. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70556. }
  70557. }
  70558. declare module BABYLON {
  70559. /** @hidden */
  70560. export var gridPixelShader: {
  70561. name: string;
  70562. shader: string;
  70563. };
  70564. }
  70565. declare module BABYLON {
  70566. /** @hidden */
  70567. export var gridVertexShader: {
  70568. name: string;
  70569. shader: string;
  70570. };
  70571. }
  70572. declare module BABYLON {
  70573. /**
  70574. * The grid materials allows you to wrap any shape with a grid.
  70575. * Colors are customizable.
  70576. */
  70577. export class GridMaterial extends BABYLON.PushMaterial {
  70578. /**
  70579. * Main color of the grid (e.g. between lines)
  70580. */
  70581. mainColor: BABYLON.Color3;
  70582. /**
  70583. * Color of the grid lines.
  70584. */
  70585. lineColor: BABYLON.Color3;
  70586. /**
  70587. * The scale of the grid compared to unit.
  70588. */
  70589. gridRatio: number;
  70590. /**
  70591. * Allows setting an offset for the grid lines.
  70592. */
  70593. gridOffset: BABYLON.Vector3;
  70594. /**
  70595. * The frequency of thicker lines.
  70596. */
  70597. majorUnitFrequency: number;
  70598. /**
  70599. * The visibility of minor units in the grid.
  70600. */
  70601. minorUnitVisibility: number;
  70602. /**
  70603. * The grid opacity outside of the lines.
  70604. */
  70605. opacity: number;
  70606. /**
  70607. * Determine RBG output is premultiplied by alpha value.
  70608. */
  70609. preMultiplyAlpha: boolean;
  70610. private _opacityTexture;
  70611. opacityTexture: BABYLON.BaseTexture;
  70612. private _gridControl;
  70613. private _renderId;
  70614. /**
  70615. * constructor
  70616. * @param name The name given to the material in order to identify it afterwards.
  70617. * @param scene The scene the material is used in.
  70618. */
  70619. constructor(name: string, scene: BABYLON.Scene);
  70620. /**
  70621. * Returns wehter or not the grid requires alpha blending.
  70622. */
  70623. needAlphaBlending(): boolean;
  70624. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70625. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70626. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70627. /**
  70628. * Dispose the material and its associated resources.
  70629. * @param forceDisposeEffect will also dispose the used effect when true
  70630. */
  70631. dispose(forceDisposeEffect?: boolean): void;
  70632. clone(name: string): GridMaterial;
  70633. serialize(): any;
  70634. getClassName(): string;
  70635. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70636. }
  70637. }
  70638. declare module BABYLON {
  70639. /** @hidden */
  70640. export var lavaPixelShader: {
  70641. name: string;
  70642. shader: string;
  70643. };
  70644. }
  70645. declare module BABYLON {
  70646. /** @hidden */
  70647. export var lavaVertexShader: {
  70648. name: string;
  70649. shader: string;
  70650. };
  70651. }
  70652. declare module BABYLON {
  70653. export class LavaMaterial extends BABYLON.PushMaterial {
  70654. private _diffuseTexture;
  70655. diffuseTexture: BABYLON.BaseTexture;
  70656. noiseTexture: BABYLON.BaseTexture;
  70657. fogColor: BABYLON.Color3;
  70658. speed: number;
  70659. movingSpeed: number;
  70660. lowFrequencySpeed: number;
  70661. fogDensity: number;
  70662. private _lastTime;
  70663. diffuseColor: BABYLON.Color3;
  70664. private _disableLighting;
  70665. disableLighting: boolean;
  70666. private _unlit;
  70667. unlit: boolean;
  70668. private _maxSimultaneousLights;
  70669. maxSimultaneousLights: number;
  70670. private _scaledDiffuse;
  70671. private _renderId;
  70672. constructor(name: string, scene: BABYLON.Scene);
  70673. needAlphaBlending(): boolean;
  70674. needAlphaTesting(): boolean;
  70675. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70676. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70677. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70678. getAnimatables(): BABYLON.IAnimatable[];
  70679. getActiveTextures(): BABYLON.BaseTexture[];
  70680. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70681. dispose(forceDisposeEffect?: boolean): void;
  70682. clone(name: string): LavaMaterial;
  70683. serialize(): any;
  70684. getClassName(): string;
  70685. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /** @hidden */
  70690. export var mixPixelShader: {
  70691. name: string;
  70692. shader: string;
  70693. };
  70694. }
  70695. declare module BABYLON {
  70696. /** @hidden */
  70697. export var mixVertexShader: {
  70698. name: string;
  70699. shader: string;
  70700. };
  70701. }
  70702. declare module BABYLON {
  70703. export class MixMaterial extends BABYLON.PushMaterial {
  70704. /**
  70705. * Mix textures
  70706. */
  70707. private _mixTexture1;
  70708. mixTexture1: BABYLON.BaseTexture;
  70709. private _mixTexture2;
  70710. mixTexture2: BABYLON.BaseTexture;
  70711. /**
  70712. * Diffuse textures
  70713. */
  70714. private _diffuseTexture1;
  70715. diffuseTexture1: BABYLON.Texture;
  70716. private _diffuseTexture2;
  70717. diffuseTexture2: BABYLON.Texture;
  70718. private _diffuseTexture3;
  70719. diffuseTexture3: BABYLON.Texture;
  70720. private _diffuseTexture4;
  70721. diffuseTexture4: BABYLON.Texture;
  70722. private _diffuseTexture5;
  70723. diffuseTexture5: BABYLON.Texture;
  70724. private _diffuseTexture6;
  70725. diffuseTexture6: BABYLON.Texture;
  70726. private _diffuseTexture7;
  70727. diffuseTexture7: BABYLON.Texture;
  70728. private _diffuseTexture8;
  70729. diffuseTexture8: BABYLON.Texture;
  70730. /**
  70731. * Uniforms
  70732. */
  70733. diffuseColor: BABYLON.Color3;
  70734. specularColor: BABYLON.Color3;
  70735. specularPower: number;
  70736. private _disableLighting;
  70737. disableLighting: boolean;
  70738. private _maxSimultaneousLights;
  70739. maxSimultaneousLights: number;
  70740. private _renderId;
  70741. constructor(name: string, scene: BABYLON.Scene);
  70742. needAlphaBlending(): boolean;
  70743. needAlphaTesting(): boolean;
  70744. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70745. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70746. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70747. getAnimatables(): BABYLON.IAnimatable[];
  70748. getActiveTextures(): BABYLON.BaseTexture[];
  70749. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70750. dispose(forceDisposeEffect?: boolean): void;
  70751. clone(name: string): MixMaterial;
  70752. serialize(): any;
  70753. getClassName(): string;
  70754. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70755. }
  70756. }
  70757. declare module BABYLON {
  70758. /** @hidden */
  70759. export var normalPixelShader: {
  70760. name: string;
  70761. shader: string;
  70762. };
  70763. }
  70764. declare module BABYLON {
  70765. /** @hidden */
  70766. export var normalVertexShader: {
  70767. name: string;
  70768. shader: string;
  70769. };
  70770. }
  70771. declare module BABYLON {
  70772. export class NormalMaterial extends BABYLON.PushMaterial {
  70773. private _diffuseTexture;
  70774. diffuseTexture: BABYLON.BaseTexture;
  70775. diffuseColor: BABYLON.Color3;
  70776. private _disableLighting;
  70777. disableLighting: boolean;
  70778. private _maxSimultaneousLights;
  70779. maxSimultaneousLights: number;
  70780. private _renderId;
  70781. constructor(name: string, scene: BABYLON.Scene);
  70782. needAlphaBlending(): boolean;
  70783. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70784. needAlphaTesting(): boolean;
  70785. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70786. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70787. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70788. getAnimatables(): BABYLON.IAnimatable[];
  70789. getActiveTextures(): BABYLON.BaseTexture[];
  70790. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70791. dispose(forceDisposeEffect?: boolean): void;
  70792. clone(name: string): NormalMaterial;
  70793. serialize(): any;
  70794. getClassName(): string;
  70795. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70796. }
  70797. }
  70798. declare module BABYLON {
  70799. /** @hidden */
  70800. export var shadowOnlyPixelShader: {
  70801. name: string;
  70802. shader: string;
  70803. };
  70804. }
  70805. declare module BABYLON {
  70806. /** @hidden */
  70807. export var shadowOnlyVertexShader: {
  70808. name: string;
  70809. shader: string;
  70810. };
  70811. }
  70812. declare module BABYLON {
  70813. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70814. private _renderId;
  70815. private _activeLight;
  70816. constructor(name: string, scene: BABYLON.Scene);
  70817. shadowColor: BABYLON.Color3;
  70818. needAlphaBlending(): boolean;
  70819. needAlphaTesting(): boolean;
  70820. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70821. activeLight: BABYLON.IShadowLight;
  70822. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70823. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70824. clone(name: string): ShadowOnlyMaterial;
  70825. serialize(): any;
  70826. getClassName(): string;
  70827. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70828. }
  70829. }
  70830. declare module BABYLON {
  70831. /** @hidden */
  70832. export var simplePixelShader: {
  70833. name: string;
  70834. shader: string;
  70835. };
  70836. }
  70837. declare module BABYLON {
  70838. /** @hidden */
  70839. export var simpleVertexShader: {
  70840. name: string;
  70841. shader: string;
  70842. };
  70843. }
  70844. declare module BABYLON {
  70845. export class SimpleMaterial extends BABYLON.PushMaterial {
  70846. private _diffuseTexture;
  70847. diffuseTexture: BABYLON.BaseTexture;
  70848. diffuseColor: BABYLON.Color3;
  70849. private _disableLighting;
  70850. disableLighting: boolean;
  70851. private _maxSimultaneousLights;
  70852. maxSimultaneousLights: number;
  70853. private _renderId;
  70854. constructor(name: string, scene: BABYLON.Scene);
  70855. needAlphaBlending(): boolean;
  70856. needAlphaTesting(): boolean;
  70857. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70858. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70859. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70860. getAnimatables(): BABYLON.IAnimatable[];
  70861. getActiveTextures(): BABYLON.BaseTexture[];
  70862. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70863. dispose(forceDisposeEffect?: boolean): void;
  70864. clone(name: string): SimpleMaterial;
  70865. serialize(): any;
  70866. getClassName(): string;
  70867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70868. }
  70869. }
  70870. declare module BABYLON {
  70871. /** @hidden */
  70872. export var skyPixelShader: {
  70873. name: string;
  70874. shader: string;
  70875. };
  70876. }
  70877. declare module BABYLON {
  70878. /** @hidden */
  70879. export var skyVertexShader: {
  70880. name: string;
  70881. shader: string;
  70882. };
  70883. }
  70884. declare module BABYLON {
  70885. /**
  70886. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70887. * @see https://doc.babylonjs.com/extensions/sky
  70888. */
  70889. export class SkyMaterial extends BABYLON.PushMaterial {
  70890. /**
  70891. * Defines the overall luminance of sky in interval ]0, 1[.
  70892. */
  70893. luminance: number;
  70894. /**
  70895. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70896. */
  70897. turbidity: number;
  70898. /**
  70899. * Defines the sky appearance (light intensity).
  70900. */
  70901. rayleigh: number;
  70902. /**
  70903. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70904. */
  70905. mieCoefficient: number;
  70906. /**
  70907. * Defines the amount of haze particles following the Mie scattering theory.
  70908. */
  70909. mieDirectionalG: number;
  70910. /**
  70911. * Defines the distance of the sun according to the active scene camera.
  70912. */
  70913. distance: number;
  70914. /**
  70915. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70916. * "inclined".
  70917. */
  70918. inclination: number;
  70919. /**
  70920. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70921. * an object direction and a reference direction.
  70922. */
  70923. azimuth: number;
  70924. /**
  70925. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70926. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70927. */
  70928. sunPosition: BABYLON.Vector3;
  70929. /**
  70930. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70931. * .sunPosition property.
  70932. */
  70933. useSunPosition: boolean;
  70934. /**
  70935. * Defines an offset vector used to get a horizon offset.
  70936. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70937. */
  70938. cameraOffset: BABYLON.Vector3;
  70939. private _cameraPosition;
  70940. private _renderId;
  70941. /**
  70942. * Instantiates a new sky material.
  70943. * This material allows to create dynamic and texture free
  70944. * effects for skyboxes by taking care of the atmosphere state.
  70945. * @see https://doc.babylonjs.com/extensions/sky
  70946. * @param name Define the name of the material in the scene
  70947. * @param scene Define the scene the material belong to
  70948. */
  70949. constructor(name: string, scene: BABYLON.Scene);
  70950. /**
  70951. * Specifies if the material will require alpha blending
  70952. * @returns a boolean specifying if alpha blending is needed
  70953. */
  70954. needAlphaBlending(): boolean;
  70955. /**
  70956. * Specifies if this material should be rendered in alpha test mode
  70957. * @returns false as the sky material doesn't need alpha testing.
  70958. */
  70959. needAlphaTesting(): boolean;
  70960. /**
  70961. * Get the texture used for alpha test purpose.
  70962. * @returns null as the sky material has no texture.
  70963. */
  70964. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70965. /**
  70966. * Get if the submesh is ready to be used and all its information available.
  70967. * Child classes can use it to update shaders
  70968. * @param mesh defines the mesh to check
  70969. * @param subMesh defines which submesh to check
  70970. * @param useInstances specifies that instances should be used
  70971. * @returns a boolean indicating that the submesh is ready or not
  70972. */
  70973. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70974. /**
  70975. * Binds the submesh to this material by preparing the effect and shader to draw
  70976. * @param world defines the world transformation matrix
  70977. * @param mesh defines the mesh containing the submesh
  70978. * @param subMesh defines the submesh to bind the material to
  70979. */
  70980. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70981. /**
  70982. * Get the list of animatables in the material.
  70983. * @returns the list of animatables object used in the material
  70984. */
  70985. getAnimatables(): BABYLON.IAnimatable[];
  70986. /**
  70987. * Disposes the material
  70988. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70989. */
  70990. dispose(forceDisposeEffect?: boolean): void;
  70991. /**
  70992. * Makes a duplicate of the material, and gives it a new name
  70993. * @param name defines the new name for the duplicated material
  70994. * @returns the cloned material
  70995. */
  70996. clone(name: string): SkyMaterial;
  70997. /**
  70998. * Serializes this material in a JSON representation
  70999. * @returns the serialized material object
  71000. */
  71001. serialize(): any;
  71002. /**
  71003. * Gets the current class name of the material e.g. "SkyMaterial"
  71004. * Mainly use in serialization.
  71005. * @returns the class name
  71006. */
  71007. getClassName(): string;
  71008. /**
  71009. * Creates a sky material from parsed material data
  71010. * @param source defines the JSON representation of the material
  71011. * @param scene defines the hosting scene
  71012. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71013. * @returns a new sky material
  71014. */
  71015. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71016. }
  71017. }
  71018. declare module BABYLON {
  71019. /** @hidden */
  71020. export var terrainPixelShader: {
  71021. name: string;
  71022. shader: string;
  71023. };
  71024. }
  71025. declare module BABYLON {
  71026. /** @hidden */
  71027. export var terrainVertexShader: {
  71028. name: string;
  71029. shader: string;
  71030. };
  71031. }
  71032. declare module BABYLON {
  71033. export class TerrainMaterial extends BABYLON.PushMaterial {
  71034. private _mixTexture;
  71035. mixTexture: BABYLON.BaseTexture;
  71036. private _diffuseTexture1;
  71037. diffuseTexture1: BABYLON.Texture;
  71038. private _diffuseTexture2;
  71039. diffuseTexture2: BABYLON.Texture;
  71040. private _diffuseTexture3;
  71041. diffuseTexture3: BABYLON.Texture;
  71042. private _bumpTexture1;
  71043. bumpTexture1: BABYLON.Texture;
  71044. private _bumpTexture2;
  71045. bumpTexture2: BABYLON.Texture;
  71046. private _bumpTexture3;
  71047. bumpTexture3: BABYLON.Texture;
  71048. diffuseColor: BABYLON.Color3;
  71049. specularColor: BABYLON.Color3;
  71050. specularPower: number;
  71051. private _disableLighting;
  71052. disableLighting: boolean;
  71053. private _maxSimultaneousLights;
  71054. maxSimultaneousLights: number;
  71055. private _renderId;
  71056. constructor(name: string, scene: BABYLON.Scene);
  71057. needAlphaBlending(): boolean;
  71058. needAlphaTesting(): boolean;
  71059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71062. getAnimatables(): BABYLON.IAnimatable[];
  71063. getActiveTextures(): BABYLON.BaseTexture[];
  71064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71065. dispose(forceDisposeEffect?: boolean): void;
  71066. clone(name: string): TerrainMaterial;
  71067. serialize(): any;
  71068. getClassName(): string;
  71069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71070. }
  71071. }
  71072. declare module BABYLON {
  71073. /** @hidden */
  71074. export var triplanarPixelShader: {
  71075. name: string;
  71076. shader: string;
  71077. };
  71078. }
  71079. declare module BABYLON {
  71080. /** @hidden */
  71081. export var triplanarVertexShader: {
  71082. name: string;
  71083. shader: string;
  71084. };
  71085. }
  71086. declare module BABYLON {
  71087. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71088. mixTexture: BABYLON.BaseTexture;
  71089. private _diffuseTextureX;
  71090. diffuseTextureX: BABYLON.BaseTexture;
  71091. private _diffuseTextureY;
  71092. diffuseTextureY: BABYLON.BaseTexture;
  71093. private _diffuseTextureZ;
  71094. diffuseTextureZ: BABYLON.BaseTexture;
  71095. private _normalTextureX;
  71096. normalTextureX: BABYLON.BaseTexture;
  71097. private _normalTextureY;
  71098. normalTextureY: BABYLON.BaseTexture;
  71099. private _normalTextureZ;
  71100. normalTextureZ: BABYLON.BaseTexture;
  71101. tileSize: number;
  71102. diffuseColor: BABYLON.Color3;
  71103. specularColor: BABYLON.Color3;
  71104. specularPower: number;
  71105. private _disableLighting;
  71106. disableLighting: boolean;
  71107. private _maxSimultaneousLights;
  71108. maxSimultaneousLights: number;
  71109. private _renderId;
  71110. constructor(name: string, scene: BABYLON.Scene);
  71111. needAlphaBlending(): boolean;
  71112. needAlphaTesting(): boolean;
  71113. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71114. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71115. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71116. getAnimatables(): BABYLON.IAnimatable[];
  71117. getActiveTextures(): BABYLON.BaseTexture[];
  71118. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71119. dispose(forceDisposeEffect?: boolean): void;
  71120. clone(name: string): TriPlanarMaterial;
  71121. serialize(): any;
  71122. getClassName(): string;
  71123. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71124. }
  71125. }
  71126. declare module BABYLON {
  71127. /** @hidden */
  71128. export var waterPixelShader: {
  71129. name: string;
  71130. shader: string;
  71131. };
  71132. }
  71133. declare module BABYLON {
  71134. /** @hidden */
  71135. export var waterVertexShader: {
  71136. name: string;
  71137. shader: string;
  71138. };
  71139. }
  71140. declare module BABYLON {
  71141. export class WaterMaterial extends BABYLON.PushMaterial {
  71142. renderTargetSize: BABYLON.Vector2;
  71143. private _bumpTexture;
  71144. bumpTexture: BABYLON.BaseTexture;
  71145. diffuseColor: BABYLON.Color3;
  71146. specularColor: BABYLON.Color3;
  71147. specularPower: number;
  71148. private _disableLighting;
  71149. disableLighting: boolean;
  71150. private _maxSimultaneousLights;
  71151. maxSimultaneousLights: number;
  71152. /**
  71153. * @param {number}: Represents the wind force
  71154. */
  71155. windForce: number;
  71156. /**
  71157. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71158. */
  71159. windDirection: BABYLON.Vector2;
  71160. /**
  71161. * @param {number}: Wave height, represents the height of the waves
  71162. */
  71163. waveHeight: number;
  71164. /**
  71165. * @param {number}: Bump height, represents the bump height related to the bump map
  71166. */
  71167. bumpHeight: number;
  71168. /**
  71169. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71170. */
  71171. private _bumpSuperimpose;
  71172. bumpSuperimpose: boolean;
  71173. /**
  71174. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71175. */
  71176. private _fresnelSeparate;
  71177. fresnelSeparate: boolean;
  71178. /**
  71179. * @param {boolean}: bump Waves modify the reflection.
  71180. */
  71181. private _bumpAffectsReflection;
  71182. bumpAffectsReflection: boolean;
  71183. /**
  71184. * @param {number}: The water color blended with the refraction (near)
  71185. */
  71186. waterColor: BABYLON.Color3;
  71187. /**
  71188. * @param {number}: The blend factor related to the water color
  71189. */
  71190. colorBlendFactor: number;
  71191. /**
  71192. * @param {number}: The water color blended with the reflection (far)
  71193. */
  71194. waterColor2: BABYLON.Color3;
  71195. /**
  71196. * @param {number}: The blend factor related to the water color (reflection, far)
  71197. */
  71198. colorBlendFactor2: number;
  71199. /**
  71200. * @param {number}: Represents the maximum length of a wave
  71201. */
  71202. waveLength: number;
  71203. /**
  71204. * @param {number}: Defines the waves speed
  71205. */
  71206. waveSpeed: number;
  71207. /**
  71208. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71209. * will avoid calculating useless pixels in the pixel shader of the water material.
  71210. */
  71211. disableClipPlane: boolean;
  71212. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71213. private _mesh;
  71214. private _refractionRTT;
  71215. private _reflectionRTT;
  71216. private _reflectionTransform;
  71217. private _lastTime;
  71218. private _lastDeltaTime;
  71219. private _renderId;
  71220. private _useLogarithmicDepth;
  71221. private _waitingRenderList;
  71222. private _imageProcessingConfiguration;
  71223. private _imageProcessingObserver;
  71224. /**
  71225. * Gets a boolean indicating that current material needs to register RTT
  71226. */
  71227. readonly hasRenderTargetTextures: boolean;
  71228. /**
  71229. * Constructor
  71230. */
  71231. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71232. useLogarithmicDepth: boolean;
  71233. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71234. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71235. addToRenderList(node: any): void;
  71236. enableRenderTargets(enable: boolean): void;
  71237. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71238. readonly renderTargetsEnabled: boolean;
  71239. needAlphaBlending(): boolean;
  71240. needAlphaTesting(): boolean;
  71241. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71242. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71243. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71244. private _createRenderTargets;
  71245. getAnimatables(): BABYLON.IAnimatable[];
  71246. getActiveTextures(): BABYLON.BaseTexture[];
  71247. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71248. dispose(forceDisposeEffect?: boolean): void;
  71249. clone(name: string): WaterMaterial;
  71250. serialize(): any;
  71251. getClassName(): string;
  71252. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71253. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71254. }
  71255. }
  71256. declare module BABYLON {
  71257. /** @hidden */
  71258. export var asciiartPixelShader: {
  71259. name: string;
  71260. shader: string;
  71261. };
  71262. }
  71263. declare module BABYLON {
  71264. /**
  71265. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71266. *
  71267. * It basically takes care rendering the font front the given font size to a texture.
  71268. * This is used later on in the postprocess.
  71269. */
  71270. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71271. private _font;
  71272. private _text;
  71273. private _charSize;
  71274. /**
  71275. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71276. */
  71277. readonly charSize: number;
  71278. /**
  71279. * Create a new instance of the Ascii Art FontTexture class
  71280. * @param name the name of the texture
  71281. * @param font the font to use, use the W3C CSS notation
  71282. * @param text the caracter set to use in the rendering.
  71283. * @param scene the scene that owns the texture
  71284. */
  71285. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71286. /**
  71287. * Gets the max char width of a font.
  71288. * @param font the font to use, use the W3C CSS notation
  71289. * @return the max char width
  71290. */
  71291. private getFontWidth;
  71292. /**
  71293. * Gets the max char height of a font.
  71294. * @param font the font to use, use the W3C CSS notation
  71295. * @return the max char height
  71296. */
  71297. private getFontHeight;
  71298. /**
  71299. * Clones the current AsciiArtTexture.
  71300. * @return the clone of the texture.
  71301. */
  71302. clone(): AsciiArtFontTexture;
  71303. /**
  71304. * Parses a json object representing the texture and returns an instance of it.
  71305. * @param source the source JSON representation
  71306. * @param scene the scene to create the texture for
  71307. * @return the parsed texture
  71308. */
  71309. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71310. }
  71311. /**
  71312. * Option available in the Ascii Art Post Process.
  71313. */
  71314. export interface IAsciiArtPostProcessOptions {
  71315. /**
  71316. * The font to use following the w3c font definition.
  71317. */
  71318. font?: string;
  71319. /**
  71320. * The character set to use in the postprocess.
  71321. */
  71322. characterSet?: string;
  71323. /**
  71324. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71325. * This number is defined between 0 and 1;
  71326. */
  71327. mixToTile?: number;
  71328. /**
  71329. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71330. * This number is defined between 0 and 1;
  71331. */
  71332. mixToNormal?: number;
  71333. }
  71334. /**
  71335. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71336. *
  71337. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71338. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71339. */
  71340. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71341. /**
  71342. * The font texture used to render the char in the post process.
  71343. */
  71344. private _asciiArtFontTexture;
  71345. /**
  71346. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71347. * This number is defined between 0 and 1;
  71348. */
  71349. mixToTile: number;
  71350. /**
  71351. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71352. * This number is defined between 0 and 1;
  71353. */
  71354. mixToNormal: number;
  71355. /**
  71356. * Instantiates a new Ascii Art Post Process.
  71357. * @param name the name to give to the postprocess
  71358. * @camera the camera to apply the post process to.
  71359. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71360. */
  71361. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71362. }
  71363. }
  71364. declare module BABYLON {
  71365. /** @hidden */
  71366. export var digitalrainPixelShader: {
  71367. name: string;
  71368. shader: string;
  71369. };
  71370. }
  71371. declare module BABYLON {
  71372. /**
  71373. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71374. *
  71375. * It basically takes care rendering the font front the given font size to a texture.
  71376. * This is used later on in the postprocess.
  71377. */
  71378. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71379. private _font;
  71380. private _text;
  71381. private _charSize;
  71382. /**
  71383. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71384. */
  71385. readonly charSize: number;
  71386. /**
  71387. * Create a new instance of the Digital Rain FontTexture class
  71388. * @param name the name of the texture
  71389. * @param font the font to use, use the W3C CSS notation
  71390. * @param text the caracter set to use in the rendering.
  71391. * @param scene the scene that owns the texture
  71392. */
  71393. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71394. /**
  71395. * Gets the max char width of a font.
  71396. * @param font the font to use, use the W3C CSS notation
  71397. * @return the max char width
  71398. */
  71399. private getFontWidth;
  71400. /**
  71401. * Gets the max char height of a font.
  71402. * @param font the font to use, use the W3C CSS notation
  71403. * @return the max char height
  71404. */
  71405. private getFontHeight;
  71406. /**
  71407. * Clones the current DigitalRainFontTexture.
  71408. * @return the clone of the texture.
  71409. */
  71410. clone(): DigitalRainFontTexture;
  71411. /**
  71412. * Parses a json object representing the texture and returns an instance of it.
  71413. * @param source the source JSON representation
  71414. * @param scene the scene to create the texture for
  71415. * @return the parsed texture
  71416. */
  71417. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71418. }
  71419. /**
  71420. * Option available in the Digital Rain Post Process.
  71421. */
  71422. export interface IDigitalRainPostProcessOptions {
  71423. /**
  71424. * The font to use following the w3c font definition.
  71425. */
  71426. font?: string;
  71427. /**
  71428. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71429. * This number is defined between 0 and 1;
  71430. */
  71431. mixToTile?: number;
  71432. /**
  71433. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71434. * This number is defined between 0 and 1;
  71435. */
  71436. mixToNormal?: number;
  71437. }
  71438. /**
  71439. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71440. *
  71441. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71442. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71443. */
  71444. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71445. /**
  71446. * The font texture used to render the char in the post process.
  71447. */
  71448. private _digitalRainFontTexture;
  71449. /**
  71450. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71451. * This number is defined between 0 and 1;
  71452. */
  71453. mixToTile: number;
  71454. /**
  71455. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71456. * This number is defined between 0 and 1;
  71457. */
  71458. mixToNormal: number;
  71459. /**
  71460. * Instantiates a new Digital Rain Post Process.
  71461. * @param name the name to give to the postprocess
  71462. * @camera the camera to apply the post process to.
  71463. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71464. */
  71465. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. /** @hidden */
  71470. export var oceanPostProcessPixelShader: {
  71471. name: string;
  71472. shader: string;
  71473. };
  71474. }
  71475. declare module BABYLON {
  71476. /**
  71477. * Option available in the Ocean Post Process.
  71478. */
  71479. export interface IOceanPostProcessOptions {
  71480. /**
  71481. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71482. */
  71483. reflectionSize?: number | {
  71484. width: number;
  71485. height: number;
  71486. } | {
  71487. ratio: number;
  71488. };
  71489. /**
  71490. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71491. */
  71492. refractionSize?: number | {
  71493. width: number;
  71494. height: number;
  71495. } | {
  71496. ratio: number;
  71497. };
  71498. }
  71499. /**
  71500. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71501. *
  71502. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71503. * Example usage:
  71504. * var pp = new OceanPostProcess("myOcean", camera);
  71505. * pp.reflectionEnabled = true;
  71506. * pp.refractionEnabled = true;
  71507. */
  71508. export class OceanPostProcess extends BABYLON.PostProcess {
  71509. /**
  71510. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71511. */
  71512. /**
  71513. * Sets weither or not the real-time reflection is enabled on the ocean.
  71514. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71515. */
  71516. reflectionEnabled: boolean;
  71517. /**
  71518. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71519. */
  71520. /**
  71521. * Sets weither or not the real-time refraction is enabled on the ocean.
  71522. * Is set to true, the refraction render target texture will be used as refraction texture.
  71523. */
  71524. refractionEnabled: boolean;
  71525. /**
  71526. * Gets wether or not the post-processes is supported by the running hardware.
  71527. * This requires draw buffer supports.
  71528. */
  71529. readonly isSupported: boolean;
  71530. /**
  71531. * This is the reflection mirror texture used to display reflections on the ocean.
  71532. * By default, render list is empty.
  71533. */
  71534. reflectionTexture: BABYLON.MirrorTexture;
  71535. /**
  71536. * This is the refraction render target texture used to display refraction on the ocean.
  71537. * By default, render list is empty.
  71538. */
  71539. refractionTexture: BABYLON.RenderTargetTexture;
  71540. private _time;
  71541. private _cameraRotation;
  71542. private _cameraViewMatrix;
  71543. private _reflectionEnabled;
  71544. private _refractionEnabled;
  71545. private _geometryRenderer;
  71546. /**
  71547. * Instantiates a new Ocean Post Process.
  71548. * @param name the name to give to the postprocess.
  71549. * @camera the camera to apply the post process to.
  71550. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71551. */
  71552. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71553. /**
  71554. * Returns the appropriate defines according to the current configuration.
  71555. */
  71556. private _getDefines;
  71557. /**
  71558. * Computes the current camera rotation as the shader requires a camera rotation.
  71559. */
  71560. private _computeCameraRotation;
  71561. }
  71562. }
  71563. declare module BABYLON {
  71564. /** @hidden */
  71565. export var brickProceduralTexturePixelShader: {
  71566. name: string;
  71567. shader: string;
  71568. };
  71569. }
  71570. declare module BABYLON {
  71571. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71572. private _numberOfBricksHeight;
  71573. private _numberOfBricksWidth;
  71574. private _jointColor;
  71575. private _brickColor;
  71576. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71577. updateShaderUniforms(): void;
  71578. numberOfBricksHeight: number;
  71579. numberOfBricksWidth: number;
  71580. jointColor: BABYLON.Color3;
  71581. brickColor: BABYLON.Color3;
  71582. /**
  71583. * Serializes this brick procedural texture
  71584. * @returns a serialized brick procedural texture object
  71585. */
  71586. serialize(): any;
  71587. /**
  71588. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71589. * @param parsedTexture defines parsed texture data
  71590. * @param scene defines the current scene
  71591. * @param rootUrl defines the root URL containing brick procedural texture information
  71592. * @returns a parsed Brick Procedural BABYLON.Texture
  71593. */
  71594. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71595. }
  71596. }
  71597. declare module BABYLON {
  71598. /** @hidden */
  71599. export var cloudProceduralTexturePixelShader: {
  71600. name: string;
  71601. shader: string;
  71602. };
  71603. }
  71604. declare module BABYLON {
  71605. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71606. private _skyColor;
  71607. private _cloudColor;
  71608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71609. updateShaderUniforms(): void;
  71610. skyColor: BABYLON.Color4;
  71611. cloudColor: BABYLON.Color4;
  71612. /**
  71613. * Serializes this cloud procedural texture
  71614. * @returns a serialized cloud procedural texture object
  71615. */
  71616. serialize(): any;
  71617. /**
  71618. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71619. * @param parsedTexture defines parsed texture data
  71620. * @param scene defines the current scene
  71621. * @param rootUrl defines the root URL containing cloud procedural texture information
  71622. * @returns a parsed Cloud Procedural BABYLON.Texture
  71623. */
  71624. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71625. }
  71626. }
  71627. declare module BABYLON {
  71628. /** @hidden */
  71629. export var fireProceduralTexturePixelShader: {
  71630. name: string;
  71631. shader: string;
  71632. };
  71633. }
  71634. declare module BABYLON {
  71635. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71636. private _time;
  71637. private _speed;
  71638. private _autoGenerateTime;
  71639. private _fireColors;
  71640. private _alphaThreshold;
  71641. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71642. updateShaderUniforms(): void;
  71643. render(useCameraPostProcess?: boolean): void;
  71644. static readonly PurpleFireColors: BABYLON.Color3[];
  71645. static readonly GreenFireColors: BABYLON.Color3[];
  71646. static readonly RedFireColors: BABYLON.Color3[];
  71647. static readonly BlueFireColors: BABYLON.Color3[];
  71648. autoGenerateTime: boolean;
  71649. fireColors: BABYLON.Color3[];
  71650. time: number;
  71651. speed: BABYLON.Vector2;
  71652. alphaThreshold: number;
  71653. /**
  71654. * Serializes this fire procedural texture
  71655. * @returns a serialized fire procedural texture object
  71656. */
  71657. serialize(): any;
  71658. /**
  71659. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71660. * @param parsedTexture defines parsed texture data
  71661. * @param scene defines the current scene
  71662. * @param rootUrl defines the root URL containing fire procedural texture information
  71663. * @returns a parsed Fire Procedural BABYLON.Texture
  71664. */
  71665. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71666. }
  71667. }
  71668. declare module BABYLON {
  71669. /** @hidden */
  71670. export var grassProceduralTexturePixelShader: {
  71671. name: string;
  71672. shader: string;
  71673. };
  71674. }
  71675. declare module BABYLON {
  71676. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71677. private _grassColors;
  71678. private _groundColor;
  71679. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71680. updateShaderUniforms(): void;
  71681. grassColors: BABYLON.Color3[];
  71682. groundColor: BABYLON.Color3;
  71683. /**
  71684. * Serializes this grass procedural texture
  71685. * @returns a serialized grass procedural texture object
  71686. */
  71687. serialize(): any;
  71688. /**
  71689. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71690. * @param parsedTexture defines parsed texture data
  71691. * @param scene defines the current scene
  71692. * @param rootUrl defines the root URL containing grass procedural texture information
  71693. * @returns a parsed Grass Procedural BABYLON.Texture
  71694. */
  71695. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71696. }
  71697. }
  71698. declare module BABYLON {
  71699. /** @hidden */
  71700. export var marbleProceduralTexturePixelShader: {
  71701. name: string;
  71702. shader: string;
  71703. };
  71704. }
  71705. declare module BABYLON {
  71706. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71707. private _numberOfTilesHeight;
  71708. private _numberOfTilesWidth;
  71709. private _amplitude;
  71710. private _jointColor;
  71711. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71712. updateShaderUniforms(): void;
  71713. numberOfTilesHeight: number;
  71714. amplitude: number;
  71715. numberOfTilesWidth: number;
  71716. jointColor: BABYLON.Color3;
  71717. /**
  71718. * Serializes this marble procedural texture
  71719. * @returns a serialized marble procedural texture object
  71720. */
  71721. serialize(): any;
  71722. /**
  71723. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71724. * @param parsedTexture defines parsed texture data
  71725. * @param scene defines the current scene
  71726. * @param rootUrl defines the root URL containing marble procedural texture information
  71727. * @returns a parsed Marble Procedural BABYLON.Texture
  71728. */
  71729. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71730. }
  71731. }
  71732. declare module BABYLON {
  71733. /** @hidden */
  71734. export var normalMapProceduralTexturePixelShader: {
  71735. name: string;
  71736. shader: string;
  71737. };
  71738. }
  71739. declare module BABYLON {
  71740. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71741. private _baseTexture;
  71742. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71743. updateShaderUniforms(): void;
  71744. render(useCameraPostProcess?: boolean): void;
  71745. resize(size: any, generateMipMaps: any): void;
  71746. baseTexture: BABYLON.Texture;
  71747. /**
  71748. * Serializes this normal map procedural texture
  71749. * @returns a serialized normal map procedural texture object
  71750. */
  71751. serialize(): any;
  71752. /**
  71753. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71754. * @param parsedTexture defines parsed texture data
  71755. * @param scene defines the current scene
  71756. * @param rootUrl defines the root URL containing normal map procedural texture information
  71757. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71758. */
  71759. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71760. }
  71761. }
  71762. declare module BABYLON {
  71763. /** @hidden */
  71764. export var perlinNoiseProceduralTexturePixelShader: {
  71765. name: string;
  71766. shader: string;
  71767. };
  71768. }
  71769. declare module BABYLON {
  71770. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71771. time: number;
  71772. timeScale: number;
  71773. translationSpeed: number;
  71774. private _currentTranslation;
  71775. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71776. updateShaderUniforms(): void;
  71777. render(useCameraPostProcess?: boolean): void;
  71778. resize(size: any, generateMipMaps: any): void;
  71779. /**
  71780. * Serializes this perlin noise procedural texture
  71781. * @returns a serialized perlin noise procedural texture object
  71782. */
  71783. serialize(): any;
  71784. /**
  71785. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71786. * @param parsedTexture defines parsed texture data
  71787. * @param scene defines the current scene
  71788. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71789. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71790. */
  71791. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71792. }
  71793. }
  71794. declare module BABYLON {
  71795. /** @hidden */
  71796. export var roadProceduralTexturePixelShader: {
  71797. name: string;
  71798. shader: string;
  71799. };
  71800. }
  71801. declare module BABYLON {
  71802. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71803. private _roadColor;
  71804. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71805. updateShaderUniforms(): void;
  71806. roadColor: BABYLON.Color3;
  71807. /**
  71808. * Serializes this road procedural texture
  71809. * @returns a serialized road procedural texture object
  71810. */
  71811. serialize(): any;
  71812. /**
  71813. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71814. * @param parsedTexture defines parsed texture data
  71815. * @param scene defines the current scene
  71816. * @param rootUrl defines the root URL containing road procedural texture information
  71817. * @returns a parsed Road Procedural BABYLON.Texture
  71818. */
  71819. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71820. }
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export var starfieldProceduralTexturePixelShader: {
  71825. name: string;
  71826. shader: string;
  71827. };
  71828. }
  71829. declare module BABYLON {
  71830. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71831. private _time;
  71832. private _alpha;
  71833. private _beta;
  71834. private _zoom;
  71835. private _formuparam;
  71836. private _stepsize;
  71837. private _tile;
  71838. private _brightness;
  71839. private _darkmatter;
  71840. private _distfading;
  71841. private _saturation;
  71842. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71843. updateShaderUniforms(): void;
  71844. time: number;
  71845. alpha: number;
  71846. beta: number;
  71847. formuparam: number;
  71848. stepsize: number;
  71849. zoom: number;
  71850. tile: number;
  71851. brightness: number;
  71852. darkmatter: number;
  71853. distfading: number;
  71854. saturation: number;
  71855. /**
  71856. * Serializes this starfield procedural texture
  71857. * @returns a serialized starfield procedural texture object
  71858. */
  71859. serialize(): any;
  71860. /**
  71861. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71862. * @param parsedTexture defines parsed texture data
  71863. * @param scene defines the current scene
  71864. * @param rootUrl defines the root URL containing startfield procedural texture information
  71865. * @returns a parsed Starfield Procedural BABYLON.Texture
  71866. */
  71867. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71868. }
  71869. }
  71870. declare module BABYLON {
  71871. /** @hidden */
  71872. export var woodProceduralTexturePixelShader: {
  71873. name: string;
  71874. shader: string;
  71875. };
  71876. }
  71877. declare module BABYLON {
  71878. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71879. private _ampScale;
  71880. private _woodColor;
  71881. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71882. updateShaderUniforms(): void;
  71883. ampScale: number;
  71884. woodColor: BABYLON.Color3;
  71885. /**
  71886. * Serializes this wood procedural texture
  71887. * @returns a serialized wood procedural texture object
  71888. */
  71889. serialize(): any;
  71890. /**
  71891. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71892. * @param parsedTexture defines parsed texture data
  71893. * @param scene defines the current scene
  71894. * @param rootUrl defines the root URL containing wood procedural texture information
  71895. * @returns a parsed Wood Procedural BABYLON.Texture
  71896. */
  71897. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71898. }
  71899. }